@buaa_smat/hometrans 0.1.0 → 0.1.2
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 +141 -124
- package/agents/build-fixer.md +1 -0
- package/agents/code-review-fix.md +1 -0
- package/agents/code-reviewer.md +1 -0
- package/agents/logic-coding.md +1 -0
- package/agents/logic-context-builder.md +1 -0
- package/agents/review-fixer.md +1 -0
- package/agents/self-test-fixer.md +1 -0
- package/agents/self-tester.md +260 -233
- package/agents/spec-generator.md +1 -0
- package/agents/test-tools/autotest/README.md +223 -0
- package/agents/test-tools/autotest/config.yaml.example +58 -0
- package/agents/test-tools/autotest/pyproject.toml +16 -0
- package/agents/test-tools/autotest/report_tool.py +759 -0
- package/agents/test-tools/autotest/self_test_runner.py +773 -0
- package/agents/test-tools/autotest/testcases_schema.md +143 -0
- package/agents/test-tools/autotest/testcases_tool.py +215 -0
- package/agents/test-tools/autotest/uv.lock +3156 -0
- package/agents/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
- package/agents/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
- package/agents/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
- package/agents/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
- package/agents/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
- package/agents/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
- package/dist/cli/config-store.js +27 -2
- package/dist/cli/config.js +17 -6
- package/dist/cli/index.js +3 -2
- package/dist/cli/init.js +135 -22
- package/dist/cli/mcp.js +2 -2
- package/dist/context/index.js +165 -69
- package/package.json +59 -60
- package/skills/code-dev-review-fix/SKILL.md +279 -0
- package/skills/code-dev-review-fix-workspace/evals/evals.json +56 -0
- package/skills/code-dev-review-fix-workspace/iteration-1/routing-results.md +23 -0
- package/skills/convert_pipeline/SKILL.md +423 -439
- package/skills/hmos-resources-convert/SKILL.md +623 -0
- package/skills/hmos-resources-convert/evals/evals.json +171 -0
- package/skills/hmos-resources-convert/references/conversion-rules.md +663 -0
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -0
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -0
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -0
- package/skills/hmos-resources-convert/template/AppScope/app.json5 +10 -0
- package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +8 -0
- 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 +7 -0
- package/skills/hmos-resources-convert/template/build-profile.json5 +42 -0
- package/skills/hmos-resources-convert/template/code-linter.json5 +32 -0
- package/skills/hmos-resources-convert/template/entry/build-profile.json5 +33 -0
- package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +6 -0
- package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +23 -0
- package/skills/hmos-resources-convert/template/entry/oh-package.json5 +10 -0
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
- package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
- package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +23 -0
- package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +55 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +8 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +8 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +16 -0
- 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 +7 -0
- 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 +3 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +8 -0
- package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +2 -0
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +5 -0
- package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +16 -0
- package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +5 -0
- package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +33 -0
- package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +23 -0
- package/skills/hmos-resources-convert/template/hvigorfile.ts +6 -0
- package/skills/hmos-resources-convert/template/oh-package-lock.json5 +28 -0
- package/skills/hmos-resources-convert/template/oh-package.json5 +10 -0
- package/skills/hmos-resources-convert/tools/apktool.bat +85 -0
- package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
- package/skills/hmos-ui-align/SKILL.md +182 -0
- package/skills/hmos-ui-align/config-example.json +11 -0
- package/skills/hmos-ui-align/config.json +11 -0
- package/skills/hmos-ui-align/diff_analysis.md +53 -0
- package/skills/hmos-ui-align/page_align.md +62 -0
- package/skills/hmos-ui-align/readme.md +231 -0
- package/skills/hmos-ui-align/references/Comparison_Template.md +2 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 +2089 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 +903 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-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 -0
- package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
- package/skills/hmos-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 +355 -0
- package/skills/hmos-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 -0
- package/skills/hmos-ui-align/references/UI_Analysis_Template.md +4 -0
- package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -0
- package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -0
- package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -0
- package/skills/hmos-ui-align/scripts/app_feature_verify.py +443 -0
- package/skills/hmos-ui-align/scripts/navigation-capure.md +37 -0
- package/skills/hmos-ui-align/scripts/page_capture.py +592 -0
- package/skills/hmos-ui-align-batch/SKILL.md +99 -0
- package/skills/hmos-ui-align-batch/references/conversion-procedure.md +180 -0
- package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -0
- package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -0
- package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 +2089 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 +903 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
- package/skills/hmos-ui-align-batch/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 +355 -0
- package/skills/hmos-ui-align-batch/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 -0
- package/skills/hmos-ui-align-batch/scripts/android_parse_fast.py +1606 -0
- package/skills/self-test/SKILL.md +369 -0
- package/skills/self-test/readme.md +309 -0
- package/skills/spec-generator-skill/SKILL.md +332 -0
- package/skills/spec-generator-skill/references/android-platform-tokens.md +105 -0
- package/skills/spec-generator-skill/references/spec-sample-1.md +78 -0
- package/skills/spec-generator-skill/references/spec-sample-2.md +58 -0
- package/skills/spec-generator-skill/references/spec-sample-3.md +116 -0
- package/skills/spec-generator-skill/references/step4-report-template.md +33 -0
- package/agents/self-test-setup.md +0 -165
- package/dist/context/resources/sdkConfig.json +0 -24
- package/src/context/resources/sdkConfig.json +0 -24
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
# Android Resource Dependency Analysis Rules
|
|
2
|
+
|
|
3
|
+
This document defines how to extract, track, and resolve inter-resource dependencies during Android-to-HarmonyOS resource conversion. Dependency analysis runs regardless of resource source — whether from a decompiled APK (complete resource set) or from the project's source `res/` directory (potentially missing library resources). When working from source `res/`, more references will be unresolvable, but the analysis is still essential to identify exactly what's missing and why. It also provides the evidence used to infer screen ownership, source ownership, and review-oriented function descriptions for the markdown written to `resource_mapping_path`.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
1. [Resource Reference Patterns](#resource-reference-patterns)
|
|
7
|
+
2. [Building the Resource Value Lookup Table](#building-the-resource-value-lookup-table)
|
|
8
|
+
3. [Resolving References to True Values](#resolving-references-to-true-values)
|
|
9
|
+
4. [Where to Scan for Dependencies](#where-to-scan-for-dependencies)
|
|
10
|
+
5. [Dependency Verification](#dependency-verification)
|
|
11
|
+
6. [Handling Missing Library Resources](#handling-missing-library-resources)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Resource Reference Patterns
|
|
16
|
+
|
|
17
|
+
Android resources reference each other using `@type/name` syntax. Extract these references from XML attribute values and text content.
|
|
18
|
+
|
|
19
|
+
### Reference Regex Pattern
|
|
20
|
+
|
|
21
|
+
Use the following pattern to extract resource references from any XML content:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
@(color|drawable|mipmap|string|dimen|integer|bool|array|style|attr|id|layout|menu|anim|animator|raw|font|xml|plurals)/([a-zA-Z_][a-zA-Z0-9_]*)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This captures:
|
|
28
|
+
- Group 1: resource type (`color`, `drawable`, etc.)
|
|
29
|
+
- Group 2: resource name
|
|
30
|
+
|
|
31
|
+
### System Resource References
|
|
32
|
+
|
|
33
|
+
References prefixed with `@android:` (e.g., `@android:color/black`, `@android:drawable/ic_menu_close`) are Android framework resources provided by the OS. These resources do NOT exist in HarmonyOS and MUST be resolved to concrete values during conversion — they cannot be left as-is in the output.
|
|
34
|
+
|
|
35
|
+
**Resolution rules for system resources:**
|
|
36
|
+
- `@android:color/*` — resolve using the built-in Android system color lookup table (defined in SKILL.md Step 5.2). NEVER leave `@android:color/*` references in the converted output. If a color is not in the lookup table, use the decompiled APK's framework resources or fall back to `#ff000000` with a warning.
|
|
37
|
+
- `@android:dimen/*` — resolve using the built-in Android system dimension lookup table (defined in SKILL.md Step 5.2). Fall back to `0vp` with a warning if not found.
|
|
38
|
+
- `@android:string/*` — resolve to the known English string value if available, otherwise use `""` with a warning.
|
|
39
|
+
- `@android:integer/*` — resolve to the known value if available, otherwise use `0` with a warning.
|
|
40
|
+
- `@android:drawable/*` — these are Android framework drawables (icons, backgrounds). Log as "system drawable — requires manual replacement" in the report. If converting from a decompiled APK, extract and convert the drawable. Otherwise, create a placeholder SVG.
|
|
41
|
+
|
|
42
|
+
In the conversion report, list all resolved system resource references in a dedicated section so the developer can verify the resolved values are correct.
|
|
43
|
+
|
|
44
|
+
### Theme Attribute References
|
|
45
|
+
|
|
46
|
+
References using `?attr/name` or `?android:attr/name` are theme attribute references resolved at runtime. These **cannot** be statically resolved — they depend on which theme is applied at runtime. Log them as "unresolvable theme attribute" and keep the reference as-is in the converted output.
|
|
47
|
+
|
|
48
|
+
### Reference Locations in XML
|
|
49
|
+
|
|
50
|
+
Resource references can appear in several places within Android XML files:
|
|
51
|
+
|
|
52
|
+
**1. XML attribute values:**
|
|
53
|
+
```xml
|
|
54
|
+
<background android:drawable="@color/md_amber_700" />
|
|
55
|
+
<TextView android:text="@string/hello" android:textColor="@color/primary" />
|
|
56
|
+
<ImageView android:src="@drawable/icon" />
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**2. Style/theme item values:**
|
|
60
|
+
```xml
|
|
61
|
+
<style name="AppTheme">
|
|
62
|
+
<item name="colorPrimary">@color/primary</item>
|
|
63
|
+
<item name="android:windowBackground">@drawable/bg_window</item>
|
|
64
|
+
</style>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**3. Color state list references:**
|
|
68
|
+
```xml
|
|
69
|
+
<selector>
|
|
70
|
+
<item android:color="@color/pressed_color" android:state_pressed="true" />
|
|
71
|
+
<item android:color="@color/default_color" />
|
|
72
|
+
</selector>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**4. Drawable XML references:**
|
|
76
|
+
```xml
|
|
77
|
+
<layer-list>
|
|
78
|
+
<item android:drawable="@drawable/bg_layer" />
|
|
79
|
+
</layer-list>
|
|
80
|
+
|
|
81
|
+
<adaptive-icon>
|
|
82
|
+
<background android:drawable="@color/ic_bg" />
|
|
83
|
+
<foreground android:drawable="@mipmap/ic_fg" />
|
|
84
|
+
</adaptive-icon>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**5. Values XML cross-references (these are the primary targets for resolution):**
|
|
88
|
+
```xml
|
|
89
|
+
<!-- colors.xml -->
|
|
90
|
+
<color name="primary_light">@color/primary</color>
|
|
91
|
+
|
|
92
|
+
<!-- dimens.xml -->
|
|
93
|
+
<color name="margin_double">@dimen/margin_base</color>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Screen and Source Attribution Support
|
|
97
|
+
|
|
98
|
+
Use dependency analysis not only to resolve resources, but also to collect evidence for the mapping markdown.
|
|
99
|
+
|
|
100
|
+
### Screen attribution evidence sources
|
|
101
|
+
|
|
102
|
+
Collect evidence from:
|
|
103
|
+
- Activities
|
|
104
|
+
- Fragments
|
|
105
|
+
- Compose / UI page files
|
|
106
|
+
- Navigation graphs
|
|
107
|
+
- Layout XML files referenced by Activities or Fragments
|
|
108
|
+
- Menu XML files referenced by screens
|
|
109
|
+
- Direct `R.type.name` references in code
|
|
110
|
+
|
|
111
|
+
### Screen attribution rules
|
|
112
|
+
|
|
113
|
+
- If a screen directly references a resource, attribute the resource to that screen.
|
|
114
|
+
- If a screen references a layout and the layout references additional resources, attribute those resources to that screen.
|
|
115
|
+
- If a shared component is referenced by multiple screens, record all known screens or use `Common`.
|
|
116
|
+
- For launcher icons, round icons, adaptive icons, app name, and app-wide theme resources, use `Launcher` or `Global` as defined by `references/resource-mapping-rules.md`.
|
|
117
|
+
- If evidence is insufficient, use `Unknown`.
|
|
118
|
+
|
|
119
|
+
### Source attribution evidence sources
|
|
120
|
+
|
|
121
|
+
Collect evidence from:
|
|
122
|
+
- Actual source path (`app/src/...`, local module `src/...`)
|
|
123
|
+
- Decompiled APK presence without a matching source resource
|
|
124
|
+
- Resource naming prefixes such as `abc_*`, `mtrl_*`, `design_*`, `material_*`
|
|
125
|
+
- Declared Gradle dependencies
|
|
126
|
+
- Android framework reference prefix `@android:`
|
|
127
|
+
- Runtime URL / remote-loading code patterns
|
|
128
|
+
|
|
129
|
+
### Function-description evidence sources
|
|
130
|
+
|
|
131
|
+
Collect evidence from:
|
|
132
|
+
- resource name semantics
|
|
133
|
+
- XML root type (`vector`, `shape`, `selector`, `layer-list`, `adaptive-icon`)
|
|
134
|
+
- usage site labels or surrounding code context
|
|
135
|
+
- manifest usage (`android:icon`, `android:roundIcon`, etc.)
|
|
136
|
+
|
|
137
|
+
Do not overstate certainty. If the conclusion is inferred, retain that explanation in the eventual mapping-row notes.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
Before resolving references, build a complete lookup table from the resource source directory (either decompiled `res/` or source `res/`). When using the decompiled APK, this table will be comprehensive. When using source `res/`, it will only contain app-defined resources — library resources will be absent, and references to them will be flagged during verification.
|
|
143
|
+
|
|
144
|
+
### Value Resources
|
|
145
|
+
|
|
146
|
+
Parse all `values*/*.xml` files and build mappings:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
colors:
|
|
150
|
+
"primary" → "#FF6200EE"
|
|
151
|
+
"primary_light" → "@color/primary" # reference chain — will be resolved
|
|
152
|
+
"md_blue_500" → "#2196F3"
|
|
153
|
+
|
|
154
|
+
dimens:
|
|
155
|
+
"margin_base" → "16dp"
|
|
156
|
+
"margin_double" → "@dimen/margin_base" # reference chain
|
|
157
|
+
|
|
158
|
+
strings:
|
|
159
|
+
"app_name" → "My App"
|
|
160
|
+
"greeting" → "Hello, %1$s!"
|
|
161
|
+
|
|
162
|
+
integers:
|
|
163
|
+
"max_items" → "10"
|
|
164
|
+
|
|
165
|
+
bools:
|
|
166
|
+
"is_tablet" → "false"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Include ALL qualifier variants (e.g., `values/colors.xml`, `values-night/colors.xml`, `values-ar/colors.xml`). Each qualifier variant gets its own entry in the lookup table.
|
|
170
|
+
|
|
171
|
+
### File Resources
|
|
172
|
+
|
|
173
|
+
Record all drawable and mipmap files:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
drawables:
|
|
177
|
+
"icon" → "drawable/icon.png"
|
|
178
|
+
"bg_card" → "drawable/bg_card.xml" (shape)
|
|
179
|
+
"ic_arrow" → "drawable/ic_arrow.xml" (vector)
|
|
180
|
+
|
|
181
|
+
mipmaps:
|
|
182
|
+
"ic_launcher" → "mipmap-anydpi-v26/ic_launcher.xml" (adaptive-icon)
|
|
183
|
+
"ic_launcher_foreground" → "mipmap-xxxhdpi/ic_launcher_foreground.png"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Resolving References to True Values
|
|
189
|
+
|
|
190
|
+
The key step: walk through all resource values and replace references with actual concrete values.
|
|
191
|
+
|
|
192
|
+
### Resolution Algorithm
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
function resolve(type, name, qualifier, depth=0):
|
|
196
|
+
if depth > 5: return UNRESOLVABLE # prevent infinite loops
|
|
197
|
+
value = lookup_table[qualifier][type][name]
|
|
198
|
+
if value is a concrete value (hex color, number, string literal):
|
|
199
|
+
return value
|
|
200
|
+
if value matches @type/other_name:
|
|
201
|
+
return resolve(type, other_name, qualifier, depth+1)
|
|
202
|
+
if value matches ?attr/name:
|
|
203
|
+
return UNRESOLVABLE # theme attribute, cannot resolve statically
|
|
204
|
+
return value
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### What Gets Resolved
|
|
208
|
+
|
|
209
|
+
**Value-to-value references** (primary targets):
|
|
210
|
+
- `@color/name` → resolved hex color (e.g., `@color/primary` → `#FF6200EE`)
|
|
211
|
+
- `@dimen/name` → resolved dimension value (e.g., `@dimen/margin_base` → `16dp`)
|
|
212
|
+
- `@string/name` → resolved string value
|
|
213
|
+
- `@integer/name` → resolved integer value
|
|
214
|
+
- `@bool/name` → resolved boolean value
|
|
215
|
+
|
|
216
|
+
**File references** (kept as HarmonyOS references, not resolved to values):
|
|
217
|
+
- `@drawable/name` → `$media:name` (the file itself is converted separately)
|
|
218
|
+
- `@mipmap/name` → `$media:name`
|
|
219
|
+
|
|
220
|
+
**Unresolvable references** (logged but kept as-is):
|
|
221
|
+
- `?attr/name` — theme attributes depend on runtime theme
|
|
222
|
+
- `@style/name` — styles have no HarmonyOS equivalent
|
|
223
|
+
|
|
224
|
+
**System resources** (resolved to concrete values, NOT kept as references):
|
|
225
|
+
- `@android:color/name` — resolved via built-in lookup table to hex values
|
|
226
|
+
- `@android:dimen/name` — resolved via built-in lookup table
|
|
227
|
+
- `@android:string/name` — resolved to known string values
|
|
228
|
+
- `@android:drawable/name` — extracted from APK or replaced with placeholder
|
|
229
|
+
|
|
230
|
+
### Resolution During Conversion
|
|
231
|
+
|
|
232
|
+
Resolution happens at conversion time, not as a separate pass. When converting a value from Android XML to HarmonyOS JSON:
|
|
233
|
+
|
|
234
|
+
1. Parse the XML value
|
|
235
|
+
2. If it's a concrete value (hex color, number, string), convert directly using format rules
|
|
236
|
+
3. If it's a resource reference (`@type/name`):
|
|
237
|
+
a. Look up in the lookup table
|
|
238
|
+
b. Follow the chain to the concrete value
|
|
239
|
+
c. Convert the concrete value using format rules
|
|
240
|
+
d. Use the resolved concrete value in the HarmonyOS JSON output
|
|
241
|
+
4. If the reference can't be resolved, use HarmonyOS reference syntax (`$color:name`, `$float:name`, etc.) and log it
|
|
242
|
+
|
|
243
|
+
### Example: Full Resolution Chain
|
|
244
|
+
|
|
245
|
+
Android `values/colors.xml`:
|
|
246
|
+
```xml
|
|
247
|
+
<color name="app_background">@color/surface_color</color>
|
|
248
|
+
<color name="surface_color">@color/md_grey_50</color>
|
|
249
|
+
<color name="md_grey_50">#FAFAFA</color>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Resolution:
|
|
253
|
+
- `app_background` → `@color/surface_color` → `@color/md_grey_50` → `#FAFAFA`
|
|
254
|
+
|
|
255
|
+
HarmonyOS `color.json` output:
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"color": [
|
|
259
|
+
{"name": "app_background", "value": "#ffFAFAFA"},
|
|
260
|
+
{"name": "surface_color", "value": "#ffFAFAFA"},
|
|
261
|
+
{"name": "md_grey_50", "value": "#ffFAFAFA"}
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
All three resolve to the same concrete value. The `#ffFAFAFA` format is after applying the `#RRGGBB` → `#ffRRGGBB` color format conversion.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Where to Scan for Dependencies
|
|
271
|
+
|
|
272
|
+
Scan ALL resource files from the resource source directory for dependencies, organized by priority:
|
|
273
|
+
|
|
274
|
+
### High Priority (converted resources — broken dependencies cause direct errors)
|
|
275
|
+
|
|
276
|
+
| File Type | Typical Location | Why It Matters |
|
|
277
|
+
|---|---|---|
|
|
278
|
+
| Adaptive icon XML | `mipmap-anydpi-v26/*.xml` | References colors, drawables, mipmaps for icon layers |
|
|
279
|
+
| Vector drawables | `drawable/*.xml` (root: `<vector>`) | May reference colors via theme attrs |
|
|
280
|
+
| Shape drawables | `drawable/*.xml` (root: `<shape>`) | May reference colors, dimens |
|
|
281
|
+
| Layer-list drawables | `drawable/*.xml` (root: `<layer-list>`) | References other drawables |
|
|
282
|
+
| Selector drawables | `drawable/*.xml` (root: `<selector>`) | References other drawables for states |
|
|
283
|
+
| Color state lists | `color/*.xml` | References other colors |
|
|
284
|
+
| Values XML | `values*/*.xml` | Cross-references between value types |
|
|
285
|
+
|
|
286
|
+
### Required — Layout and Menu (not converted, but dependencies must be verified)
|
|
287
|
+
|
|
288
|
+
Layout and menu files are **not** converted to HarmonyOS (they use ArkUI instead), but the resources they reference — strings, colors, drawables, dimensions — **must** be present in the converted output so the developer has everything needed when rebuilding the UI.
|
|
289
|
+
|
|
290
|
+
| File Type | Typical Location | Why It Matters |
|
|
291
|
+
|---|---|---|
|
|
292
|
+
| Layout XML | `layout*/*.xml` | References strings, colors, drawables, dimens used by every UI component |
|
|
293
|
+
| Menu XML | `menu/*.xml` | References strings and drawables for action bar / navigation items |
|
|
294
|
+
|
|
295
|
+
### Skip (no meaningful dependencies)
|
|
296
|
+
|
|
297
|
+
- Raw files (`raw/`)
|
|
298
|
+
- Font files (`font/`) — unless font XML family definitions reference other fonts
|
|
299
|
+
- Image files (PNG, JPG, WEBP, etc.) — binary files, no references
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Dependency Verification
|
|
304
|
+
|
|
305
|
+
After conversion with reference resolution, verify that the output is self-consistent:
|
|
306
|
+
|
|
307
|
+
### Check by Resource Type
|
|
308
|
+
|
|
309
|
+
| Dependency Type | Where to Check in HarmonyOS Output |
|
|
310
|
+
|---|---|
|
|
311
|
+
| `@color/name` | Should be resolved to hex in `*/element/color.json`. If not resolved, check `name` exists. |
|
|
312
|
+
| `@drawable/name` | Look for `name.*` (any extension: .png, .svg, .jpg, etc.) in `*/media/` |
|
|
313
|
+
| `@mipmap/name` | Same as drawable — mipmaps go to `media/` in HarmonyOS |
|
|
314
|
+
| `@string/name` | Should be resolved to literal in `*/element/string.json`. If not resolved, check `name` exists. |
|
|
315
|
+
| `@dimen/name` | Should be resolved to value in `*/element/float.json`. If not resolved, check `name` exists. |
|
|
316
|
+
| `@integer/name` | Look for `name` in `*/element/integer.json` |
|
|
317
|
+
| `@bool/name` | Look for `name` in `*/element/boolean.json` |
|
|
318
|
+
| `@array/name` | Look for `name` in `*/element/strarray.json` or `*/element/intarray.json` |
|
|
319
|
+
| `@plurals/name` | Look for `name` in `*/element/plural.json` |
|
|
320
|
+
| `@style/name` | Mark as "unmappable type" (styles have no HarmonyOS equivalent) |
|
|
321
|
+
| `@attr/name` | Mark as "unmappable type" |
|
|
322
|
+
| `@layout/name` | Mark as "not applicable" (layouts aren't converted) |
|
|
323
|
+
| `@id/name` | Mark as "not applicable" (IDs are code-level concerns) |
|
|
324
|
+
|
|
325
|
+
### Qualifier Coverage Check
|
|
326
|
+
|
|
327
|
+
When a dependency is satisfied, also verify qualifier coverage. If the dependent resource exists in multiple qualifier directories (e.g., `base`, `dark`, `ldpi`), the dependency should ideally exist in matching qualifier directories. Flag cases where a dependency exists in `base` but the dependent resource also has `dark` or density-qualified variants — the dependency may need those variants too.
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## Handling Missing Library Resources
|
|
332
|
+
|
|
333
|
+
When converting from source `res/` (because the APK build failed or no APK was available), library-provided resources will be absent from the lookup table. This section describes how to handle these gaps gracefully.
|
|
334
|
+
|
|
335
|
+
### Identifying Library Resources
|
|
336
|
+
|
|
337
|
+
Many common Android libraries define resources with recognizable naming patterns. Use these heuristics to correlate unsatisfied dependencies with likely library sources:
|
|
338
|
+
|
|
339
|
+
| Library | Common Resource Prefixes |
|
|
340
|
+
|---|---|
|
|
341
|
+
| Material Components (`com.google.android.material`) | `material_*`, `design_*`, `mtrl_*`, `Widget.Material*`, `Theme.Material*` |
|
|
342
|
+
| AndroidX AppCompat (`androidx.appcompat`) | `abc_*`, `Widget.AppCompat.*` |
|
|
343
|
+
| AndroidX Core (`androidx.core`) | `notification_*`, `compat_*` |
|
|
344
|
+
| AndroidX ConstraintLayout | `constraint_*` |
|
|
345
|
+
| Google Play Services | `common_google_*` |
|
|
346
|
+
|
|
347
|
+
### Extracting Library Dependencies from build.gradle
|
|
348
|
+
|
|
349
|
+
Parse `build.gradle` or `build.gradle.kts` to identify declared library dependencies:
|
|
350
|
+
|
|
351
|
+
```groovy
|
|
352
|
+
// build.gradle
|
|
353
|
+
dependencies {
|
|
354
|
+
implementation 'com.google.android.material:material:1.9.0'
|
|
355
|
+
implementation 'androidx.appcompat:appcompat:1.6.1'
|
|
356
|
+
implementation 'androidx.core:core-ktx:1.12.0'
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Extract the group:artifact for each dependency. In the conversion report, list these libraries with their likely resource prefixes so the developer knows which libraries contribute which missing resources.
|
|
361
|
+
|
|
362
|
+
### Resolution Behavior for Missing Resources
|
|
363
|
+
|
|
364
|
+
When a reference cannot be resolved because the target resource is not in the lookup table:
|
|
365
|
+
|
|
366
|
+
1. **Apply a type-appropriate fallback value** to ensure the output compiles without errors:
|
|
367
|
+
- `$color:name` → `#ff000000` (black)
|
|
368
|
+
- `$float:name` → `0vp`
|
|
369
|
+
- `$string:name` → `""`
|
|
370
|
+
- `$integer:name` → `0`
|
|
371
|
+
- `$boolean:name` → `false`
|
|
372
|
+
2. **Log it as an unsatisfied dependency** with:
|
|
373
|
+
- The original reference (`@color/design_default_color_primary`)
|
|
374
|
+
- The fallback value applied (`#ff000000`)
|
|
375
|
+
- The source file where it was found
|
|
376
|
+
- The likely library source (if identifiable from naming patterns)
|
|
377
|
+
- The reason: "Library resource not available in source res/ — fallback applied"
|
|
378
|
+
3. **Why fallback instead of keeping the reference**: Keeping `$color:name` references in the output causes HarmonyOS compilation errors. Applying a safe default ensures the project compiles and the developer can identify and fix the fallback values by searching for the logged warnings. The conversion report provides a complete list of all fallbacks applied.
|
|
379
|
+
4. **When converting from a decompiled APK**: unresolved references should be very rare (the APK contains all merged resources). If they occur, log them as errors rather than warnings — they indicate a bug in the resolution logic.
|
|
380
|
+
|
|
381
|
+
### Categorizing Unresolved References
|
|
382
|
+
|
|
383
|
+
In the report, separate unresolved references into categories:
|
|
384
|
+
|
|
385
|
+
1. **Missing library resources** — references to resources that likely come from declared library dependencies. These are expected when converting from source `res/`.
|
|
386
|
+
2. **Theme attributes** (`?attr/name`) — cannot be statically resolved regardless of resource source.
|
|
387
|
+
3. **System resources** (`@android:type/name`) — Android framework resources that MUST be resolved to concrete values using the built-in lookup tables. If resolution fails, use a type-appropriate default (colors → `#ff000000`, dimens → `0vp`, integers → `0`, strings → `""`) and log a warning. System resource references must NEVER appear in the final converted output.
|
|
388
|
+
4. **Truly missing** — references that don't match any known library pattern and aren't in the lookup table. These may indicate a project misconfiguration or an undeclared dependency.
|