first commit
This commit is contained in:
commit
f5f1c0928f
39 changed files with 4478 additions and 0 deletions
30
scripts/bootstrap.sh
Executable file
30
scripts/bootstrap.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
if [ "$(uname -s)" != Darwin ]; then
|
||||
echo 'This bootstrap script targets macOS. On other platforms install JDK 17 and Android SDK 34, then set JAVA_HOME and ANDROID_HOME.' >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p .tools/sdk/cmdline-tools .tools/jdk
|
||||
if [ ! -x .tools/jdk/Contents/Home/bin/java ]; then
|
||||
ARCH=aarch64
|
||||
if [ "$(uname -m)" = x86_64 ]; then ARCH=x64; fi
|
||||
curl -L --fail "https://api.adoptium.net/v3/binary/latest/17/ga/mac/$ARCH/jdk/hotspot/normal/eclipse" -o .tools/jdk.tar.gz
|
||||
tar -xzf .tools/jdk.tar.gz -C .tools/jdk --strip-components=1
|
||||
rm .tools/jdk.tar.gz
|
||||
fi
|
||||
if [ ! -x .tools/platform-tools/adb ]; then
|
||||
curl -L --fail https://dl.google.com/android/repository/platform-tools-latest-darwin.zip -o .tools/platform-tools.zip
|
||||
unzip -q .tools/platform-tools.zip -d .tools
|
||||
rm .tools/platform-tools.zip
|
||||
fi
|
||||
if [ ! -x .tools/sdk/cmdline-tools/latest/bin/sdkmanager ]; then
|
||||
curl -L --fail https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip -o .tools/cmdline-tools.zip
|
||||
unzip -q .tools/cmdline-tools.zip -d .tools/sdk/cmdline-tools
|
||||
mv .tools/sdk/cmdline-tools/cmdline-tools .tools/sdk/cmdline-tools/latest
|
||||
rm .tools/cmdline-tools.zip
|
||||
fi
|
||||
export JAVA_HOME="$PWD/.tools/jdk/Contents/Home"
|
||||
.tools/sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root="$PWD/.tools/sdk" --licenses
|
||||
.tools/sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root="$PWD/.tools/sdk" 'platforms;android-34' 'build-tools;34.0.0'
|
||||
echo 'Toolchain ready. Run scripts/build.sh.'
|
||||
26
scripts/build.sh
Executable file
26
scripts/build.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
ROOT="$PWD"
|
||||
export JAVA_HOME="${JAVA_HOME:-$ROOT/.tools/jdk/Contents/Home}"
|
||||
export ANDROID_HOME="${ANDROID_HOME:-$ROOT/.tools/sdk}"
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
BT="$ANDROID_HOME/build-tools/34.0.0"
|
||||
ANDROID_JAR="$ANDROID_HOME/platforms/android-34/android.jar"
|
||||
mkdir -p build/classes build/dex output .tools
|
||||
rm -rf build/classes/* build/dex/*
|
||||
"$BT/aapt2" compile --dir app/src/main/res -o build/resources.zip
|
||||
"$BT/aapt2" link -o build/unsigned.apk -I "$ANDROID_JAR" --manifest app/src/main/AndroidManifest.xml --java build/generated -A app/src/main/assets --auto-add-overlay build/resources.zip
|
||||
find app/src/main/java build/generated -name '*.java' > build/sources.txt
|
||||
javac -encoding UTF-8 -source 8 -target 8 -Xlint:unchecked -bootclasspath "$ANDROID_JAR:$BT/core-lambda-stubs.jar" -d build/classes @build/sources.txt
|
||||
find build/classes -name '*.class' > build/classes.txt
|
||||
"$BT/d8" --lib "$ANDROID_JAR" --min-api 26 --output build/dex @build/classes.txt
|
||||
cp build/unsigned.apk build/with-dex.apk
|
||||
(cd build/dex && zip -q -u ../with-dex.apk classes*.dex)
|
||||
"$BT/zipalign" -f 4 build/with-dex.apk build/aligned.apk
|
||||
if [ ! -f .tools/luma-development.keystore ]; then
|
||||
keytool -genkeypair -keystore .tools/luma-development.keystore -storepass android -keypass android -alias luma -keyalg RSA -keysize 2048 -validity 10000 -dname 'CN=Luma Development' -noprompt
|
||||
fi
|
||||
"$BT/apksigner" sign --ks .tools/luma-development.keystore --ks-key-alias luma --ks-pass pass:android --key-pass pass:android --out output/Luma.apk build/aligned.apk
|
||||
"$BT/apksigner" verify output/Luma.apk
|
||||
echo "Built $ROOT/output/Luma.apk"
|
||||
325
scripts/device_smoke.py
Normal file
325
scripts/device_smoke.py
Normal file
|
|
@ -0,0 +1,325 @@
|
|||
#!/usr/bin/env python3
|
||||
"""On-device integration checks. Operates only Luma UI and launches installed apps.
|
||||
Run with the TV awake. Keeps Projectivy installed as a fallback.
|
||||
"""
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
import struct
|
||||
import statistics
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ADB = str(ROOT / '.tools/platform-tools/adb')
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--device', default='192.168.50.195:35635')
|
||||
parser.add_argument('--part', choices=['navigation', 'home-routing', 'customization', 'performance', 'plex', 'appearance-modes', 'final-defaults', 'screensaver', 'screensaver-video', 'screensaver-timeout'], default='navigation')
|
||||
args = parser.parse_args()
|
||||
|
||||
def adb(*cmd):
|
||||
r = subprocess.run([ADB, '-s', args.device, *map(str,cmd)], capture_output=True, check=True)
|
||||
return r.stdout.decode(errors='replace')
|
||||
|
||||
def key(*keys):
|
||||
adb('shell','input','keyevent',*keys)
|
||||
time.sleep(.35)
|
||||
|
||||
def tree():
|
||||
adb('shell','uiautomator','dump','/sdcard/luma-test.xml')
|
||||
return ET.fromstring(adb('shell','cat','/sdcard/luma-test.xml'))
|
||||
|
||||
def tap_text(text):
|
||||
for attempt in range(9):
|
||||
root = tree()
|
||||
for n in root.iter('node'):
|
||||
if n.get('text','').split('\n')[0] == text:
|
||||
x1,y1,x2,y2=map(int,re.findall(r'\d+',n.get('bounds')))
|
||||
if y2-y1<35: continue
|
||||
adb('shell','input','tap',(x1+x2)//2,(y1+y2)//2)
|
||||
time.sleep(.45)
|
||||
return
|
||||
adb('shell','input','swipe',1200,850,1200,380,250)
|
||||
time.sleep(.2)
|
||||
raise AssertionError('Missing control: '+text)
|
||||
|
||||
def text_exists(text):
|
||||
assert any(text in n.get('text','') for n in tree().iter('node')),text
|
||||
|
||||
def focus():
|
||||
for n in tree().iter('node'):
|
||||
if n.get('focused')=='true':
|
||||
return n.get('content-desc') or n.get('text')
|
||||
|
||||
def start():
|
||||
adb('shell','am','start','-W','-a','android.intent.action.MAIN','-c','android.intent.category.HOME','-n','tv.luma.launcher/.MainActivity')
|
||||
time.sleep(1)
|
||||
|
||||
def package():
|
||||
out=adb('shell','dumpsys','activity','activities')
|
||||
m=re.search(r'topResumedActivity=.*? u0 ([^/]+)/',out)
|
||||
return m.group(1) if m else None
|
||||
|
||||
def ok(label): print('PASS: '+label,flush=True)
|
||||
|
||||
if args.part=='navigation':
|
||||
start()
|
||||
assert package()=='tv.luma.launcher'
|
||||
ok('Luma launches directly')
|
||||
key(82);text_exists('Make it yours');key(4)
|
||||
ok('Menu opens settings; Back closes it')
|
||||
# Return to the first icon using Back and directional navigation.
|
||||
key(4);time.sleep(.4)
|
||||
start();key(19)
|
||||
assert 'settings' in focus().lower()
|
||||
key(20)
|
||||
assert focus()=='Plex',focus()
|
||||
key(22);assert focus()=='Plezy',focus()
|
||||
key(22);assert focus()=='SmartTube beta',focus()
|
||||
key(20);assert focus()=='Prime Video',focus()
|
||||
key(19);assert focus()=='SmartTube beta',focus()
|
||||
ok('D-pad moves horizontally and between app rows')
|
||||
key(23);time.sleep(2)
|
||||
assert package()=='org.smarttube.beta',package()
|
||||
ok('OK launches the selected app')
|
||||
key(3);time.sleep(2)
|
||||
assert package()=='tv.luma.launcher',package()
|
||||
ok('Home returns to Luma')
|
||||
start();key(4,4,4);time.sleep(1)
|
||||
assert package()=='tv.luma.launcher',package()
|
||||
ok('Repeated Back at home stays on Luma')
|
||||
key(20,20);key(4)
|
||||
assert focus()=='Plex',focus()
|
||||
assert package()=='tv.luma.launcher',package()
|
||||
ok('Back from lower rows returns to the first row and stays on Luma')
|
||||
start()
|
||||
|
||||
elif args.part=='home-routing':
|
||||
start();key(82);tap_text('Default launcher')
|
||||
text_exists('Home button override: On')
|
||||
tap_text('Open Projectivy');time.sleep(2)
|
||||
assert package()=='com.spocky.projengmenu',package()
|
||||
time.sleep(3)
|
||||
assert package()=='com.spocky.projengmenu',package()
|
||||
ok('Explicit Projectivy fallback remains open without a redirect loop')
|
||||
key(3);time.sleep(1)
|
||||
assert package()=='tv.luma.launcher',package()
|
||||
for _ in range(5):key(3)
|
||||
assert package()=='tv.luma.launcher',package()
|
||||
ok('Home returns from fallback and repeated Home presses stay in Luma')
|
||||
adb('shell','am','start','-a','android.settings.SETTINGS');time.sleep(1)
|
||||
assert package()!='tv.luma.launcher'
|
||||
key(3);time.sleep(1)
|
||||
assert package()=='tv.luma.launcher',package()
|
||||
ok('Home returns to Luma from Android settings')
|
||||
key(82);tap_text('Screensaver');tap_text('Preview now');time.sleep(1)
|
||||
assert any(n.get('content-desc')=='Luma screensaver' for n in tree().iter('node'))
|
||||
key(3);time.sleep(1)
|
||||
assert not any(n.get('content-desc')=='Luma screensaver' for n in tree().iter('node'))
|
||||
assert package()=='tv.luma.launcher',package()
|
||||
ok('Home dismisses the screensaver and returns to the app grid')
|
||||
assert 'LumaHomeService' in adb('shell','dumpsys','activity','services','tv.luma.launcher')
|
||||
assert 'com.spocky.projengmenu' in adb('shell','pm','list','packages','-e','com.spocky.projengmenu')
|
||||
ok('Home override is bound; Projectivy remains enabled')
|
||||
|
||||
elif args.part=='customization':
|
||||
start();key(82);tap_text('Appearance')
|
||||
tap_text('App spacing · 6 columns');tap_text('Spacious · 5 columns')
|
||||
text_exists('App spacing · 5 columns');key(4)
|
||||
# Settings Back closes the whole dialog, then reopen and restore default.
|
||||
key(82);tap_text('Appearance');tap_text('App spacing · 5 columns');tap_text('Balanced · 6 columns')
|
||||
tap_text('Wallpaper · Alpine');tap_text('Aurora · Soft teal & indigo')
|
||||
text_exists('Wallpaper · Aurora')
|
||||
key(4);key(3);time.sleep(1);start();key(82);tap_text('Appearance')
|
||||
text_exists('Wallpaper · Aurora')
|
||||
ok('Wallpaper preference persists across leaving and resuming')
|
||||
tap_text('Wallpaper · Aurora');tap_text('Alpine · Cinematic mountain light')
|
||||
tap_text('Focus animations · On');text_exists('Focus animations · Off');tap_text('Focus animations · Off')
|
||||
tap_text('Clock · On');text_exists('Clock · Off');tap_text('Clock · Off');key(4)
|
||||
ok('Spacing, wallpaper, reduced motion, and clock controls work')
|
||||
# Long press on a focused tile exposes actual app actions.
|
||||
key(19);key(20)
|
||||
adb('shell','input','keyevent','--longpress',23);time.sleep(.5)
|
||||
text_exists('Move to front');text_exists('Hide from home');key(4)
|
||||
ok('Hold OK exposes app management')
|
||||
|
||||
elif args.part=='plex':
|
||||
# Requires scripts/plex_fixture.py running on the host.
|
||||
adb('reverse','tcp:8765','tcp:8765')
|
||||
start();key(82);tap_text('Plex media rows');tap_text('Enter server manually')
|
||||
inputs=[n for n in tree().iter('node') if n.get('class')=='android.widget.EditText']
|
||||
assert len(inputs)==2
|
||||
for node,value in zip(inputs,['http://127.0.0.1:8765','luma-test-fixture']):
|
||||
x1,y1,x2,y2=map(int,re.findall(r'\d+',node.get('bounds')))
|
||||
adb('shell','input','tap',(x1+x2)//2,(y1+y2)//2)
|
||||
adb('shell','input','text',value)
|
||||
key(4)
|
||||
tap_text('Connect');time.sleep(2)
|
||||
assert package()=='tv.luma.launcher'
|
||||
# Move from app grid into optional rows.
|
||||
key(19);key(20);key(20,20,20,20)
|
||||
text_exists('Continue watching');text_exists('Alpine at dusk')
|
||||
(ROOT/'output/luma-media-fixture.png').write_bytes(subprocess.run([ADB,'-s',args.device,'exec-out','screencap','-p'],capture_output=True,check=True).stdout)
|
||||
ok('Plex connection, encrypted credential storage, Continue Watching, and artwork rendering')
|
||||
# Open settings and ensure fixture credentials are removed before finishing.
|
||||
key(82);tap_text('Plex media rows');tap_text('Disconnect Plex')
|
||||
text_exists('Media rows · Off')
|
||||
key(4);key(4)
|
||||
adb('reverse','--remove','tcp:8765')
|
||||
ok('Disconnect clears test connection and disables media rows')
|
||||
|
||||
elif args.part=='appearance-modes':
|
||||
start();key(82);tap_text('Appearance')
|
||||
nodes=list(tree().iter('node'))
|
||||
label_control=next(n.get('text').split('\n')[0] for n in nodes if n.get('text','').startswith('App labels · '))
|
||||
if label_control!='App labels · Focused only':
|
||||
tap_text(label_control);tap_text('Focused only')
|
||||
tap_text('Banner · Artwork only');tap_text('Dynamic')
|
||||
text_exists('Banner · Dynamic');key(4)
|
||||
assert any('Your library.' in n.get('text','') for n in tree().iter('node'))
|
||||
key(82);tap_text('Appearance');tap_text('Banner · Dynamic');tap_text('Minimal')
|
||||
text_exists('Banner · Minimal');key(4)
|
||||
nodes=list(tree().iter('node'))
|
||||
first=next(n for n in nodes if n.get('content-desc')=='Plex' and n.get('focusable')=='true')
|
||||
assert int(re.findall(r'\d+',first.get('bounds'))[1]) < 250
|
||||
key(82);tap_text('Appearance');tap_text('Banner · Minimal');tap_text('Artwork only')
|
||||
tap_text('App labels · Focused only');tap_text('Always')
|
||||
text_exists('App labels · Always');key(4)
|
||||
assert any(n.get('text')=='Plezy' for n in tree().iter('node'))
|
||||
key(82);tap_text('Appearance');tap_text('App labels · Always');tap_text('Never')
|
||||
text_exists('App labels · Never');key(4)
|
||||
assert not any(n.get('text')=='Plex' for n in tree().iter('node'))
|
||||
key(82);tap_text('Appearance');tap_text('App labels · Never');tap_text('Focused only');key(4);key(19,19,20)
|
||||
nodes=list(tree().iter('node'))
|
||||
assert any(n.get('text')=='Plex' for n in nodes)
|
||||
assert not any(n.get('text')=='Plezy' for n in nodes)
|
||||
assert not any('Your library.' in n.get('text','') for n in nodes)
|
||||
# Original spacious layout: first full row and a partial second row.
|
||||
first=next(n for n in nodes if n.get('content-desc')=='Plex' and n.get('focusable')=='true')
|
||||
assert int(re.findall(r'\d+',first.get('bounds'))[1]) >= 650
|
||||
key(3);time.sleep(1);start();key(82);tap_text('Appearance')
|
||||
text_exists('Banner · Artwork only');text_exists('App labels · Focused only');key(4)
|
||||
ok('All banner and label modes work; original spacious layout and clean defaults persist')
|
||||
|
||||
elif args.part=='final-defaults':
|
||||
start();key(82);tap_text('Appearance')
|
||||
text_exists('Banner · Artwork only');text_exists('App labels · Focused only');key(4);key(19,19,20)
|
||||
nodes=list(tree().iter('node'))
|
||||
assert not any('Your library.' in n.get('text','') for n in nodes)
|
||||
assert any(n.get('text')=='Plex' for n in nodes)
|
||||
assert not any(n.get('text')=='Plezy' for n in nodes)
|
||||
first=next(n for n in nodes if n.get('content-desc')=='Plex' and n.get('focusable')=='true')
|
||||
assert first.get('focused')=='true'
|
||||
assert int(re.findall(r'\d+',first.get('bounds'))[1]) >= 650
|
||||
ok('Artwork only, Focused only labels, and original spacious layout are active')
|
||||
|
||||
elif args.part=='screensaver':
|
||||
adb('shell','am','force-stop','tv.luma.launcher')
|
||||
start();key(82);tap_text('Screensaver')
|
||||
nodes=list(tree().iter('node'))
|
||||
mode_control=next(n.get('text') for n in nodes if n.get('text','').startswith('Mode · '))
|
||||
tap_text(mode_control);tap_text('Art gallery')
|
||||
nodes=list(tree().iter('node'))
|
||||
interval_control=next(n.get('text') for n in nodes if n.get('text','').startswith('Photo duration · '))
|
||||
tap_text(interval_control);tap_text('15 sec')
|
||||
tap_text('Preview now');time.sleep(2)
|
||||
nodes=list(tree().iter('node'))
|
||||
assert any(n.get('content-desc')=='Luma screensaver' for n in nodes)
|
||||
titles=['Wheat Field with Cypresses','The Great Wave','The Death of Socrates']
|
||||
seen=[]
|
||||
for index in range(3):
|
||||
nodes=list(tree().iter('node'))
|
||||
seen.append(next(n.get('text') for n in nodes if n.get('text') in titles))
|
||||
path=ROOT/f'output/luma-art-{index}.png'
|
||||
path.write_bytes(subprocess.run([ADB,'-s',args.device,'exec-out','screencap','-p'],capture_output=True,check=True).stdout)
|
||||
bmp=Path('/tmp/luma-frame-check.bmp')
|
||||
subprocess.run(['sips','-z','64','112','-s','format','bmp',str(path),'--out',str(bmp)],stdout=subprocess.DEVNULL,check=True)
|
||||
data=bmp.read_bytes();offset=struct.unpack_from('<I',data,10)[0]
|
||||
width,height=struct.unpack_from('<ii',data,18);bits=struct.unpack_from('<H',data,28)[0]
|
||||
assert bits==32
|
||||
rowbytes=width*4
|
||||
def rgb(x,y):
|
||||
yy=y if height<0 else abs(height)-1-y
|
||||
b,g,r,_=data[offset+yy*rowbytes+x*4:offset+yy*rowbytes+x*4+4]
|
||||
return r,g,b
|
||||
luminance=[sum(rgb(x,y))/3 for y in range(8,42) for x in range(22,90)]
|
||||
assert statistics.pstdev(luminance)>8,('Blank artwork frame',seen[-1])
|
||||
assert max(rgb(0,5))<=2,('Matte is not black',rgb(0,5))
|
||||
if index<2:
|
||||
for _ in range(10):
|
||||
time.sleep(2)
|
||||
next_nodes=list(tree().iter('node'))
|
||||
next_title=next((n.get('text') for n in next_nodes if n.get('text') in titles),None)
|
||||
if next_title and next_title!=seen[-1]:break
|
||||
assert len(set(seen))==3,seen
|
||||
ok('All three artwork images render, crossfade, and use pure-black mattes')
|
||||
key(20)
|
||||
assert not any(n.get('content-desc')=='Luma screensaver' for n in tree().iter('node'))
|
||||
assert package()=='tv.luma.launcher'
|
||||
key(82);tap_text('Screensaver');tap_text('Mode · Art gallery');tap_text('Scenic')
|
||||
tap_text('Photo duration · 15 sec');tap_text('30 sec');tap_text('Preview now');time.sleep(2)
|
||||
assert any(n.get('content-desc')=='Luma screensaver' for n in tree().iter('node'))
|
||||
(ROOT/'output/luma-scenic-screensaver.png').write_bytes(subprocess.run([ADB,'-s',args.device,'exec-out','screencap','-p'],capture_output=True,check=True).stdout)
|
||||
key(23)
|
||||
ok('Scenic preview works; D-pad and OK wake without launching an app')
|
||||
|
||||
elif args.part=='screensaver-video':
|
||||
start();key(82);tap_text('Screensaver');tap_text('Nature video');tap_text('Download bird nature loop')
|
||||
for _ in range(24):
|
||||
time.sleep(2)
|
||||
nodes=list(tree().iter('node'))
|
||||
if any(n.get('text')=='Screensaver' for n in nodes):break
|
||||
error=next((n.get('text') for n in nodes if n.get('text','').startswith('Download stopped.')),None)
|
||||
assert error is None,error
|
||||
text_exists('Mode · Nature video');tap_text('Preview now');time.sleep(4)
|
||||
nodes=list(tree().iter('node'))
|
||||
assert any(n.get('content-desc')=='Luma screensaver' for n in nodes)
|
||||
assert any(n.get('text')=='Nature loop' for n in nodes)
|
||||
(ROOT/'output/luma-nature-screensaver.png').write_bytes(subprocess.run([ADB,'-s',args.device,'exec-out','screencap','-p'],capture_output=True,check=True).stdout)
|
||||
ok('NPS nature video downloads locally and plays in the screensaver')
|
||||
key(3);time.sleep(3)
|
||||
assert package()=='tv.luma.launcher'
|
||||
start();key(82);tap_text('Screensaver');tap_text('Mode · Nature video');tap_text('Scenic');key(4);key(19,19,20)
|
||||
ok('Home exits video to Luma; scenic mode restored and local video retained for use')
|
||||
|
||||
elif args.part=='screensaver-timeout':
|
||||
start();key(82);tap_text('Screensaver');tap_text('Idle timeout · 10 min');tap_text('1 min');key(4)
|
||||
print('Waiting for the 1 minute idle timeout…',flush=True)
|
||||
time.sleep(63)
|
||||
assert any(n.get('content-desc')=='Luma screensaver' for n in tree().iter('node'))
|
||||
key(20);key(82);tap_text('Screensaver');tap_text('Idle timeout · 1 min');tap_text('10 min');key(4);key(19,19,20)
|
||||
ok('Real 1 minute idle activation works; 10 minute default restored')
|
||||
|
||||
elif args.part=='performance':
|
||||
start();key(20,20,20,20)
|
||||
assert focus()=='All apps',focus()
|
||||
key(19,19,19,19)
|
||||
assert focus()=='Plex',focus()
|
||||
ok('Focus scrolls through all rows to the footer and back')
|
||||
adb('shell','dumpsys','gfxinfo','tv.luma.launcher','reset')
|
||||
for _ in range(4):key(22,22,20,21,21,19)
|
||||
(ROOT/'output/luma-focus-frames.txt').write_text(adb('shell','dumpsys','gfxinfo','tv.luma.launcher'))
|
||||
time.sleep(2)
|
||||
(ROOT/'output/luma-foreground-memory.txt').write_text(adb('shell','dumpsys','meminfo','tv.luma.launcher'))
|
||||
adb('shell','am','start','-a','android.settings.SETTINGS');time.sleep(12)
|
||||
pid=adb('shell','pidof','tv.luma.launcher').strip()
|
||||
first=adb('shell','cat',f'/proc/{pid}/stat').split()
|
||||
time.sleep(10)
|
||||
second=adb('shell','cat',f'/proc/{pid}/stat').split()
|
||||
ticks=sum(int(second[i])-int(first[i]) for i in [13,14])
|
||||
assert ticks==0, f'Background CPU ticks: {ticks}'
|
||||
ok('Zero background CPU ticks over a 10 second sample')
|
||||
services=adb('shell','dumpsys','activity','services','tv.luma.launcher')
|
||||
assert 'LumaHomeService' in services and 'LumaDreamService' not in services
|
||||
router_pid=adb('shell','pidof','tv.luma.launcher:home').strip()
|
||||
first=adb('shell','cat',f'/proc/{router_pid}/stat').split()
|
||||
time.sleep(10)
|
||||
second=adb('shell','cat',f'/proc/{router_pid}/stat').split()
|
||||
router_ticks=sum(int(second[i])-int(first[i]) for i in [13,14])
|
||||
assert router_ticks==0, f'Idle Home router CPU ticks: {router_ticks}'
|
||||
(ROOT/'output/luma-home-router-memory.txt').write_text(adb('shell','dumpsys','meminfo',router_pid))
|
||||
(ROOT/'output/luma-background-memory.txt').write_text(adb('shell','dumpsys','meminfo','tv.luma.launcher'))
|
||||
(ROOT/'output/luma-background-cpu.txt').write_text(f'Launcher background CPU ticks in 10 seconds: {ticks}\nHome router idle CPU ticks in 10 seconds: {router_ticks}\n'+services)
|
||||
ok('Only the separate Home router service is bound; zero idle CPU ticks over 10 seconds')
|
||||
start()
|
||||
35
scripts/plex_fixture.py
Normal file
35
scripts/plex_fixture.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Local integration fixture, never used by the shipping launcher.
|
||||
Serve on loopback and use `adb reverse tcp:8765 tcp:8765` for TV integration QA.
|
||||
"""
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
ART = Path(__file__).resolve().parents[1]/'app/src/main/assets/alpine.jpg'
|
||||
|
||||
class Fixture(BaseHTTPRequestHandler):
|
||||
def log_message(self, *args): pass
|
||||
def do_GET(self):
|
||||
if self.headers.get('X-Plex-Token') != 'luma-test-fixture':
|
||||
self.send_response(401); self.end_headers(); return
|
||||
if self.path.startswith('/photo/'):
|
||||
data=ART.read_bytes(); mime='image/jpeg'
|
||||
elif self.path.startswith('/hubs'):
|
||||
def item(key,title,progress=0):
|
||||
return dict(ratingKey=str(key), title=title, type='movie', year=2026,
|
||||
duration=600000, viewOffset=progress, art='/library/art/alpine',
|
||||
summary='Local integration test artwork. Not connected to a real Plex library.')
|
||||
data=json.dumps({'MediaContainer':{'Hub':[
|
||||
{'hubIdentifier':'home.continueWatching', 'title':'Continue Watching',
|
||||
'Metadata':[item(1,'Alpine at dusk',240000),item(2,'The quiet shore',80000)]},
|
||||
{'hubIdentifier':'movie.recentlyAdded', 'title':'Recently Added',
|
||||
'Metadata':[item(3,'Beyond the ridge'),item(4,'Blue hour')]}
|
||||
]}}).encode(); mime='application/json'
|
||||
else:
|
||||
data=json.dumps({'MediaContainer':{'machineIdentifier':'luma-local-fixture'}}).encode();mime='application/json'
|
||||
self.send_response(200);self.send_header('Content-Type',mime);self.send_header('Content-Length',str(len(data)));self.end_headers();self.wfile.write(data)
|
||||
|
||||
if __name__=='__main__':
|
||||
print('Plex test fixture on 127.0.0.1:8765',flush=True)
|
||||
HTTPServer(('127.0.0.1',8765),Fixture).serve_forever()
|
||||
Loading…
Add table
Add a link
Reference in a new issue