@buaa_smat/hometrans 0.1.16 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -54
- package/agents/code-reviewer.md +321 -65
- package/agents/logic-coder.md +113 -88
- package/agents/logic-context-builder.md +47 -29
- package/agents/scripts/hmos-precheck/backends/arkts.mjs +567 -0
- package/agents/scripts/hmos-precheck/backends/arkts_diff.mjs +159 -0
- package/agents/scripts/hmos-precheck/backends/arkts_project_rules.mjs +398 -0
- package/agents/scripts/hmos-precheck/backends/codelinter.mjs +250 -0
- package/agents/scripts/hmos-precheck/backends/project_integrity.mjs +321 -0
- package/agents/scripts/hmos-precheck/backends/static_precheck.mjs +247 -0
- package/agents/scripts/hmos-precheck/core/config.mjs +184 -0
- package/agents/scripts/hmos-precheck/core/diagnostic_scope.mjs +20 -0
- package/agents/scripts/hmos-precheck/core/process_adapter.mjs +47 -0
- package/agents/scripts/hmos-precheck/core/project_catalog.mjs +50 -0
- package/agents/scripts/hmos-precheck/core/result_projection.mjs +147 -0
- package/agents/scripts/hmos-precheck/core/scope_plan.mjs +131 -0
- package/agents/scripts/hmos-precheck/core/sdk_context.mjs +67 -0
- package/agents/scripts/hmos-precheck/docs/architecture.md +37 -0
- package/agents/scripts/hmos-precheck/docs/performance-optimization.md +28 -0
- package/agents/scripts/hmos-precheck/docs/upstream-reference.json +19 -0
- package/agents/scripts/hmos-precheck/docs/validation.md +50 -0
- package/agents/scripts/hmos-precheck/index.mjs +17 -0
- package/agents/scripts/hmos-precheck/invocation.mjs +231 -0
- package/agents/scripts/hmos-precheck/rules/rule_case_matrix.csv +32 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.csv +64 -0
- package/agents/scripts/hmos-precheck/rules/rule_inventory.mjs +59 -0
- package/agents/scripts/hmos-precheck/rules/rule_policy.mjs +54 -0
- package/agents/scripts/platform_query.mjs +626 -0
- package/agents/scripts/platform_query.test.mjs +422 -0
- package/agents/self-test-fixer.md +36 -34
- package/agents/self-tester.md +123 -143
- package/agents/test-case-generation-generator.md +317 -0
- package/agents/test-case-generation-validator.md +231 -0
- package/dist/cli/config-store.js +16 -63
- package/dist/cli/env-vars.js +1 -3
- package/dist/cli/index.js +0 -11
- package/dist/cli/init.js +127 -144
- package/dist/cli/uninstall.js +76 -110
- package/dist/utils/regex.js +8 -0
- package/env-requirements.json +55 -54
- package/package.json +6 -6
- package/resource/convert_pipeline_process.svg +103 -0
- package/resource/project_architecture.svg +122 -0
- package/resource/title_dark.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +345 -41
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +661 -180
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-batch-ui-align/references/mvvm-v2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +133 -0
- package/skills/hmos-batch-ui-align/references/mvvm-v2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.ts +1798 -0
- package/skills/hmos-batch-ui-align/scripts/arkts_static_check.ts +1592 -0
- package/skills/hmos-batch-ui-align/scripts/measure_pack.ts +752 -0
- package/skills/hmos-convert-pipeline/SKILL.md +168 -121
- package/skills/hmos-fix-build-errors/SKILL.md +87 -67
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
- package/skills/hmos-incremental-ui-align/README.md +53 -36
- package/skills/hmos-incremental-ui-align/SKILL.md +179 -23
- package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
- package/skills/hmos-incremental-ui-align/page_align.md +62 -62
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +38 -2
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/!!/350/257/255/346/263/225/357/274/232/345/217/214/345/220/221/347/273/221/345/256/232.md +206 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Computed/350/243/205/351/245/260/345/231/250/357/274/232/350/256/241/347/256/227/345/261/236/346/200/247.md +373 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Event/350/243/205/351/245/260/345/231/250/357/274/232/350/247/204/350/214/203/347/273/204/344/273/266/350/276/223/345/207/272.md +158 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Local/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/351/203/250/347/212/266/346/200/201.md +750 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Monitor/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/344/277/256/346/224/271/345/274/202/346/255/245/347/233/221/345/220/254.md +1704 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@ObservedV2/350/243/205/351/245/260/345/231/250/345/222/214@Trace/350/243/205/351/245/260/345/231/250/357/274/232/347/261/273/345/261/236/346/200/247/345/217/230/345/214/226/350/247/202/346/265/213.md +1012 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Once/350/243/205/351/245/260/345/231/250/357/274/232/345/210/235/345/247/213/345/214/226/345/220/214/346/255/245/344/270/200/346/254/241.md +164 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Param/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/244/226/351/203/250/350/276/223/345/205/245.md +840 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Provider/350/243/205/351/245/260/345/231/250/345/222/214@Consumer/350/243/205/351/245/260/345/231/250/357/274/232/350/267/250/347/273/204/344/273/266/345/261/202/347/272/247/345/217/214/345/220/221/345/220/214/346/255/245.md +856 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/@Type/350/243/205/351/245/260/345/231/250/357/274/232/346/240/207/350/256/260/347/261/273/345/261/236/346/200/247/347/232/204/347/261/273/345/236/213.md +83 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/AppStorageV2/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200UI/347/212/266/346/200/201/345/255/230/345/202/250.md +294 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/MVVM/346/250/241/345/274/217/357/274/210V2/357/274/211.md +1407 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/PersistenceV2/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +1220 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +47 -0
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243V2//347/212/266/346/200/201/347/256/241/347/220/206V1/345/220/221V2/350/277/201/347/247/273/344/270/216/346/267/267/347/224/250/346/214/207/345/257/274.md +840 -0
- package/skills/hmos-incremental-ui-align/references/State_Model_Template.md +74 -0
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +34 -4
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.ts +937 -0
- package/skills/hmos-incremental-ui-align/scripts/extract_checklist.ts +343 -0
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +44 -5
- package/skills/hmos-incremental-ui-align/scripts/page_capture.ts +977 -0
- package/skills/hmos-incremental-ui-align/scripts/page_capture_burst.ts +188 -0
- package/skills/hmos-integration-test/README.md +61 -70
- package/skills/hmos-integration-test/SKILL.md +128 -111
- package/skills/hmos-resources-convert/SKILL.md +334 -66
- package/skills/hmos-resources-convert/references/code-vector-icon-rules.md +335 -0
- package/skills/hmos-resources-convert/references/conversion-rules.md +676 -663
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +410 -388
- package/skills/hmos-resources-convert/references/lottie-conversion-rules.md +219 -0
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +482 -457
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +592 -513
- package/skills/hmos-resources-convert/scripts/a2h_resource_convert.ts +2163 -0
- package/skills/hmos-resources-convert/scripts/code_vector_icons.ts +591 -0
- package/skills/hmos-resources-convert/scripts/svg_fidelity_check.ts +632 -0
- package/skills/hmos-spec-generate/SKILL.md +293 -214
- package/skills/hmos-spec-generate/scripts/parse_requirements.ts +515 -0
- package/skills/hmos-spec-generate/template/REQ.txt +22 -0
- package/skills/hmos-spec-generate/template/REQ.xlsx +0 -0
- package/skills/hmos-test-case-generation/README.md +241 -0
- package/skills/hmos-test-case-generation/SKILL.md +324 -0
- package/skills/hmos-test-case-generation/references/contract.md +315 -0
- package/skills/hmos-test-case-generation/references/review-notes-template.md +84 -0
- package/skills/hmos-test-case-generation/references/ui-elements-schema.md +142 -0
- package/skills/hmos-test-case-generation/tools/convert_to_ui_elements.ts +550 -0
- package/skills/hmos-test-case-generation/tools/validate.ts +1312 -0
- package/tools/bfs-crawl/README.md +73 -0
- package/tools/bfs-crawl/android_viewtree_bfs_crawler.ts +1662 -0
- package/tools/test-tools/autotest/config.ts +175 -0
- package/tools/test-tools/autotest/deps/autotest-agent-0.1.1.tgz +0 -0
- package/tools/test-tools/autotest/docs/README.md +266 -0
- package/tools/test-tools/autotest/{testcases_schema.md → docs/testcases_schema.md} +1 -1
- package/tools/test-tools/autotest/engine/batch-launcher.ts +327 -0
- package/tools/test-tools/autotest/engine/report-tool.ts +773 -0
- package/tools/test-tools/autotest/engine/self-test-runner.ts +961 -0
- package/tools/test-tools/autotest/engine/testcases-tool.ts +246 -0
- package/tools/test-tools/autotest/paths.ts +41 -0
- package/tools/test-tools/autotest/resolve-metadata-tool.ts +143 -0
- package/tools/test-tools/autotest/runner/logger.ts +45 -0
- package/tools/test-tools/autotest/runner/process-utils.ts +41 -0
- package/tools/test-tools/autotest/validate.ts +167 -0
- package/agents/build-fixer.md +0 -385
- package/agents/logic-coder/scripts/platform_context_query.py +0 -568
- package/agents/review-fixer.md +0 -405
- package/agents/spec-generator.md +0 -541
- package/dist/cli/mcp-setup.js +0 -258
- package/dist/cli/mcp.js +0 -94
- package/dist/context/index.js +0 -694
- package/resource/migration_process.svg +0 -94
- package/resource/migration_process_transparent.svg +0 -93
- package/skills/hmos-batch-ui-align/scripts/android_parse_fast.py +0 -1606
- package/skills/hmos-incremental-ui-align/scripts/__pycache__/app_feature_verify.cpython-314.pyc +0 -0
- package/skills/hmos-incremental-ui-align/scripts/app_feature_verify.py +0 -542
- package/skills/hmos-incremental-ui-align/scripts/page_capture.py +0 -597
- package/skills/hmos-resources-convert/evals/evals.json +0 -171
- package/skills/hmos-resources-convert/template/AppScope/app.json5 +0 -10
- package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +0 -8
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/build-profile.json5 +0 -42
- package/skills/hmos-resources-convert/template/code-linter.json5 +0 -32
- package/skills/hmos-resources-convert/template/entry/build-profile.json5 +0 -33
- package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +0 -23
- package/skills/hmos-resources-convert/template/entry/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +0 -48
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +0 -23
- package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +0 -55
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +0 -16
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +0 -7
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +0 -3
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +0 -8
- package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +0 -2
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +0 -16
- package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +0 -5
- package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +0 -33
- package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +0 -23
- package/skills/hmos-resources-convert/template/hvigorfile.ts +0 -6
- package/skills/hmos-resources-convert/template/oh-package-lock.json5 +0 -28
- package/skills/hmos-resources-convert/template/oh-package.json5 +0 -10
- package/skills/hmos-resources-convert/tools/apktool.bat +0 -85
- package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
- package/skills/hmos-spec-generate/references/android-platform-tokens.md +0 -105
- package/skills/hmos-spec-generate/references/spec-sample-1.md +0 -78
- package/skills/hmos-spec-generate/references/spec-sample-2.md +0 -58
- package/skills/hmos-spec-generate/references/spec-sample-3.md +0 -116
- package/skills/hmos-spec-generate/references/step4-report-template.md +0 -33
- package/tools/test-tools/autotest/README.md +0 -238
- package/tools/test-tools/autotest/pyproject.toml +0 -26
- package/tools/test-tools/autotest/report_tool.py +0 -759
- package/tools/test-tools/autotest/self_test_runner.py +0 -895
- package/tools/test-tools/autotest/testcases_tool.py +0 -215
- package/tools/test-tools/autotest/uv.lock +0 -3156
- package/tools/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
- package/tools/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
|
@@ -1,597 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
# /// script
|
|
4
|
-
# requires-python = ">=3.10"
|
|
5
|
-
# [[tool.uv.index]]
|
|
6
|
-
# url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
7
|
-
# ///
|
|
8
|
-
"""
|
|
9
|
-
统一页面采集工具 —— 单次采集当前设备页面的 View Tree (XML)、截图,支持滚动采集。
|
|
10
|
-
|
|
11
|
-
支持 Android (ADB) 和 HarmonyOS (HDC) 两种设备。
|
|
12
|
-
|
|
13
|
-
用法:
|
|
14
|
-
# HarmonyOS
|
|
15
|
-
uv run page_capture.py --device hdc -o ./output
|
|
16
|
-
|
|
17
|
-
# Android
|
|
18
|
-
uv run page_capture.py --device adb -o ./output --serial emulator-5554
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
import argparse
|
|
22
|
-
import json
|
|
23
|
-
import os
|
|
24
|
-
import re
|
|
25
|
-
import subprocess
|
|
26
|
-
import sys
|
|
27
|
-
import time
|
|
28
|
-
import xml.etree.ElementTree as ET
|
|
29
|
-
from datetime import datetime
|
|
30
|
-
from pathlib import Path
|
|
31
|
-
|
|
32
|
-
# 强制设置 UTF-8 编码以避免 Windows GBK 编码问题
|
|
33
|
-
if sys.platform == 'win32':
|
|
34
|
-
import io
|
|
35
|
-
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
36
|
-
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
37
|
-
|
|
38
|
-
# ---------------------------------------------------------------------------
|
|
39
|
-
# Constants
|
|
40
|
-
# ---------------------------------------------------------------------------
|
|
41
|
-
SCROLL_DURATION_MS = 300
|
|
42
|
-
HDC_SWIPE_SPEED = 600 # pixels/second for hdc uitest uiInput swipe
|
|
43
|
-
IDLE_POLL_INTERVAL = 0.2
|
|
44
|
-
IDLE_TIMEOUT = 5
|
|
45
|
-
|
|
46
|
-
SKIP_RESOURCE_ID_PATTERNS = [
|
|
47
|
-
"statusBarBackground",
|
|
48
|
-
"navigationBarBackground",
|
|
49
|
-
"action_bar_container",
|
|
50
|
-
"status_bar",
|
|
51
|
-
"navigation_bar",
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
# HarmonyOS: skip system UI node types / bundles
|
|
55
|
-
HMOS_SKIP_TYPES = {"WindowScene", "__Common__", "EffectComponent", "metaballNode"}
|
|
56
|
-
HMOS_SKIP_BUNDLES = {"com.huawei.systemui", "com.ohos.systemui", "com.huawei.android.launcher"}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
# ---------------------------------------------------------------------------
|
|
60
|
-
# ADB helpers
|
|
61
|
-
# ---------------------------------------------------------------------------
|
|
62
|
-
def adb(*args, serial=None, timeout=15) -> str:
|
|
63
|
-
cmd = ["adb"]
|
|
64
|
-
if serial:
|
|
65
|
-
cmd += ["-s", serial]
|
|
66
|
-
cmd += list(args)
|
|
67
|
-
try:
|
|
68
|
-
result = subprocess.run(cmd, capture_output=True, timeout=timeout,
|
|
69
|
-
encoding="utf-8", errors="replace")
|
|
70
|
-
return (result.stdout or "").strip()
|
|
71
|
-
except subprocess.TimeoutExpired:
|
|
72
|
-
print(f" [WARN] adb timeout: {' '.join(args)}")
|
|
73
|
-
return ""
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def adb_shell(*args, serial=None, timeout=15) -> str:
|
|
77
|
-
return adb("shell", *args, serial=serial, timeout=timeout)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def adb_wait_idle(serial=None):
|
|
81
|
-
deadline = time.time() + IDLE_TIMEOUT
|
|
82
|
-
prev_focus = None
|
|
83
|
-
interval = IDLE_POLL_INTERVAL
|
|
84
|
-
while time.time() < deadline:
|
|
85
|
-
time.sleep(interval)
|
|
86
|
-
interval = min(interval * 1.5, 0.5)
|
|
87
|
-
focus_out = adb_shell("dumpsys", "window", serial=serial)
|
|
88
|
-
current_focus = ""
|
|
89
|
-
for line in focus_out.splitlines():
|
|
90
|
-
if "mCurrentFocus" in line:
|
|
91
|
-
current_focus = line.strip()
|
|
92
|
-
break
|
|
93
|
-
if current_focus and current_focus == prev_focus:
|
|
94
|
-
return
|
|
95
|
-
prev_focus = current_focus
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
# ---------------------------------------------------------------------------
|
|
99
|
-
# HDC helpers
|
|
100
|
-
# ---------------------------------------------------------------------------
|
|
101
|
-
def hdc(*args, timeout=15) -> str:
|
|
102
|
-
cmd = ["hdc"] + list(args)
|
|
103
|
-
try:
|
|
104
|
-
result = subprocess.run(cmd, shell=True, capture_output=True,
|
|
105
|
-
text=True, timeout=timeout)
|
|
106
|
-
if result.returncode != 0 and result.stderr.strip():
|
|
107
|
-
print(f" [WARN] hdc stderr: {result.stderr.strip()}")
|
|
108
|
-
return (result.stdout or "").strip()
|
|
109
|
-
except subprocess.TimeoutExpired:
|
|
110
|
-
print(f" [WARN] hdc timeout: {' '.join(args)}")
|
|
111
|
-
return ""
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def hdc_shell(*args, timeout=15) -> str:
|
|
115
|
-
return hdc("shell", *args, timeout=timeout)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def hdc_wait_idle():
|
|
119
|
-
time.sleep(1)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
# ---------------------------------------------------------------------------
|
|
123
|
-
# XML utilities (shared)
|
|
124
|
-
# ---------------------------------------------------------------------------
|
|
125
|
-
def find_scrollable_containers(xml_content: str) -> list[dict]:
|
|
126
|
-
containers = []
|
|
127
|
-
if not xml_content:
|
|
128
|
-
return containers
|
|
129
|
-
try:
|
|
130
|
-
root = ET.fromstring(xml_content)
|
|
131
|
-
except ET.ParseError:
|
|
132
|
-
return containers
|
|
133
|
-
for node in root.iter("node"):
|
|
134
|
-
if node.get("scrollable") != "true":
|
|
135
|
-
continue
|
|
136
|
-
cls = node.get("class", "")
|
|
137
|
-
if cls in {"android.widget.HorizontalScrollView", "HorizontalScrollView"}:
|
|
138
|
-
continue
|
|
139
|
-
bounds_str = node.get("bounds", "")
|
|
140
|
-
m = re.findall(r"\d+", bounds_str)
|
|
141
|
-
if len(m) != 4:
|
|
142
|
-
continue
|
|
143
|
-
x1, y1, x2, y2 = map(int, m)
|
|
144
|
-
if y2 - y1 < 200:
|
|
145
|
-
continue
|
|
146
|
-
containers.append({
|
|
147
|
-
"bounds": (x1, y1, x2, y2),
|
|
148
|
-
"class": cls,
|
|
149
|
-
"resource-id": node.get("resource-id", ""),
|
|
150
|
-
})
|
|
151
|
-
containers.sort(
|
|
152
|
-
key=lambda c: (c["bounds"][2] - c["bounds"][0]) * (c["bounds"][3] - c["bounds"][1]),
|
|
153
|
-
reverse=True,
|
|
154
|
-
)
|
|
155
|
-
return containers
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
def _extract_node_keys(xml_content: str) -> set[tuple]:
|
|
159
|
-
keys = set()
|
|
160
|
-
if not xml_content:
|
|
161
|
-
return keys
|
|
162
|
-
try:
|
|
163
|
-
root = ET.fromstring(xml_content)
|
|
164
|
-
except ET.ParseError:
|
|
165
|
-
return keys
|
|
166
|
-
for node in root.iter("node"):
|
|
167
|
-
keys.add((
|
|
168
|
-
node.get("class", ""),
|
|
169
|
-
node.get("resource-id", ""),
|
|
170
|
-
node.get("text", ""),
|
|
171
|
-
node.get("content-desc", ""),
|
|
172
|
-
node.get("bounds", ""),
|
|
173
|
-
))
|
|
174
|
-
return keys
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def parse_bounds_center(bounds: str):
|
|
178
|
-
m = re.findall(r"\d+", bounds)
|
|
179
|
-
if len(m) == 4:
|
|
180
|
-
x1, y1, x2, y2 = map(int, m)
|
|
181
|
-
return ((x1 + x2) // 2, (y1 + y2) // 2)
|
|
182
|
-
return None
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
def get_clickable_elements(xml_content: str) -> list[dict]:
|
|
186
|
-
elements = []
|
|
187
|
-
if not xml_content:
|
|
188
|
-
return elements
|
|
189
|
-
try:
|
|
190
|
-
root = ET.fromstring(xml_content)
|
|
191
|
-
|
|
192
|
-
listview_child_set = set()
|
|
193
|
-
for node in root.iter("node"):
|
|
194
|
-
cls = node.get("class", "")
|
|
195
|
-
if "ListView" in cls or "GridView" in cls or "List" == cls:
|
|
196
|
-
for child in node:
|
|
197
|
-
listview_child_set.add(child)
|
|
198
|
-
|
|
199
|
-
def extract_text(node):
|
|
200
|
-
text = node.get("text", "")
|
|
201
|
-
if text:
|
|
202
|
-
return text
|
|
203
|
-
for child in node.iter("node"):
|
|
204
|
-
t = child.get("text", "")
|
|
205
|
-
if t:
|
|
206
|
-
return t
|
|
207
|
-
return ""
|
|
208
|
-
|
|
209
|
-
for node in root.iter("node"):
|
|
210
|
-
if node.get("enabled") != "true":
|
|
211
|
-
continue
|
|
212
|
-
is_clickable = node.get("clickable") == "true"
|
|
213
|
-
is_long_clickable = node.get("long-clickable") == "true"
|
|
214
|
-
is_listview_item = node in listview_child_set
|
|
215
|
-
is_checkable = node.get("checkable") == "true"
|
|
216
|
-
if not (is_clickable or is_long_clickable or is_listview_item or is_checkable):
|
|
217
|
-
continue
|
|
218
|
-
bounds = node.get("bounds", "")
|
|
219
|
-
text = node.get("text", "")
|
|
220
|
-
if not text:
|
|
221
|
-
text = extract_text(node)
|
|
222
|
-
base_info = {
|
|
223
|
-
"class": node.get("class", ""),
|
|
224
|
-
"text": text,
|
|
225
|
-
"resource-id": node.get("resource-id", ""),
|
|
226
|
-
"content-desc": node.get("content-desc", ""),
|
|
227
|
-
"bounds": bounds,
|
|
228
|
-
"center": parse_bounds_center(bounds),
|
|
229
|
-
}
|
|
230
|
-
if is_clickable or is_listview_item or is_checkable:
|
|
231
|
-
elements.append({**base_info, "long-clickable": False})
|
|
232
|
-
if is_long_clickable:
|
|
233
|
-
elements.append({**base_info, "long-clickable": True})
|
|
234
|
-
except ET.ParseError as e:
|
|
235
|
-
print(f" [WARN] XML parse error: {e}")
|
|
236
|
-
return elements
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
# ---------------------------------------------------------------------------
|
|
240
|
-
# HarmonyOS: JSON → XML conversion
|
|
241
|
-
# ---------------------------------------------------------------------------
|
|
242
|
-
def hmos_to_xml(node, parent=None):
|
|
243
|
-
attrs = node.get("attributes", {})
|
|
244
|
-
t = attrs.get("type", "")
|
|
245
|
-
bundle = attrs.get("bundleName", "")
|
|
246
|
-
if t in HMOS_SKIP_TYPES:
|
|
247
|
-
return None
|
|
248
|
-
if bundle in HMOS_SKIP_BUNDLES:
|
|
249
|
-
return None
|
|
250
|
-
xml_attrs = {
|
|
251
|
-
"class": t,
|
|
252
|
-
"resource-id": attrs.get("key", ""),
|
|
253
|
-
"text": attrs.get("text", ""),
|
|
254
|
-
"content-desc": attrs.get("description", ""),
|
|
255
|
-
"clickable": attrs.get("clickable", "false"),
|
|
256
|
-
"long-clickable": attrs.get("longClickable", "false"),
|
|
257
|
-
"scrollable": attrs.get("scrollable", "false"),
|
|
258
|
-
"enabled": attrs.get("enabled", "true"),
|
|
259
|
-
"focused": attrs.get("focused", "false"),
|
|
260
|
-
"bounds": attrs.get("bounds", ""),
|
|
261
|
-
"package": bundle,
|
|
262
|
-
}
|
|
263
|
-
el = ET.SubElement(parent, "node", xml_attrs) if parent is not None \
|
|
264
|
-
else ET.Element("node", xml_attrs)
|
|
265
|
-
for child in node.get("children", []):
|
|
266
|
-
hmos_to_xml(child, el)
|
|
267
|
-
return el
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
# ---------------------------------------------------------------------------
|
|
271
|
-
# Android capture
|
|
272
|
-
# ---------------------------------------------------------------------------
|
|
273
|
-
def _adb_dump_xml(output_dir: Path, serial=None) -> str:
|
|
274
|
-
remote_path = "/sdcard/ui_dump.xml"
|
|
275
|
-
adb_shell("rm -f /sdcard/ui_dump.xml && uiautomator dump /sdcard/ui_dump.xml",
|
|
276
|
-
serial=serial, timeout=20)
|
|
277
|
-
for _ in range(6):
|
|
278
|
-
check = adb_shell("ls", remote_path, serial=serial)
|
|
279
|
-
if remote_path in check:
|
|
280
|
-
break
|
|
281
|
-
time.sleep(0.2)
|
|
282
|
-
xml_content = adb_shell("cat", remote_path, serial=serial, timeout=15)
|
|
283
|
-
if xml_content:
|
|
284
|
-
(output_dir / "view.xml").write_text(xml_content, encoding="utf-8")
|
|
285
|
-
return xml_content
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
def _adb_dump_xml_quick(serial=None) -> str:
|
|
289
|
-
remote_path = "/sdcard/ui_dump.xml"
|
|
290
|
-
adb_shell("rm -f /sdcard/ui_dump.xml && uiautomator dump /sdcard/ui_dump.xml",
|
|
291
|
-
serial=serial, timeout=20)
|
|
292
|
-
for _ in range(6):
|
|
293
|
-
check = adb_shell("ls", remote_path, serial=serial)
|
|
294
|
-
if remote_path in check:
|
|
295
|
-
break
|
|
296
|
-
time.sleep(0.2)
|
|
297
|
-
return adb_shell("cat", remote_path, serial=serial, timeout=15)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
def _adb_screenshot(output_dir: Path, filename="screenshot.png", serial=None):
|
|
301
|
-
local_path = output_dir / filename
|
|
302
|
-
cmd = ["adb"]
|
|
303
|
-
if serial:
|
|
304
|
-
cmd += ["-s", serial]
|
|
305
|
-
cmd += ["exec-out", "screencap", "-p"]
|
|
306
|
-
try:
|
|
307
|
-
result = subprocess.run(cmd, capture_output=True, timeout=15)
|
|
308
|
-
if result.stdout:
|
|
309
|
-
local_path.write_bytes(result.stdout)
|
|
310
|
-
except subprocess.TimeoutExpired:
|
|
311
|
-
print(f" [WARN] screenshot timeout")
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
def _adb_get_activity(serial=None) -> dict:
|
|
315
|
-
info = {}
|
|
316
|
-
act_out = adb_shell("dumpsys", "activity", "activities", serial=serial)
|
|
317
|
-
win_out = adb_shell("dumpsys", "window", serial=serial)
|
|
318
|
-
for line in act_out.splitlines():
|
|
319
|
-
if re.search(r"ResumedActivity|topActivity", line, re.IGNORECASE):
|
|
320
|
-
info["resumed_activity"] = line.strip()
|
|
321
|
-
break
|
|
322
|
-
for line in win_out.splitlines():
|
|
323
|
-
if "mCurrentFocus" in line:
|
|
324
|
-
info["current_focus"] = line.strip()
|
|
325
|
-
break
|
|
326
|
-
if "mFocusedApp" in line:
|
|
327
|
-
info.setdefault("focused_app", line.strip())
|
|
328
|
-
return info
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
def _adb_scroll_and_capture(output_dir: Path, container_bounds, max_scrolls, initial_xml, serial=None):
|
|
332
|
-
x1, y1, x2, y2 = container_bounds
|
|
333
|
-
cx = (x1 + x2) // 2
|
|
334
|
-
height = y2 - y1
|
|
335
|
-
swipe_from_y = y1 + int(height * 0.7)
|
|
336
|
-
swipe_to_y = y1 + int(height * 0.3)
|
|
337
|
-
|
|
338
|
-
xml_list = []
|
|
339
|
-
prev_keys = _extract_node_keys(initial_xml) if initial_xml else None
|
|
340
|
-
scroll_count = 0
|
|
341
|
-
|
|
342
|
-
for i in range(max_scrolls):
|
|
343
|
-
adb_shell("input", "swipe",
|
|
344
|
-
str(cx), str(swipe_from_y), str(cx), str(swipe_to_y),
|
|
345
|
-
str(SCROLL_DURATION_MS), serial=serial)
|
|
346
|
-
adb_wait_idle(serial)
|
|
347
|
-
|
|
348
|
-
new_xml = _adb_dump_xml_quick(serial=serial)
|
|
349
|
-
new_keys = _extract_node_keys(new_xml)
|
|
350
|
-
|
|
351
|
-
if prev_keys is not None and new_keys == prev_keys:
|
|
352
|
-
print(f" Reached bottom after {i + 1} scroll(s)")
|
|
353
|
-
break
|
|
354
|
-
prev_keys = new_keys
|
|
355
|
-
scroll_count += 1
|
|
356
|
-
xml_list.append(new_xml)
|
|
357
|
-
|
|
358
|
-
xml_path = output_dir / f"view_scroll_{i + 1}.xml"
|
|
359
|
-
xml_path.write_text(new_xml, encoding="utf-8")
|
|
360
|
-
|
|
361
|
-
_adb_screenshot(output_dir, f"screenshot_scroll_{i + 1}.png", serial=serial)
|
|
362
|
-
print(f" Scroll {i + 1}: XML + screenshot saved")
|
|
363
|
-
|
|
364
|
-
if scroll_count > 0:
|
|
365
|
-
print(f" Restoring initial position: scrolling back {scroll_count} time(s)...")
|
|
366
|
-
for i in range(scroll_count):
|
|
367
|
-
adb_shell("input", "swipe",
|
|
368
|
-
str(cx), str(swipe_to_y), str(cx), str(swipe_from_y),
|
|
369
|
-
str(SCROLL_DURATION_MS), serial=serial)
|
|
370
|
-
adb_wait_idle(serial)
|
|
371
|
-
|
|
372
|
-
return xml_list
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
def capture_android(output_dir: Path, serial=None, max_scrolls=10):
|
|
376
|
-
output_dir.mkdir(parents=True, exist_ok=True)
|
|
377
|
-
print("[1/4] Dumping view XML...")
|
|
378
|
-
xml_content = _adb_dump_xml(output_dir, serial=serial)
|
|
379
|
-
if not xml_content:
|
|
380
|
-
print("[ERR] Failed to dump XML")
|
|
381
|
-
return
|
|
382
|
-
|
|
383
|
-
print("[2/4] Taking screenshot...")
|
|
384
|
-
_adb_screenshot(output_dir, serial=serial)
|
|
385
|
-
|
|
386
|
-
print("[3/4] Checking scrollable containers...")
|
|
387
|
-
containers = find_scrollable_containers(xml_content)
|
|
388
|
-
all_xml_contents = [xml_content]
|
|
389
|
-
if containers:
|
|
390
|
-
container = containers[0]
|
|
391
|
-
print(f" Found scrollable: {container['class']} {container.get('resource-id', '')}")
|
|
392
|
-
scroll_xmls = _adb_scroll_and_capture(
|
|
393
|
-
output_dir, container["bounds"], max_scrolls, xml_content, serial=serial,
|
|
394
|
-
)
|
|
395
|
-
all_xml_contents.extend(scroll_xmls)
|
|
396
|
-
print(f" Scroll capture done: {len(scroll_xmls)} scroll(s)")
|
|
397
|
-
else:
|
|
398
|
-
print(" No scrollable container found")
|
|
399
|
-
|
|
400
|
-
print("[4/4] Building meta.json...")
|
|
401
|
-
activity_info = _adb_get_activity(serial=serial)
|
|
402
|
-
|
|
403
|
-
seen_clickable = set()
|
|
404
|
-
clickable = []
|
|
405
|
-
for idx, xc in enumerate(all_xml_contents):
|
|
406
|
-
for elem in get_clickable_elements(xc):
|
|
407
|
-
key = (
|
|
408
|
-
elem.get("resource-id", ""),
|
|
409
|
-
elem.get("text", ""),
|
|
410
|
-
elem.get("content-desc", ""),
|
|
411
|
-
elem.get("class", ""),
|
|
412
|
-
elem.get("bounds", ""),
|
|
413
|
-
elem.get("long-clickable", False),
|
|
414
|
-
)
|
|
415
|
-
if key not in seen_clickable:
|
|
416
|
-
seen_clickable.add(key)
|
|
417
|
-
elem["scroll_index"] = idx
|
|
418
|
-
clickable.append(elem)
|
|
419
|
-
|
|
420
|
-
meta = {
|
|
421
|
-
"timestamp": datetime.now().isoformat(),
|
|
422
|
-
"device": "adb",
|
|
423
|
-
"activity_info": activity_info,
|
|
424
|
-
"clickable_count": len(clickable),
|
|
425
|
-
"clickable_elements": clickable,
|
|
426
|
-
}
|
|
427
|
-
(output_dir / "meta.json").write_text(
|
|
428
|
-
json.dumps(meta, ensure_ascii=False, indent=2), encoding="utf-8",
|
|
429
|
-
)
|
|
430
|
-
|
|
431
|
-
print(f"\nDone! Files saved to {output_dir}")
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
# ---------------------------------------------------------------------------
|
|
435
|
-
# HarmonyOS capture
|
|
436
|
-
# ---------------------------------------------------------------------------
|
|
437
|
-
def _hdc_dump_layout(output_dir: Path) -> tuple[str, str]:
|
|
438
|
-
"""Dump layout JSON, convert to XML. Returns (xml_string, page_name)."""
|
|
439
|
-
out = hdc_shell("uitest dumpLayout")
|
|
440
|
-
match = re.search(r"saved to:(.+\.json)", out)
|
|
441
|
-
if not match:
|
|
442
|
-
raise RuntimeError(f"Cannot parse dumpLayout output: {out}")
|
|
443
|
-
remote_json = match.group(1).strip()
|
|
444
|
-
|
|
445
|
-
local_json = str(output_dir / "_tmp_layout.json")
|
|
446
|
-
hdc("file", "recv", remote_json, local_json)
|
|
447
|
-
|
|
448
|
-
with open(local_json, "r", encoding="utf-8") as f:
|
|
449
|
-
data = json.load(f)
|
|
450
|
-
|
|
451
|
-
page_name = ""
|
|
452
|
-
if data.get("children"):
|
|
453
|
-
page_name = data["children"][0].get("attributes", {}).get("pagePath", "")
|
|
454
|
-
page_name = page_name.split("/")[-1] if page_name else "unknown"
|
|
455
|
-
|
|
456
|
-
root_el = hmos_to_xml(data)
|
|
457
|
-
tree = ET.ElementTree(root_el)
|
|
458
|
-
ET.indent(tree, space=" ")
|
|
459
|
-
|
|
460
|
-
xml_path = output_dir / "view.xml"
|
|
461
|
-
tree.write(str(xml_path), encoding="unicode", xml_declaration=True)
|
|
462
|
-
|
|
463
|
-
xml_str = ET.tostring(root_el, encoding="unicode")
|
|
464
|
-
|
|
465
|
-
os.remove(local_json)
|
|
466
|
-
return xml_str, page_name
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
def _hdc_dump_layout_quick(output_dir: Path) -> str:
|
|
470
|
-
"""Dump layout and return XML string without saving to view.xml."""
|
|
471
|
-
out = hdc_shell("uitest dumpLayout")
|
|
472
|
-
match = re.search(r"saved to:(.+\.json)", out)
|
|
473
|
-
if not match:
|
|
474
|
-
return ""
|
|
475
|
-
remote_json = match.group(1).strip()
|
|
476
|
-
|
|
477
|
-
local_json = str(output_dir / "_tmp_layout.json")
|
|
478
|
-
hdc("file", "recv", remote_json, local_json)
|
|
479
|
-
|
|
480
|
-
try:
|
|
481
|
-
with open(local_json, "r", encoding="utf-8") as f:
|
|
482
|
-
data = json.load(f)
|
|
483
|
-
root_el = hmos_to_xml(data)
|
|
484
|
-
xml_str = ET.tostring(root_el, encoding="unicode") if root_el else ""
|
|
485
|
-
finally:
|
|
486
|
-
if os.path.exists(local_json):
|
|
487
|
-
os.remove(local_json)
|
|
488
|
-
return xml_str
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
def _hdc_screenshot(output_dir: Path, filename="screenshot.jpeg"):
|
|
492
|
-
remote_img = "/data/local/tmp/screenshot.jpeg"
|
|
493
|
-
hdc_shell(f"snapshot_display -f {remote_img}")
|
|
494
|
-
local_path = output_dir / filename
|
|
495
|
-
hdc("file", "recv", remote_img, str(local_path))
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
def _hdc_scroll_and_capture(output_dir: Path, container_bounds, max_scrolls, initial_xml):
|
|
499
|
-
x1, y1, x2, y2 = container_bounds
|
|
500
|
-
cx = (x1 + x2) // 2
|
|
501
|
-
height = y2 - y1
|
|
502
|
-
swipe_from_y = y1 + int(height * 0.7)
|
|
503
|
-
swipe_to_y = y1 + int(height * 0.3)
|
|
504
|
-
|
|
505
|
-
xml_list = []
|
|
506
|
-
prev_keys = _extract_node_keys(initial_xml) if initial_xml else None
|
|
507
|
-
scroll_count = 0
|
|
508
|
-
|
|
509
|
-
for i in range(max_scrolls):
|
|
510
|
-
hdc_shell(
|
|
511
|
-
"uitest", "uiInput", "swipe",
|
|
512
|
-
str(cx), str(swipe_from_y), str(cx), str(swipe_to_y),
|
|
513
|
-
str(HDC_SWIPE_SPEED),
|
|
514
|
-
)
|
|
515
|
-
hdc_wait_idle()
|
|
516
|
-
|
|
517
|
-
new_xml = _hdc_dump_layout_quick(output_dir)
|
|
518
|
-
new_keys = _extract_node_keys(new_xml)
|
|
519
|
-
|
|
520
|
-
if prev_keys is not None and new_keys == prev_keys:
|
|
521
|
-
print(f" Reached bottom after {i + 1} scroll(s)")
|
|
522
|
-
break
|
|
523
|
-
prev_keys = new_keys
|
|
524
|
-
scroll_count += 1
|
|
525
|
-
xml_list.append(new_xml)
|
|
526
|
-
|
|
527
|
-
xml_path = output_dir / f"view_scroll_{i + 1}.xml"
|
|
528
|
-
xml_path.write_text(new_xml, encoding="utf-8")
|
|
529
|
-
|
|
530
|
-
_hdc_screenshot(output_dir, f"screenshot_scroll_{i + 1}.jpeg")
|
|
531
|
-
print(f" Scroll {i + 1}: XML + screenshot saved")
|
|
532
|
-
|
|
533
|
-
if scroll_count > 0:
|
|
534
|
-
print(f" Restoring initial position: scrolling back {scroll_count} time(s)...")
|
|
535
|
-
for i in range(scroll_count):
|
|
536
|
-
hdc_shell(
|
|
537
|
-
"uitest", "uiInput", "swipe",
|
|
538
|
-
str(cx), str(swipe_to_y), str(cx), str(swipe_from_y),
|
|
539
|
-
str(HDC_SWIPE_SPEED),
|
|
540
|
-
)
|
|
541
|
-
hdc_wait_idle()
|
|
542
|
-
|
|
543
|
-
return xml_list
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
def capture_hdc(output_dir: Path, max_scrolls=10):
|
|
547
|
-
output_dir.mkdir(parents=True, exist_ok=True)
|
|
548
|
-
print("[1/3] Dumping layout (JSON -> XML)...")
|
|
549
|
-
xml_content, page_name = _hdc_dump_layout(output_dir)
|
|
550
|
-
if not xml_content:
|
|
551
|
-
print("[ERR] Failed to dump layout")
|
|
552
|
-
return
|
|
553
|
-
print(f" Page: {page_name}")
|
|
554
|
-
|
|
555
|
-
print("[2/3] Taking screenshot...")
|
|
556
|
-
_hdc_screenshot(output_dir)
|
|
557
|
-
|
|
558
|
-
print("[3/3] Checking scrollable containers...")
|
|
559
|
-
containers = find_scrollable_containers(xml_content)
|
|
560
|
-
if containers:
|
|
561
|
-
container = containers[0]
|
|
562
|
-
print(f" Found scrollable: {container['class']} {container.get('resource-id', '')}")
|
|
563
|
-
scroll_xmls = _hdc_scroll_and_capture(
|
|
564
|
-
output_dir, container["bounds"], max_scrolls, xml_content,
|
|
565
|
-
)
|
|
566
|
-
print(f" Scroll capture done: {len(scroll_xmls)} scroll(s)")
|
|
567
|
-
else:
|
|
568
|
-
print(" No scrollable container found")
|
|
569
|
-
|
|
570
|
-
print(f"\nDone! Files saved to {output_dir}")
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
# ---------------------------------------------------------------------------
|
|
574
|
-
# CLI
|
|
575
|
-
# ---------------------------------------------------------------------------
|
|
576
|
-
def main():
|
|
577
|
-
parser = argparse.ArgumentParser(description="Capture current page: view tree XML + screenshots (Android / HarmonyOS)")
|
|
578
|
-
parser.add_argument("--device", choices=["hdc", "adb"], default="hdc",
|
|
579
|
-
help="Device type: hdc=HarmonyOS, adb=Android (default: hdc)")
|
|
580
|
-
parser.add_argument("--output-dir", "-o", type=str, required=True,
|
|
581
|
-
help="Output directory for captured files")
|
|
582
|
-
parser.add_argument("--max-scrolls", type=int, default=10,
|
|
583
|
-
help="Max scroll count per container (default: 10)")
|
|
584
|
-
parser.add_argument("--serial", type=str, default=None,
|
|
585
|
-
help="ADB device serial (optional, for multi-device)")
|
|
586
|
-
args = parser.parse_args()
|
|
587
|
-
|
|
588
|
-
output_dir = Path(args.output_dir)
|
|
589
|
-
|
|
590
|
-
if args.device == "adb":
|
|
591
|
-
capture_android(output_dir, serial=args.serial, max_scrolls=args.max_scrolls)
|
|
592
|
-
else:
|
|
593
|
-
capture_hdc(output_dir, max_scrolls=args.max_scrolls)
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
if __name__ == "__main__":
|
|
597
|
-
sys.exit(main())
|