Skip to content

Commit 4ea4b75

Browse files
committed
fix: restore global mod_device suffix and remove provision workaround
1 parent c1e400e commit 4ea4b75

4 files changed

Lines changed: 95 additions & 13 deletions

File tree

devices/common/props_global.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
"ro.product.mod_device": "{base_code}_xiaomieu_global",
3131
"ro.build.host": "xiaomi.eu"
3232
},
33+
"global_rom": {
34+
"ro.product.mod_device": "{global_mod_device}",
35+
"ro.build.host": "{build_host}"
36+
},
3337
"cn_rom": {
3438
"ro.product.mod_device": "{base_code}",
3539
"ro.build.host": "{build_host}"

devices/common/replacements.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,6 @@
103103
"condition_port_os_version_incremental_gte": "OS3.0.0",
104104
"condition_base_android_version_gte": 15,
105105
"condition_base_android_version_lt": 16
106-
},
107-
{
108-
"description": "CN stock to global (non-EU) copy Provision app",
109-
"id": "copy_provision_cn_to_global",
110-
"fixme": "Temporary workaround: On CN hardware, using global Provision can get stuck on Setup Wizard WiFi page (returns to same page after connect/skip). Replacing with CN Provision mitigates the issue until root cause is fixed.",
111-
"type": "file",
112-
"search_path": "system_ext/priv-app",
113-
"match_mode": "exact",
114-
"ensure_exists": true,
115-
"files": ["Provision"],
116-
"condition_is_port_global_rom": true,
117-
"condition_stock_region": "cn"
118106
}
119107
]
120108
}

src/core/props.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,22 @@ def _update_general_info(self):
290290
# 1. Common
291291
replacements = config.get("common", {})
292292

293-
# 2. EU vs CN
293+
# 2. EU vs Global vs CN
294294
is_eu = getattr(self.ctx, "is_port_eu_rom", False)
295+
is_global = getattr(self.ctx, "is_port_global_rom", False) and not is_eu
295296
if is_eu:
296297
replacements.update(config.get("eu_rom", {}))
298+
elif is_global:
299+
replacements.update(config.get("global_rom", {}))
297300
else:
298301
replacements.update(config.get("cn_rom", {}))
299302

303+
global_region = (getattr(self.ctx, "port_global_region", "") or "").strip().lower()
304+
if global_region and global_region != "global":
305+
global_mod_device = f"{base_code}_{global_region}_global"
306+
else:
307+
global_mod_device = f"{base_code}_global"
308+
300309
# Format values (Placeholder replacement)
301310
fmt_map = {
302311
"build_date": build_date,
@@ -305,6 +314,8 @@ def _update_general_info(self):
305314
"rom_version": rom_version,
306315
"build_user": self.build_user,
307316
"build_host": self.build_host,
317+
"global_region": global_region,
318+
"global_mod_device": global_mod_device,
308319
}
309320

310321
# Build final key-value map for processing
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import logging
2+
from types import SimpleNamespace
3+
4+
# Ensure modifier package is initialized before importing PropertyModifier.
5+
import src.core.modifiers # noqa: F401
6+
from src.core.props import PropertyModifier
7+
8+
9+
def _write_minimal_props_global_json(tmp_path):
10+
devices_common = tmp_path / "devices" / "common"
11+
devices_common.mkdir(parents=True, exist_ok=True)
12+
(devices_common / "props_global.json").write_text(
13+
"""{
14+
"common": {},
15+
"eu_rom": {
16+
"ro.product.mod_device": "{base_code}_xiaomieu_global"
17+
},
18+
"global_rom": {
19+
"ro.product.mod_device": "{global_mod_device}"
20+
},
21+
"cn_rom": {
22+
"ro.product.mod_device": "{base_code}"
23+
}
24+
}
25+
""",
26+
encoding="utf-8",
27+
)
28+
29+
30+
def _build_ctx(tmp_path, *, is_port_eu_rom, is_port_global_rom, port_global_region):
31+
target_dir = tmp_path / "target"
32+
target_dir.mkdir(parents=True, exist_ok=True)
33+
return SimpleNamespace(
34+
target_dir=target_dir,
35+
stock_rom_code="pudding",
36+
target_rom_version="OS2.0.0.TEST",
37+
is_port_eu_rom=is_port_eu_rom,
38+
is_port_global_rom=is_port_global_rom,
39+
port_global_region=port_global_region,
40+
)
41+
42+
43+
def _run_update_and_read_mod_device(tmp_path, ctx):
44+
prop_file = ctx.target_dir / "build.prop"
45+
prop_file.write_text("ro.product.mod_device=old_value\n", encoding="utf-8")
46+
modifier = PropertyModifier(ctx, logger=logging.getLogger("test.props.mod_device"))
47+
modifier._update_general_info()
48+
for line in prop_file.read_text(encoding="utf-8").splitlines():
49+
if line.startswith("ro.product.mod_device="):
50+
return line.split("=", 1)[1]
51+
raise AssertionError("ro.product.mod_device was not found after update")
52+
53+
54+
def test_update_general_info_preserves_global_region_suffix_for_mod_device(tmp_path, monkeypatch):
55+
_write_minimal_props_global_json(tmp_path)
56+
monkeypatch.chdir(tmp_path)
57+
ctx = _build_ctx(
58+
tmp_path,
59+
is_port_eu_rom=False,
60+
is_port_global_rom=True,
61+
port_global_region="tw",
62+
)
63+
64+
value = _run_update_and_read_mod_device(tmp_path, ctx)
65+
assert value == "pudding_tw_global"
66+
67+
68+
def test_update_general_info_uses_generic_global_suffix_when_region_missing(tmp_path, monkeypatch):
69+
_write_minimal_props_global_json(tmp_path)
70+
monkeypatch.chdir(tmp_path)
71+
ctx = _build_ctx(
72+
tmp_path,
73+
is_port_eu_rom=False,
74+
is_port_global_rom=True,
75+
port_global_region="",
76+
)
77+
78+
value = _run_update_and_read_mod_device(tmp_path, ctx)
79+
assert value == "pudding_global"

0 commit comments

Comments
 (0)