"""Drive the same real Android update flow on each checkout's Metro bundle.
Pair a fresh old nightly desktop first and label it 'Update proof'.
Pass an output directory; no credentials or server responses are supplied here.
The desktop download is slowed separately with slow-desktop.py using its captured PID.
"""
import subprocess,sys,pathlib,json,time
out=pathlib.Path(sys.argv[1]); out.mkdir(parents=True,exist_ok=True)
session=sys.argv[2]
def run(*args):
 p=subprocess.run(['agent-device',*args,'--session',session],capture_output=True,text=True)
 with open(out/'actions.txt','a') as f: f.write(' '.join(args)+'\n'+p.stdout+p.stderr+'\n')
 if p.returncode: raise RuntimeError('Device command failed: '+args[0])
 return p.stdout
run('record','start',str(out/'raw.mp4'),'--hide-touches','--quality','medium')
run('press','label="Update to 0.1.15-nightly.20261205.5786"','--settle')
run('press','label="Update"','--settle')
run('wait','text','Downloading update…')
run('back','--settle')
run('press','label="Manage Update proof"','--settle')
run('snapshot','-i')
run('screenshot',str(out/'reopened.png'))
run('record','stop')
