Initial Beta build
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m27s
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m27s
This commit is contained in:
commit
2b585badac
65 changed files with 3535 additions and 0 deletions
36
scripts/device.py
Normal file
36
scripts/device.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
"""Operate only Kaleido on the authorized onn streamer. Credentials stay on stdin."""
|
||||
import argparse, json, pathlib, subprocess, sys, time, xml.etree.ElementTree as ET
|
||||
ROOT=pathlib.Path(__file__).resolve().parents[1]
|
||||
ADB=pathlib.Path(r'C:\Users\Elijah\Desktop\platform-tools\adb.exe')
|
||||
DEVICE='192.168.50.195:5555'
|
||||
OUT=ROOT/'evidence/private'
|
||||
OUT.mkdir(parents=True,exist_ok=True)
|
||||
def adb(*args, data=None):
|
||||
p=subprocess.run([str(ADB),'-s',DEVICE,*args],input=data,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||
if p.returncode: raise RuntimeError(p.stderr.decode(errors='replace'))
|
||||
return p.stdout
|
||||
def screenshot(name):
|
||||
path=OUT/(name+'.png');path.write_bytes(adb('exec-out','screencap','-p'));print(path)
|
||||
def hierarchy():
|
||||
adb('shell','uiautomator','dump','/data/local/tmp/kaleido-window.xml')
|
||||
raw=adb('shell','cat','/data/local/tmp/kaleido-window.xml');(OUT/'window.xml').write_bytes(raw)
|
||||
root=ET.fromstring(raw)
|
||||
for n in root.iter('node'):
|
||||
if n.get('text') or n.get('focused')=='true':print({k:n.get(k) for k in ['text','content-desc','focused','bounds']})
|
||||
def seed():
|
||||
env=dict(l.strip().split('=',1) for l in (ROOT/'.env').read_text().splitlines() if '=' in l and not l.startswith('#'))
|
||||
data=json.dumps({'server':env['PLEX_SERVER_URL'].strip('\"\''),'token':env['PLEX_TOKEN'].strip('\"\'')}).encode()
|
||||
adb('shell','am','force-stop','tv.kaleido.app')
|
||||
adb('shell','run-as','tv.kaleido.app','mkdir','-p','files')
|
||||
adb('shell','run-as','tv.kaleido.app','sh','-c','"cat > files/bootstrap.json"',data=data)
|
||||
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity')
|
||||
print('Private test session provisioned. No credentials are embedded in the APK.')
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser();p.add_argument('action',choices=['seed','screenshot','hierarchy','key','launch','logs']);p.add_argument('value',nargs='?',default='screen');a=p.parse_args()
|
||||
if a.action=='seed':seed()
|
||||
if a.action=='screenshot':screenshot(a.value)
|
||||
if a.action=='hierarchy':hierarchy()
|
||||
if a.action=='key':adb('shell','input','keyevent',a.value)
|
||||
if a.action=='launch':print(adb('shell','am','start','-n','tv.kaleido.app/.MainActivity').decode())
|
||||
if a.action=='logs':
|
||||
text=adb('logcat','-d','-t','2000','KaleidoPlayback:I','AndroidRuntime:E','ExoPlayerImpl:I','*:S').decode(errors='replace');(OUT/'device.log').write_text(text);print(text[-16000:])
|
||||
Loading…
Add table
Add a link
Reference in a new issue