Migrate Lumen to Dart and Flutter 2.0

This commit is contained in:
Hadrian Burkhardt
2026-10-31 04:08:16 +01:00
parent 07e9253663
commit 302ad6d38e
145 changed files with 5856 additions and 101 deletions
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""Read-only game-progress smoke check of the installed Flutter app; no fixtures/reset."""
import argparse,re,subprocess,time,xml.etree.ElementTree as ET
from pathlib import Path
p=argparse.ArgumentParser();p.add_argument('--serial',required=True);p.add_argument('--package',default='com.lumen.daily');p.add_argument('--expect-fresh',action='store_true');a=p.parse_args()
assert re.fullmatch(r'[a-zA-Z0-9_.]+',a.package)
base=['/home/ubuntu/Android/Sdk/platform-tools/adb','-s',a.serial];out=Path('artifacts/flutter-check');out.mkdir(parents=True,exist_ok=True)
def adb(*args):return subprocess.check_output(base+list(args))
def dump():
adb('shell','uiautomator','dump','/sdcard/lumen-flutter-smoke.xml')
return ET.fromstring(adb('exec-out','cat','/sdcard/lumen-flutter-smoke.xml'))
def value(n):return n.get('text','')+' '+n.get('content-desc','')
def find(text):
root=dump()
for n in root.iter('node'):
if text.casefold() in value(n).casefold():return n
raise AssertionError('Missing '+text+'; screen: '+str([value(n) for n in root.iter('node') if value(n).strip()]))
def tapnode(n):
x1,y1,x2,y2=map(int,re.findall(r'\d+',n.get('bounds')));adb('shell','input','tap',str((x1+x2)//2),str((y1+y2)//2))
def tap(text):tapnode(find(text))
def launch():adb('shell','am','start','-n',a.package+'/com.lumen.daily.MainActivity')
def shot(name):(out/name).write_bytes(adb('exec-out','screencap','-p'))
launch();time.sleep(2)
# Leave the player's actual consent decision to them if UMP requires it.
root=dump()
assert not any('Welcome to Publisher Test Ads' in value(n) for n in root.iter('node')),'Consent form is awaiting the player’s choice.'
if any('Close book' in value(n) for n in root.iter('node')):tap('Close book')
if a.expect_fresh:find('0 / 12');find('0\nPATTERNS FOUND')
shot('main-home.png');tap('Open Mara’s notebook');find('For you, when you are ready');tap('Next leaf');find('By the cottage window')
play=find('Play this reading');tapnode(play);time.sleep(2);shot('main-recording.png');tapnode(play);find('Resume recording')
def seconds():
n=find('Paused ·');m=re.search(r'(\d+):(\d+)',value(n));return int(m[1])*60+int(m[2])
first=seconds();assert first>=1
tapnode(play);time.sleep(2);tapnode(play);find('Resume recording');assert seconds()>=first+1
tap('Stop');find('Play this reading')
adb('shell','am','force-stop',a.package);launch();find('By the cottage window');find('Play this reading');shot('main-restored-page.png')
tap('Close book')
if a.expect_fresh:find('0 / 12');find('0\nPATTERNS FOUND')
print('PASS: optimized app launches, starts fresh, plays through its UI, resumes audio, restores the reading place after process restart and leaves puzzle counts unchanged.')
(out/'release-smoke.txt').write_text('PASS: fresh Flutter progress; release startup; UI FLAC playback/pause/resume/stop; process restart restores page; 0 puzzles awarded by reading.\n')
+6 -10
View File
@@ -1,13 +1,10 @@
#!/usr/bin/env python3
"""Verify every bundled recording matches the current diary text and its WAV master."""
import array, hashlib, json, math, subprocess, tempfile, wave
import array, hashlib, json, subprocess, wave
from pathlib import Path
root=Path(__file__).resolve().parents[1]
source=root/'assets/narration';raw=root/'app/src/main/res/raw'
with tempfile.TemporaryDirectory(prefix='lumen-audio-text-') as temp:
subprocess.run(['javac','-d',temp,str(root/'app/src/main/java/com/lumen/daily/StoryBook.java'),str(root/'scripts/ExportNarration.java')],check=True)
canonical=json.loads(subprocess.check_output(['java','-cp',temp,'com.lumen.daily.ExportNarration']))
assert canonical==json.loads((source/'scripts.json').read_text()),'Regenerate the script export after editing diary text'
source=root/'assets/narration';raw=root/'assets/audio'
canonical=json.loads((source/'scripts.json').read_text())
manifest=json.loads((source/'manifest.json').read_text());runtime=json.loads((raw/'narration_manifest.json').read_text())
assert runtime['tracks']==manifest['tracks']
assert len(canonical)==5==len(manifest['tracks'])
@@ -32,7 +29,6 @@ for record in canonical:
assert decoded==master,'Runtime FLAC must preserve the WAV master exactly'
assert track['flacSha256']==hashlib.sha256(flac.read_bytes()).hexdigest()
print(f"PASS {record['pageId']}: {track['durationMs']/1000:.1f}s, lossless, text/cues match")
for p in (root/'app/src/main/java').rglob('*.java'):
assert 'android.speech.tts' not in p.read_text(),f'Android reader reintroduced in {p}'
assert 'TTS_SERVICE' not in (root/'app/src/main/AndroidManifest.xml').read_text()
print('All five recordings verified; no Android text-to-speech dependency.')
for p in (root/'lib').rglob('*.dart'):
assert 'flutter_tts' not in p.read_text(),f'Device reader reintroduced in {p}'
print('All five recordings verified; bundled file playback only.')
+1 -1
View File
@@ -16,7 +16,7 @@ parser.add_argument('--voice',default='bf_emma')
parser.add_argument('--speed',type=float,default=.82)
parser.add_argument('--root',type=Path,default=Path(__file__).resolve().parents[1])
a=parser.parse_args()
source=a.root/'assets/narration';raw=a.root/'app/src/main/res/raw'
source=a.root/'assets/narration';raw=a.root/'assets/audio'
(source/'wav').mkdir(parents=True,exist_ok=True);raw.mkdir(parents=True,exist_ok=True)
options=ort.SessionOptions();options.intra_op_num_threads=4;options.inter_op_num_threads=1
session=ort.InferenceSession(str(a.model),sess_options=options,providers=['CPUExecutionProvider'])