Kaleido/scripts/verify_navigation_sounds.py
Elijah 430616330b
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m14s
Release 0.1.2 with navigation sounds and smoother Home scrolling
2026-10-24 10:18:59 -07:00

48 lines
2.5 KiB
Python

"""Check navigation sound persistence; audio() also compares native mixer activity.
The optional mixer check needs system sound effects enabled and otherwise silent
audio output on the authorized onn. It never changes the TV's global sound setting.
"""
import json,time
from verify_ui import launch,key,focused,text
from device import adb,OUT,screenshot
def setting():
launch();key(22,4);focused('Settings');key(23);focused('Sign in with Plex')
key(20);focused('Mode: Direct stream');key(20);focused('Mark watched at 80%');key(20)
def persistence():
setting();focused('Navigation sounds: On');key(23);focused('Navigation sounds: Off')
screenshot('navigation-sounds-off')
setting();focused('Navigation sounds: Off')
print('PASS disabling navigation sounds persists across process restart',flush=True)
key(23);focused('Navigation sounds: On')
setting();focused('Navigation sounds: On')
print('PASS enabling navigation sounds persists across process restart',flush=True)
screenshot('navigation-sounds-on');key(4);focused('Home');text('Continue Watching')
def audio():
assert adb('shell','settings','get','system','sound_effects_enabled').decode().strip()=='1','System sound effects must already be enabled for this optional check'
def probe(label):
time.sleep(.4)
adb('shell','atrace','--async_start','-b','16384','audio')
try:
for _ in range(3):
adb('shell','input','keyevent','20');time.sleep(.3)
adb('shell','input','keyevent','19');time.sleep(.3)
time.sleep(.4)
finally:raw=adb('shell','atrace','--async_stop','audio').decode(errors='replace')
(OUT/f'navigation-audio-{label}-atrace.txt').write_text(raw)
focused('Navigation sounds: '+label.capitalize())
return sum('tracing_mark_write: B|' in line and line.endswith('|write') for line in raw.splitlines())
setting();focused('Navigation sounds: On');key(23);focused('Navigation sounds: Off')
muted=probe('off')
key(23);focused('Navigation sounds: On');enabled=probe('on')
result={'mutedMixerWrites':muted,'enabledMixerWrites':enabled}
(OUT/'navigation-audio-results.json').write_text(json.dumps(result,indent=2)+'\n')
print('Native audio activity:',result,flush=True)
assert muted==0 and enabled>0,'Expected silence while muted and native audio output while enabled'
print('PASS navigation taps produce native mixer output only while enabled',flush=True)
key(4);focused('Home')
if __name__=='__main__':persistence()