feat: add isolated Liam square540 head-chest build preset

This commit is contained in:
zenord
2026-10-15 11:43:38 +08:00
parent f705c27eee
commit 2405026402
16 changed files with 379 additions and 35 deletions
+50 -7
View File
@@ -12,6 +12,7 @@ from pathlib import Path
import re
import shutil
import subprocess
import struct
import tempfile
import urllib.request
import zipfile
@@ -32,10 +33,47 @@ def file_sha(p):
return hashlib.file_digest(f, 'sha256').hexdigest()
def dex_float_fields(raw, descriptor='Lcom/gorios/lanvoice/BuildConfig;'):
"""Read encoded FLOAT bits: dexdump prints only six significant digits."""
def uleb(pos):
value=0
for shift in range(0,35,7):
byte=raw[pos];pos+=1;value|=(byte&127)<<shift
if byte<128:return value,pos
raise ValueError('invalid DEX uleb')
def uint(pos):return struct.unpack_from('<I',raw,pos)[0]
def string(index):
pos=uint(uint(60)+index*4);_,pos=uleb(pos)
return raw[pos:raw.index(b'\0',pos)].decode('utf-8')
def typename(index):return string(uint(uint(68)+index*4))
for i in range(uint(96)):
pos=uint(100)+i*32
if typename(uint(pos))!=descriptor:continue
data=uint(pos+24);values=uint(pos+28)
count,data=uleb(data)
for _ in range(3):_,data=uleb(data)
fields=[];field_index=0
for _ in range(count):
delta,data=uleb(data);_,data=uleb(data);field_index+=delta
fields.append(string(uint(uint(84)+field_index*8+4)))
size,values=uleb(values);floats={}
for name in fields[:size]:
header=raw[values];values+=1;kind=header&31;length=(header>>5)+1
if kind in (0x1e,0x1f):continue # null/boolean have no payload
require(kind in (0,2,3,4,6,16,17,23,24,25,26,27), 'unexpected BuildConfig DEX value')
payload=raw[values:values+length];values+=length
if kind==16:
require(length<=4,'invalid DEX float')
floats[name]=struct.unpack('<f',b'\0'*(4-length)+payload)[0]
return floats
raise ValueError('BuildConfig DEX class missing')
def flags(profile, version, media_bundle='black-correct03'):
media = select.catalog()['mediaBundles'][media_bundle]
pin = media['indexSha256']
return ['-PcharacterProfile='+profile, '-PcharacterMediaBundle='+media_bundle,
cache_flags = [] if profile != 'liam-test-square540' else ['--project-cache-dir='+str(ROOT/'.runtime/gradle-project-cache'/profile/'square540-headchest')]
return cache_flags + ['-PcharacterProfile='+profile, '-PcharacterMediaBundle='+media_bundle,
'-PavatarUserNetworkActions='+str(media.get('networkActionsAllowed',False)).lower(),
'-PactionVersionCode='+str(version),
'-PnaturalManifestSha=0a3c4918ba746019cf1df885bec66e5858a8950997dac4f64e7d37094be64dad',
@@ -47,12 +85,15 @@ def flags(profile, version, media_bundle='black-correct03'):
def build_dir(profile):
return ROOT/('app/build' if profile == 'main' else 'app/build/characters/'+profile)
return select.build_directory(profile)
def verify(apk, profile, version, media_bundle='black-correct03',frame_zoom=1,frame_center_y=.5):
catalog = select.catalog()
role = catalog['profiles'][profile]
framing = select.framing(profile, media_bundle)
if framing['id'] != 'legacy':
frame_zoom,frame_center_y=framing['zoom'],framing['centerY']
media = catalog['mediaBundles'][media_bundle]
selected = select.selection(ROOT/'app/src/main/assets', profile, emotion_sha=media['indexSha256'],
user_assets=True, mouth=True, startup=True, media_bundle=media_bundle)
@@ -78,7 +119,7 @@ def verify(apk, profile, version, media_bundle='black-correct03',frame_zoom=1,fr
require(new.read(poster_path)==new.read('assets/'+media['bootstrapRoot']+'poster.png'), 'selected poster mismatch')
# Read real DEX static values rather than trusting a generated Java file.
with tempfile.TemporaryDirectory() as folder:
dex_text = ''
dex_text = '';dex_floats={}
for name in new.namelist():
if re.fullmatch(r'classes\d*\.dex', name):
dex = Path(folder)/name
@@ -86,7 +127,7 @@ def verify(apk, profile, version, media_bundle='black-correct03',frame_zoom=1,fr
result = subprocess.check_output([str(TOOLS/'dexdump'), str(dex)]).decode('utf-8', errors='replace')
match = re.search(r"Class descriptor\s*:\s*'Lcom/gorios/lanvoice/BuildConfig;'([\s\S]*?)(?=\nClass #|\Z)", result)
if match:
dex_text = match[1]
dex_text = match[1];dex_floats=dex_float_fields(new.read(name))
break
require(dex_text, 'BuildConfig absent from actual DEX')
dex_values = dict(re.findall(r"name\s*:\s*'([^']+)'[^\n]*\n\s*type[^\n]*\n\s*access[^\n]*\n\s*value\s*:\s*([^\n]+)", dex_text))
@@ -94,6 +135,8 @@ def verify(apk, profile, version, media_bundle='black-correct03',frame_zoom=1,fr
'CHARACTER_PROFILE': profile, 'EMOTION_MANIFEST_SHA': media['indexSha256'],
'EMOTION_ASSET_ROOT': media['assetRoot'], 'STARTUP_ASSET_ROOT': media['bootstrapRoot'],
'STARTUP_MANIFEST_SHA': media['bootstrapSha256']}
if 'AVATAR_FRAMING_PRESET' in dex_values or framing['id']!='legacy':
expected['AVATAR_FRAMING_PRESET']=framing['id']
for field, value in expected.items():
require(dex_values.get(field) == '"'+value+'"', 'APK DEX mismatch: '+field)
for field, value in {'AVATAR_NETWORK_ACTIONS_ALLOWED': media.get('networkActionsAllowed',False), 'AVATAR_USER_ASSET_CANDIDATE': True,
@@ -105,7 +148,7 @@ def verify(apk, profile, version, media_bundle='black-correct03',frame_zoom=1,fr
dex_values.get('VERSION_NAME') == '"0.7.14'+role['versionSuffix']+'"', 'APK DEX version mismatch')
for field,value in [('AVATAR_FRAME_ZOOM',frame_zoom),('AVATAR_FRAME_CENTER_Y',frame_center_y)]:
if field in dex_values or frame_zoom!=1 or frame_center_y!=.5:
require(abs(float(dex_values.get(field,'nan'))-value)<.000001,'APK framing mismatch: '+field)
require(abs(dex_floats.get(field,float('nan'))-value)<.000001,'APK framing mismatch: '+field)
badge = subprocess.check_output([str(TOOLS/'aapt'), 'dump', 'badging', str(apk)], text=True)
version_name = '0.7.14'+role['versionSuffix']
for value in ("name='"+role['applicationId']+"'", f"versionCode='{version}'",
@@ -129,13 +172,13 @@ def verify(apk, profile, version, media_bundle='black-correct03',frame_zoom=1,fr
'assets_unchanged': len(selected['files']) if media_bundle=='black-correct03' else None,
'network_actions_allowed':media.get('networkActionsAllowed',False),
'waiting_contract_enabled':media.get('waitingContract',False),
'framing_zoom':frame_zoom,'framing_center_y':frame_center_y,
'framing_preset':framing['id'],'framing_zoom':frame_zoom,'framing_center_y':frame_center_y,
'poster_resources_unchanged': 2, 'provider_authorities': authorities,
'actual_dex_verified': True, 'device': 'not_run', 'gateway_changed': False}
def artifact_name(profile, version):
require(profile in ('lvbu-test', 'liam-test'), 'main publication outside this task')
require(profile in ('lvbu-test', 'liam-test', 'liam-test-square540'), 'main publication outside this task')
return f"lan-voice-v0714-{profile}-code{version}-arm64-debug.apk"