Work already pending in the tree before the bug-fix pass, committed on its own: - Remove Volume boost (it degraded audio) and its setting; keep passthrough. - Leave playback with the server's reason when Plex stops a session (timeline terminationCode/terminationText); never fall back or reconnect after. - Genre filtering lives in Categories; the Library grid lists the whole section. - Update UI verification scripts and AGENTS.md accordingly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
6.1 KiB
Python
105 lines
6.1 KiB
Python
"""Validate optional themes and the normal audio path on the authorized onn; restore the prior audio preferences."""
|
|
import re,time,sys,xml.etree.ElementTree as ET
|
|
from device import adb,OUT,screenshot
|
|
from verify_ui import launch,key,text,focused,focus,snapshot,labels,wait,passed
|
|
|
|
def settings(category):
|
|
launch();key(22,4);focused('Settings');key(23);focused('Switch account')
|
|
key(21);focused('Connection');key(20,category);key(22)
|
|
|
|
def choose(options,value):
|
|
key(23)
|
|
current=focus(snapshot())
|
|
assert current in options,(current,options)
|
|
delta=options.index(value)-options.index(current)
|
|
key(20 if delta>=0 else 19,abs(delta));focused(value);key(23)
|
|
|
|
def logs():return adb('logcat','-d','-s','KaleidoTheme:I','KaleidoPlayback:I','*:S').decode(errors='replace')
|
|
|
|
def wait_log(fragment,timeout=40):
|
|
deadline=time.monotonic()+timeout
|
|
while time.monotonic()<deadline:
|
|
value=logs()
|
|
if fragment in value:return value
|
|
time.sleep(.5)
|
|
raise AssertionError('Missing log '+fragment)
|
|
|
|
def open_silo():
|
|
launch();key(22,3);focused('Search');key(23);text('Search')
|
|
adb('shell','input','text','silo')
|
|
text('TV shows');key(66);focused('Silo');key(23);text('Seasons')
|
|
|
|
if __name__=='__main__':
|
|
playback_only='--playback-only' in sys.argv
|
|
original_xml=None
|
|
if playback_only:
|
|
# UI preferences and persistence are checked separately; isolate the playback batch
|
|
# using only this debug app's private preferences, with byte-for-byte restoration.
|
|
original_xml=adb('shell','run-as','tv.kaleido.app','cat','shared_prefs/preferences.xml')
|
|
(OUT/'030-audio-original-preferences.xml').write_bytes(original_xml)
|
|
tree=ET.fromstring(original_xml)
|
|
for name,kind,value in [('themeMusic','boolean','true'),('themeVolume','int','20')]:
|
|
node=next((n for n in tree if n.get('name')==name),None)
|
|
if node is None:node=ET.SubElement(tree,kind,{'name':name})
|
|
node.set('value',value)
|
|
adb('shell','am','force-stop','tv.kaleido.app')
|
|
adb('shell','run-as','tv.kaleido.app','sh','-c','"cat > shared_prefs/preferences.xml"',data=ET.tostring(tree,encoding='utf-8',xml_declaration=True))
|
|
else:
|
|
settings(3);focused('Navigation sounds');key(20);focused('Theme music')
|
|
original_on=focus(snapshot()).endswith('On')
|
|
if not original_on:key(23)
|
|
key(20);focused('Theme music volume')
|
|
original_volume=re.search(r'(\d+)%$',focus(snapshot())).group(1)+'%'
|
|
choose([str(n)+'%' for n in range(10,101,10)],'20%');focused('Theme music volume')
|
|
settings(3);key(20);focused('Theme music');assert focus(snapshot()).endswith('On')
|
|
key(20);focused('Theme music volume');assert focus(snapshot()).endswith('20%')
|
|
screenshot('030-theme-settings')
|
|
passed('Theme toggle and theme volume persist through cold starts; dialogs restore focus')
|
|
try:
|
|
adb('logcat','-c');open_silo();wait_log('KaleidoTheme: READY volume=20%')
|
|
screenshot('030-silo-theme')
|
|
adb('logcat','-c');key(3);wait_log('STOP')
|
|
# Launchers may reopen Home rather than restore the previous Activity task.
|
|
# Enter the title through the normal remote flow before expecting music again.
|
|
open_silo();wait_log('PLAYING')
|
|
passed('Theme stops in the background and plays again on a title page')
|
|
# Show -> season -> neighbouring episode selection all retain a supported theme.
|
|
key(20)
|
|
wait(lambda r:'Season' in focus(r),'Season receives focus');key(23)
|
|
wait(lambda r:any(t=='Episodes' or t.startswith(('Play','Resume')) for t in labels(r)),'Season episode header')
|
|
wait_log('KaleidoTheme: READY volume=20%')
|
|
passed('Series and season/episode detail pages play the real inherited Plex theme')
|
|
# Actual video uses validation mode, which avoids changing Plex progress.
|
|
adb('logcat','-c')
|
|
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','7599','--el','testOffset','90000','--ei','testMode','0','--ez','testValidation','true')
|
|
wait_log('STOP');wait_log('READY item=7599')
|
|
time.sleep(4)
|
|
audit=adb('shell','run-as','tv.kaleido.app','cat','files/playback-validation.jsonl')
|
|
(OUT/'030-audio-validation.jsonl').write_bytes(audit)
|
|
import json
|
|
events=[json.loads(line) for line in audit.decode().splitlines()]
|
|
assert any(e.get('event')=='audioAdvancing' for e in events),'Decoded audio must advance'
|
|
assert any(e.get('event')=='firstFrame' for e in events),'Video must render'
|
|
passed('Theme stops for actual video; audio and video advance')
|
|
adb('shell','am','force-stop','tv.kaleido.app');adb('logcat','-c')
|
|
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId','9776','--el','testOffset','90000','--ei','testMode','2','--ez','testValidation','true')
|
|
wait_log('READY item=9776');time.sleep(4)
|
|
movie_audit=adb('shell','run-as','tv.kaleido.app','cat','files/playback-validation.jsonl')
|
|
(OUT/'030-audio-movie-validation.jsonl').write_bytes(movie_audit)
|
|
movie_events=[json.loads(line) for line in movie_audit.decode().splitlines()]
|
|
assert any(e.get('event')=='audioAdvancing' for e in movie_events)
|
|
assert any(e.get('event')=='firstFrame' for e in movie_events)
|
|
passed('A real Plex-converted movie renders audio and video')
|
|
adb('shell','am','force-stop','tv.kaleido.app')
|
|
finally:
|
|
if playback_only:
|
|
adb('shell','am','force-stop','tv.kaleido.app')
|
|
adb('shell','run-as','tv.kaleido.app','sh','-c','"cat > shared_prefs/preferences.xml"',data=original_xml)
|
|
assert adb('shell','run-as','tv.kaleido.app','cat','shared_prefs/preferences.xml')==original_xml
|
|
else:
|
|
settings(3);key(20);focused('Theme music')
|
|
if focus(snapshot()).endswith('On')!=original_on:key(23)
|
|
key(20);focused('Theme music volume');choose([str(n)+'%' for n in range(10,101,10)],original_volume)
|
|
launch()
|
|
(OUT/'030-audio.log').write_text(logs())
|
|
passed('Prior theme preferences restored; device returned to Home')
|