Release 1.1.13: fix app movement and add launcher actions
Keep the displayed app order intact until the grid reuse comparison, and retain selection during rebuilds so D-pad rearranging visibly moves the chosen tile. Add Android-confirmed uninstall for user apps and a foreground-only Wi-Fi/Ethernet shortcut with separate TV-input spacing. Remove the duplicate Personalize footer. Use an explicitly authorized replacement signing identity after loss of the original key. Document the one-time reinstall and preserve signature verification. Add a portable build using ignored signing configuration and regression checks for movement, lifecycle, native network settings, and cancel/confirm uninstall. Validated on the authorized onn 4K Plus: original failing move reproduction now passes, HomeActions/GridReuse/WakeRegression/Navigation instrumentation passes, and native settings/uninstall checks pass. Input-header availability was simulated; physical Ethernet and input switching were not exercised. Restore prior visible settings and Home override; remove the disposable test APK.
This commit is contained in:
parent
2739b278cd
commit
6a08aa242c
24 changed files with 635 additions and 79 deletions
|
|
@ -1,20 +1,4 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
TASK_ROOT="$PWD"
|
||||
export JAVA_HOME="${JAVA_HOME:-$TASK_ROOT/.tools/jdk/Contents/Home}"
|
||||
export ANDROID_HOME="${ANDROID_HOME:-$TASK_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/wake-tests/classes build/wake-tests/dex output
|
||||
"$BT/aapt2" link -o build/wake-tests/base.apk -I "$ANDROID_JAR" --manifest tests/device/AndroidManifest.xml
|
||||
javac -encoding UTF-8 -source 8 -target 8 -bootclasspath "$ANDROID_JAR:$BT/core-lambda-stubs.jar" -classpath build/classes -d build/wake-tests/classes tests/device/*.java
|
||||
find build/wake-tests/classes -name '*.class' > build/wake-tests/classes.txt
|
||||
"$BT/d8" --lib "$ANDROID_JAR" --min-api 26 --output build/wake-tests/dex @build/wake-tests/classes.txt
|
||||
cp build/wake-tests/base.apk build/wake-tests/with-dex.apk
|
||||
(cd build/wake-tests/dex && zip -q -u ../with-dex.apk classes*.dex)
|
||||
"$BT/zipalign" -f 4 build/wake-tests/with-dex.apk build/wake-tests/aligned.apk
|
||||
"$BT/apksigner" sign --ks .tools/luma-development.keystore --ks-key-alias luma --ks-pass pass:android --key-pass pass:android --out output/Luma-wake-tests.apk build/wake-tests/aligned.apk
|
||||
"$BT/apksigner" verify output/Luma-wake-tests.apk
|
||||
echo "Built $TASK_ROOT/output/Luma-wake-tests.apk"
|
||||
exec bash scripts/build.sh --tests "$@"
|
||||
|
|
|
|||
105
scripts/build.py
Normal file
105
scripts/build.py
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Build signed launcher/test APKs with a local JDK and Android SDK (including Windows)."""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import secrets
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
os.chdir(ROOT)
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--tests', action='store_true')
|
||||
p.add_argument('--create-signing-key', action='store_true', help='Explicitly create a new signing identity')
|
||||
a = p.parse_args()
|
||||
java = Path(os.environ['JAVA_HOME']) / 'bin'
|
||||
sdk = Path(os.environ['ANDROID_HOME'])
|
||||
bt = max((sdk / 'build-tools').iterdir(), key=lambda x: tuple(int(n) for n in x.name.split('.')))
|
||||
platform = max((sdk / 'platforms').glob('android-*'), key=lambda x: int(x.name.split('-')[1]))
|
||||
android = platform / 'android.jar'
|
||||
suffix = '.exe' if os.name == 'nt' else ''
|
||||
env = os.environ.copy()
|
||||
env['PATH'] = str(java) + os.pathsep + env['PATH']
|
||||
config = ROOT / '.tools/signing.json'
|
||||
key = Path(env.get('LUMA_KEYSTORE', str(ROOT / '.tools/luma-development.keystore')))
|
||||
alias = env.get('LUMA_KEY_ALIAS', 'luma')
|
||||
password = env.get('LUMA_KEYSTORE_PASSWORD')
|
||||
if not password and config.exists():
|
||||
password = json.loads(config.read_text())['password']
|
||||
if not key.exists():
|
||||
if not a.create_signing_key:
|
||||
sys.exit('Original signing key missing. Restore it; use --create-signing-key only for an authorized new identity.')
|
||||
if config.exists():
|
||||
sys.exit('Signing configuration exists but its key is missing. Restore the key before building.')
|
||||
key.parent.mkdir(parents=True, exist_ok=True)
|
||||
password = password or secrets.token_urlsafe(36)
|
||||
env['LUMA_BUILD_PASSWORD'] = password
|
||||
subprocess.run([str(java / ('keytool' + suffix)), '-genkeypair', '-keystore', str(key),
|
||||
'-storepass:env', 'LUMA_BUILD_PASSWORD', '-keypass:env', 'LUMA_BUILD_PASSWORD',
|
||||
'-alias', alias, '-keyalg', 'RSA', '-keysize', '3072', '-validity', '36500',
|
||||
'-dname', 'CN=Luma', '-noprompt'], env=env, check=True)
|
||||
config.parent.mkdir(parents=True, exist_ok=True)
|
||||
config.write_text(json.dumps({'password': password}) + '\n')
|
||||
if not password:
|
||||
sys.exit('Set LUMA_KEYSTORE_PASSWORD for the existing signing key.')
|
||||
env['LUMA_BUILD_PASSWORD'] = password
|
||||
env['AAPT2'] = str(bt / ('aapt2' + suffix))
|
||||
|
||||
def run(*args):
|
||||
subprocess.run([str(x) for x in args], env=env, check=True)
|
||||
|
||||
def jar_tool(main):
|
||||
return [java / ('java' + suffix), '-cp', bt / 'lib' / (main + '.jar')]
|
||||
|
||||
def build(test=False):
|
||||
out = ROOT / 'build' / ('device-tests' if test else 'launcher')
|
||||
if out.exists():
|
||||
shutil.rmtree(out)
|
||||
(out / 'classes').mkdir(parents=True)
|
||||
(out / 'dex').mkdir()
|
||||
(out / 'generated').mkdir()
|
||||
manifest = ROOT / ('tests/device/AndroidManifest.xml' if test else 'app/src/main/AndroidManifest.xml')
|
||||
link = [env['AAPT2'], 'link', '-o', out / 'base.apk', '-I', android, '--manifest', manifest]
|
||||
if not test:
|
||||
run(env['AAPT2'], 'compile', '--dir', ROOT / 'app/src/main/res', '-o', out / 'resources.zip')
|
||||
link += ['--java', out / 'generated', '-A', ROOT / 'app/src/main/assets',
|
||||
'--auto-add-overlay', out / 'resources.zip']
|
||||
run(*link)
|
||||
source = ROOT / ('tests/device' if test else 'app/src/main/java')
|
||||
files = list(source.rglob('*.java')) + list((out / 'generated').rglob('*.java'))
|
||||
# Java argfiles require forward slashes and quoting on Windows paths with spaces.
|
||||
(out / 'sources.txt').write_text('\n'.join('"' + x.as_posix() + '"' for x in files))
|
||||
javac = [java / ('javac' + suffix), '-encoding', 'UTF-8', '-source', '8', '-target', '8',
|
||||
'-bootclasspath', str(android) + os.pathsep + str(bt / 'core-lambda-stubs.jar'),
|
||||
'-d', out / 'classes']
|
||||
if test:
|
||||
javac += ['-classpath', ROOT / 'build/launcher/classes']
|
||||
run(*javac, '@' + str(out / 'sources.txt'))
|
||||
classes = list((out / 'classes').rglob('*.class'))
|
||||
# D8 treats each argfile line as a complete argument, including any spaces.
|
||||
(out / 'classes.txt').write_text('\n'.join(x.as_posix() for x in classes))
|
||||
run(*jar_tool('d8'), 'com.android.tools.r8.D8', '--lib', android, '--min-api', '26',
|
||||
'--output', out / 'dex', '@' + str(out / 'classes.txt'))
|
||||
with zipfile.ZipFile(out / 'base.apk') as resources, zipfile.ZipFile(
|
||||
out / 'dex.apk', 'w', compression=zipfile.ZIP_DEFLATED) as apk:
|
||||
for entry in resources.infolist():
|
||||
apk.writestr(entry, resources.read(entry.filename))
|
||||
for dex in (out / 'dex').glob('*.dex'):
|
||||
apk.write(dex, dex.name)
|
||||
run(bt / ('zipalign' + suffix), '-f', '4', out / 'dex.apk', out / 'aligned.apk')
|
||||
result = ROOT / 'output' / ('Luma-wake-tests.apk' if test else 'Luma.apk')
|
||||
result.parent.mkdir(exist_ok=True)
|
||||
run(*jar_tool('apksigner'), 'com.android.apksigner.ApkSignerTool', 'sign', '--ks', key,
|
||||
'--ks-key-alias', alias, '--ks-pass', 'env:LUMA_BUILD_PASSWORD',
|
||||
'--key-pass', 'env:LUMA_BUILD_PASSWORD', '--out', result, out / 'aligned.apk')
|
||||
run(*jar_tool('apksigner'), 'com.android.apksigner.ApkSignerTool', 'verify', result)
|
||||
print('Built ' + str(result), flush=True)
|
||||
|
||||
build()
|
||||
run(sys.executable, ROOT / 'scripts/make-update-manifest.py')
|
||||
if a.tests:
|
||||
build(True)
|
||||
|
|
@ -1,27 +1,6 @@
|
|||
#!/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
|
||||
python3 scripts/make-update-manifest.py
|
||||
echo "Built $ROOT/output/Luma.apk"
|
||||
export JAVA_HOME="${JAVA_HOME:-$PWD/.tools/jdk/Contents/Home}"
|
||||
export ANDROID_HOME="${ANDROID_HOME:-$PWD/.tools/sdk}"
|
||||
exec python3 scripts/build.py "$@"
|
||||
|
|
|
|||
46
scripts/check-app-move.py
Normal file
46
scripts/check-app-move.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"""Exercise remote move entry and one arrow; Back restores the original order."""
|
||||
import argparse
|
||||
import subprocess
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--adb', required=True)
|
||||
p.add_argument('--device', required=True)
|
||||
a = p.parse_args()
|
||||
|
||||
def adb(*args):
|
||||
return subprocess.check_output([a.adb, '-s', a.device, *map(str, args)]).decode('utf-8')
|
||||
|
||||
def key(k, long=False):
|
||||
adb('shell', 'input', 'keyevent', *(['--longpress'] if long else []), k)
|
||||
time.sleep(.3)
|
||||
|
||||
def tree():
|
||||
adb('shell', 'uiautomator', 'dump', '/sdcard/luma-move.xml')
|
||||
return ET.fromstring(adb('shell', 'cat', '/sdcard/luma-move.xml'))
|
||||
|
||||
def apps():
|
||||
return [n.get('content-desc') for n in tree().iter('node')
|
||||
if n.get('long-clickable') == 'true' and n.get('content-desc')]
|
||||
|
||||
adb('shell', 'am', 'start', '-W', '-n', 'tv.luma.launcher/.MainActivity')
|
||||
key(4)
|
||||
key(19)
|
||||
key(20)
|
||||
before = apps()
|
||||
assert len(before) >= 2, before
|
||||
key(23, True)
|
||||
for _ in range(2):
|
||||
key(20)
|
||||
focused = next(n.get('text') for n in tree().iter('node') if n.get('focused') == 'true')
|
||||
assert focused.startswith('Move in grid'), focused
|
||||
key(23)
|
||||
try:
|
||||
key(22)
|
||||
after = apps()
|
||||
assert after[:2] == [before[1], before[0]], f'Arrow did not move app: before={before[:3]}, after={after[:3]}'
|
||||
print('PASS: remote menu -> move -> right swaps the first two apps')
|
||||
finally:
|
||||
key(4)
|
||||
assert apps()[:2] == before[:2], 'Back did not restore original order'
|
||||
80
scripts/check-home-actions.py
Normal file
80
scripts/check-home-actions.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
"""Real network-settings and disposable-test-app uninstall checks. Run after instrumentation."""
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--adb', required=True)
|
||||
p.add_argument('--device', required=True)
|
||||
a = p.parse_args()
|
||||
|
||||
def adb(*args):
|
||||
return subprocess.check_output([a.adb, '-s', a.device, *map(str, args)]).decode('utf-8')
|
||||
|
||||
def key(k):
|
||||
adb('shell', 'input', 'keyevent', k)
|
||||
time.sleep(.4)
|
||||
|
||||
def tree():
|
||||
adb('shell', 'uiautomator', 'dump', '/sdcard/luma-actions.xml')
|
||||
return ET.fromstring(adb('shell', 'cat', '/sdcard/luma-actions.xml'))
|
||||
|
||||
def tap(label, description=False):
|
||||
for _ in range(8):
|
||||
for n in tree().iter('node'):
|
||||
value = n.get('content-desc' if description else 'text', '')
|
||||
if (label in value if description else value.split('\n')[0] == label):
|
||||
x, y, right, bottom = map(int, re.findall(r'\d+', n.get('bounds')))
|
||||
if bottom - y < 30:
|
||||
continue
|
||||
adb('shell', 'input', 'tap', (x + right) // 2, (y + bottom) // 2)
|
||||
time.sleep(.5)
|
||||
return
|
||||
adb('shell', 'input', 'swipe', 1200, 850, 1200, 400, 300)
|
||||
raise AssertionError('Missing control: ' + label)
|
||||
|
||||
def package_present():
|
||||
return 'package:tv.luma.launcher.tests' in adb(
|
||||
'shell', 'pm', 'list', 'packages', '--user', user, 'tv.luma.launcher.tests').splitlines()
|
||||
|
||||
def uninstall_menu():
|
||||
key(82)
|
||||
tap('App library')
|
||||
tap('Luma test app')
|
||||
tap('Uninstall app')
|
||||
nodes = list(tree().iter('node'))
|
||||
assert any(n.get('package') == 'com.google.android.packageinstaller' or
|
||||
'packageinstaller' in n.get('package', '') for n in nodes), 'No Android confirmation'
|
||||
assert any('Luma test app' in n.get('text', '') for n in nodes), 'Wrong uninstall target'
|
||||
|
||||
user = adb('shell', 'am', 'get-current-user').strip()
|
||||
adb('shell', 'am', 'start', '-W', '-n', 'tv.luma.launcher/.MainActivity')
|
||||
key(4)
|
||||
tap('Open network settings', True)
|
||||
nodes = list(tree().iter('node'))
|
||||
assert any('Network' in n.get('text', '') or 'Wi-Fi' in n.get('text', '') for n in nodes), 'Network page missing'
|
||||
assert any(n.get('package') == 'com.android.tv.settings' for n in nodes), 'Not native TV settings'
|
||||
print('PASS: network status opens native TV network settings', flush=True)
|
||||
key(4)
|
||||
adb('shell', 'am', 'start', '-W', '-n', 'tv.luma.launcher/.MainActivity')
|
||||
assert package_present(), 'Install Luma-wake-tests.apk before this check'
|
||||
uninstall_menu()
|
||||
key(4)
|
||||
assert package_present(), 'Cancel removed test app'
|
||||
print('PASS: canceling Android confirmation preserves the app', flush=True)
|
||||
adb('shell', 'am', 'start', '-W', '-n', 'tv.luma.launcher/.MainActivity')
|
||||
uninstall_menu()
|
||||
tap('OK')
|
||||
for _ in range(15):
|
||||
if not package_present():
|
||||
break
|
||||
time.sleep(.3)
|
||||
assert not package_present(), 'Confirmed uninstall failed'
|
||||
adb('shell', 'am', 'start', '-W', '-n', 'tv.luma.launcher/.MainActivity')
|
||||
key(82)
|
||||
tap('App library')
|
||||
assert not any(n.get('text', '').startswith('Luma test app') for n in tree().iter('node')), 'Removed app remains in library'
|
||||
key(4)
|
||||
print('PASS: confirmed uninstall removes disposable app and refreshes Luma library', flush=True)
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
"""Generate the small feed committed beside the signed APK; URLs resolve inside one Git commit."""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import xml.etree.ElementTree as ET
|
||||
|
|
@ -13,7 +14,7 @@ manifest = ET.parse(root / 'app/src/main/AndroidManifest.xml').getroot()
|
|||
code = int(manifest.get(ns + 'versionCode'))
|
||||
name = manifest.get(ns + 'versionName')
|
||||
apk = root / 'output/Luma.apk'
|
||||
badging = subprocess.check_output([str(root / '.tools/sdk/build-tools/34.0.0/aapt2'), 'dump', 'badging', str(apk)], text=True)
|
||||
badging = subprocess.check_output([os.environ.get('AAPT2', str(root / '.tools/sdk/build-tools/34.0.0/aapt2')), 'dump', 'badging', str(apk)], text=True)
|
||||
assert f"versionCode='{code}'" in badging and f"versionName='{name}'" in badging, 'Rebuild the APK before generating its update manifest'
|
||||
gradle = (root / 'app/build.gradle').read_text()
|
||||
assert re.search(r'versionCode\s+' + str(code) + r'\b', gradle), 'Manifest and Gradle version codes differ'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue