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:
Elijah 2026-10-25 12:08:46 -07:00
parent 2739b278cd
commit 6a08aa242c
24 changed files with 635 additions and 79 deletions

1
.gitignore vendored
View file

@ -13,3 +13,4 @@ output/*.log
output/wake-before/
output/Luma-wake-tests.apk*
output/performance/
output/private/

View file

@ -23,3 +23,11 @@ Follow Android and Android TV best practices. Keep Luma portable across current
- Preserve D-pad navigation, accessibility, focus visibility, smooth scrolling, and lifecycle recovery. Test meaningful failure and recovery cases for changes affecting rendering, persistence, updates, or background work.
- Do not ship a claimed performance improvement based only on an isolated microbenchmark. Compare normal and rapid navigation on both available devices and disclose material tradeoffs or untested cases.
- Review the final diff for hardcoded device assumptions and secrets before committing. Document relevant behavior, settings, and validation alongside the change.
## Build and release
- Set `JAVA_HOME` (JDK 17) and `ANDROID_HOME` (Android SDK), then run `python scripts/build.py --tests`. On macOS/Linux `bash scripts/build.sh --tests` wraps the same build. Run device tests serially, with an explicit ADB serial; restore preferences and remove the test APK afterward.
- Version both `app/build.gradle` and `app/src/main/AndroidManifest.xml`, edit `docs/UPDATE_NOTES.md`, build, and commit **both** `output/Luma.apk` and `output/update.json` with source/docs to `main`. Push `main`, then verify the public feed and downloaded APK checksum. This branch feed is the release mechanism; no separate release upload is required.
- Signing uses ignored `.tools/luma-development.keystore` and `.tools/signing.json`, or `LUMA_KEYSTORE`, `LUMA_KEY_ALIAS`, and `LUMA_KEYSTORE_PASSWORD`. Back up the key and local signing configuration securely. Never regenerate them to fix a routine build failure.
- Version 1.1.13 intentionally begins a new signing identity after the old key was lost and replacement was authorized. Versions through 1.1.12 require a one-time uninstall/reinstall, which resets app data. Keep signature verification enabled; later releases must reuse the replacement key.
- Move mode must compare the actual displayed order with the requested order before rebuilding; do not mutate `visibleApps` before the reuse check. Keep selection stable while focused children are replaced. `HomeActionsInstrumentation` covers remote movement/save/cancel, network lifecycle, and simulated input-header layout.

View file

@ -2,7 +2,9 @@
A native, remote-first Android TV launcher designed for limited-memory streamers and integrated TVs. Its package name is `tv.luma.launcher`.
Version **1.1.12** removes obsolete alternate-launcher integration, avoids redundant screen-on window updates during navigation, and waits for focus to settle before transitioning app background colors. Every resume restores missing images, including when Android briefly pauses the launcher without stopping it. Leaving the launcher releases image memory. Updates can be installed directly from the TV; physical-input controls appear on compatible TVs.
Version **1.1.13** fixes D-pad app rearranging, adds uninstall to the app menu and a network status shortcut beside Settings, and removes the duplicate Personalize footer button. Physical-input controls have their own space on compatible TVs.
**One-time reinstall required:** the original signing key was lost. This release uses an authorized replacement key, so Android cannot install it over versions through 1.1.12. Uninstall the old Luma and install this APK; Luma settings and Plex credentials reset. Subsequent updates use the replacement key normally. Update signature verification remains enabled.
## Use it
@ -13,10 +15,11 @@ Press **Home** after configuring Home routing, or open **Luma** from Android's a
```
- D-pad navigates the installed app grid; OK opens an app.
- Hold OK on an app to move it, move it to the front, hide it, or open Android app info.
- Hold OK on an app to move it, move it to the front, hide it, uninstall it, or open Android app info. Uninstall is available for user-installed apps and opens Android's confirmation screen; system apps retain app info.
- In move mode, arrows move the app; OK saves and Back restores the previous order.
- Menu or the gear opens Luma settings. **All apps** includes hidden apps so they can be restored.
- Back scrolls to the first row and stays on Luma. Home returns to Luma.
- The network icon beside Settings opens network settings. It shows Wi-Fi or Ethernet for the active connection, muted when disconnected and gold when Android has not validated internet access. Its accessibility label describes the state. It uses a callback only while Home is foreground, without scans, location permission, or polling. Unsupported network-settings screens fall back to wireless settings and then general settings.
## Default launcher and Home routing
@ -91,10 +94,10 @@ No SSH key or Forgejo account token is stored on the TV. For branch-based Forgej
### Publish an update
1. Increase `versionCode` and `versionName` in both `app/src/main/AndroidManifest.xml` and `app/build.gradle`. Every published update needs a greater version code.
2. Edit `docs/UPDATE_NOTES.md`, then run `scripts/build.sh` using the existing signing keystore. The build generates `output/Luma.apk` and `output/update.json` together, including the APK checksum and size.
2. Edit `docs/UPDATE_NOTES.md`, then run `python scripts/build.py` (or `bash scripts/build.sh`) using the existing signing keystore. Set `JAVA_HOME` and `ANDROID_HOME`. The build generates `output/Luma.apk` and `output/update.json` together, including the APK checksum and size.
3. Commit and push the source changes, **both output files**, and release notes to `main`. The next scheduled/manual check on each TV discovers the update. No separate release upload or account setup is needed.
Preserve `.tools/luma-development.keystore` separately from Git: the same signing key is required for every update. The first updater-capable APK must be installed on each TV once, through ADB, Downloader, or a file manager; later updates can be handled within Luma.
Preserve `.tools/luma-development.keystore` and `.tools/signing.json` securely outside Git: the same signing key and password are required for every update. The first APK using the replacement identity must be installed on each TV once, through ADB, Downloader, or a file manager; later updates can be handled within Luma.
Android scheduling and installation behavior follow the [JobInfo API](https://developer.android.com/reference/android/app/job/JobInfo.Builder) and [package installation API](https://developer.android.com/reference/android/content/pm/PackageManager#canRequestPackageInstalls()).
@ -117,16 +120,16 @@ Measurements are in [docs/VALIDATION.md](docs/VALIDATION.md). PSS includes Andro
The signed APK is [output/Luma.apk](output/Luma.apk). Source is in `app/src/main/java/tv/luma/launcher`.
The current workspace already contains a local JDK 17 and Android SDK under `.tools`. Rebuild without Gradle:
Rebuild without Gradle using Python 3, JDK 17, and an Android SDK with platform/build tools 34 or newer. Set `JAVA_HOME` and `ANDROID_HOME` to those installations. On the current Windows checkout they are `.tools/jdk` and `.tools/sdk`:
```sh
bash scripts/build.sh
.tools/platform-tools/adb -s 192.168.50.195:35635 install -r output/Luma.apk
python scripts/build.py --tests
adb -s "$LUMA_ADB_DEVICE" install -r output/Luma.apk
```
For a fresh macOS checkout, run `scripts/bootstrap.sh`, review/accept the SDK licenses, then build. Alternatively use the included Gradle project with JDK 17, Gradle 8.7 and Android SDK 34. No third-party app dependencies are needed.
The local build creates and reuses `.tools/luma-development.keystore`. Preserve that file to install future updates over the existing APK. It is ignored by source control. This is a development signing identity for your sideloaded build; configure your own signing identity before distributing it.
The build reuses `.tools/luma-development.keystore` with the password in ignored `.tools/signing.json`. Alternatively set `LUMA_KEYSTORE`, `LUMA_KEY_ALIAS`, and `LUMA_KEYSTORE_PASSWORD`. It refuses to generate a missing key unless explicitly run with `--create-signing-key`; that option is only for an intentionally new identity and requires reinstalling existing copies. Passwords are passed to signing tools through environment variables.
To remove Luma, run `adb uninstall tv.luma.launcher`. No command in the build/install scripts disables another launcher or changes the default Home app.
@ -149,9 +152,9 @@ The wake regression uses a separate test APK signed with the same development ke
```sh
bash scripts/build-wake-tests.sh
.tools/platform-tools/adb -s 192.168.50.195:35635 install -r output/Luma-wake-tests.apk
.tools/platform-tools/adb -s 192.168.50.195:35635 shell am instrument -w -r tv.luma.launcher.tests/.WakeRegressionInstrumentation
.tools/platform-tools/adb -s 192.168.50.195:35635 uninstall tv.luma.launcher.tests
adb -s "$LUMA_ADB_DEVICE" install -r output/Luma-wake-tests.apk
adb -s "$LUMA_ADB_DEVICE" shell am instrument -w -r tv.luma.launcher.tests/.WakeRegressionInstrumentation
adb -s "$LUMA_ADB_DEVICE" uninstall tv.luma.launcher.tests
```
Successful output ends with `INSTRUMENTATION_CODE: -1` and PASS lines for all cases. The runner controls activity lifecycle callbacks and should be run with no other device tests in progress.
@ -159,6 +162,8 @@ Android force-stops the target package during instrumentation and can mark its a
The `.AccentSchedulingInstrumentation` runner verifies focus-color coalescing, the final selected color, pause cancellation, resume recovery, and immediate reduced-motion updates in both rendering modes.
The `tv.luma.launcher.HomeActionsInstrumentation` runner checks the actual remote menu and all four move directions, focus, boundary clamping, save/cancel, saved order after resume, callback cleanup/recovery, and header spacing/focus with simulated physical-input availability. Run `scripts/check-app-move.py --adb <adb-path> --device <serial>` for the original UI reproduction. After instrumentation, `scripts/check-home-actions.py` checks the native network page and both canceling and confirming an uninstall of the disposable **Luma test app**; it removes that test APK as part of its check. These scripts do not uninstall user apps.
Additional runners in the same test APK check real GPU pixels (`.TileRenderingInstrumentation`, `.RenderingInstrumentation`) and normal/rapid D-pad navigation without spawning an input process per key (`.NavigationInstrumentation`). Pass `-e memorySaver true` to the wake or navigation runner to exercise the optional mode; the runner restores its preference afterward.
The same test APK also includes `tv.luma.launcher.tests/.PerformanceInstrumentation` for the background/shadow A/B benchmark. It changes only runtime view state and writes a temporary `performance.txt` in Luma's external-files directory. Reopen Luma afterward and remove the diagnostic APK.

View file

@ -6,8 +6,8 @@ android {
applicationId 'tv.luma.launcher'
minSdk 26
targetSdk 34
versionCode 15
versionName '1.1.12'
versionCode 16
versionName '1.1.13'
}
compileOptions { sourceCompatibility JavaVersion.VERSION_1_8; targetCompatibility JavaVersion.VERSION_1_8 }
}

View file

@ -1,10 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tv.luma.launcher" android:versionCode="15" android:versionName="1.1.12">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tv.luma.launcher" android:versionCode="16" android:versionName="1.1.13">
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="34" />
<uses-feature android:name="android.software.leanback" android:required="true" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<queries>

View file

@ -25,7 +25,8 @@ public final class MainActivity extends Activity {
private LinearLayout content, appsContainer, mediaContainer, hero, sectionHeading;
private PlexClient.Media plexFeatured;
private TextView clock, eyebrow, headline, description, openHint, appCount, settingsButton;
private ImageButton inputButton;
private ImageButton inputButton, networkButton;
private NetworkStatus networkStatus;
private TvInputs tvInputs;
private List<TvInputs.Source> inputSources = Collections.emptyList();
private volatile int inputGeneration;
@ -97,6 +98,7 @@ public final class MainActivity extends Activity {
getWindow().getDecorView().setSystemUiVisibility(5894);
getWindow().setNavigationBarColor(Ui.BG);
buildShell();
networkStatus = new NetworkStatus(this, networkButton, handler);
}
private int d(float n) {
@ -183,11 +185,25 @@ public final class MainActivity extends Activity {
LinearLayout.LayoutParams inputLp = new LinearLayout.LayoutParams(d(39), d(34));
inputLp.leftMargin = d(17);
header.addView(inputButton, inputLp);
networkButton = new ImageButton(this);
networkButton.setImageResource(R.drawable.ic_wifi_off);
networkButton.setImageTintList(Ui.textColors());
networkButton.setPadding(d(9), d(7), d(9), d(7));
networkButton.setFocusable(true);
networkButton.setContentDescription("Network status · Open network settings");
networkButton.setId(View.generateViewId());
Ui.glass(networkButton, 18);
networkButton.setOnClickListener(v -> openNetworkSettings());
LinearLayout.LayoutParams networkLp = new LinearLayout.LayoutParams(d(39), d(34));
networkLp.leftMargin = d(17);
header.addView(networkButton, networkLp);
settingsButton = chip("⚙", v -> showSettings());
settingsButton.setTextSize(19);
settingsButton.setContentDescription("Luma settings");
settingsButton.setId(View.generateViewId());
inputButton.setNextFocusRightId(settingsButton.getId());
inputButton.setNextFocusRightId(networkButton.getId());
networkButton.setNextFocusRightId(settingsButton.getId());
settingsButton.setNextFocusLeftId(networkButton.getId());
LinearLayout.LayoutParams settingsLp = new LinearLayout.LayoutParams(d(39), d(34));
settingsLp.leftMargin = d(17);
header.addView(settingsButton, settingsLp);
@ -243,10 +259,6 @@ public final class MainActivity extends Activity {
footer.setPadding(d(4), d(24), d(4), 0);
TextView all = chip("All apps", v -> showAllApps());
footer.addView(all, new LinearLayout.LayoutParams(d(95), d(35)));
TextView customize = chip("Personalize", v -> showSettings());
LinearLayout.LayoutParams customizeLp = new LinearLayout.LayoutParams(d(112), d(35));
customizeLp.leftMargin = d(10);
footer.addView(customize, customizeLp);
content.addView(footer, new LinearLayout.LayoutParams(-1, d(66)));
setContentView(root);
configureScene();
@ -331,6 +343,7 @@ public final class MainActivity extends Activity {
protected void onResume() {
super.onResume();
foreground = true;
networkStatus.start();
tvInputs.start(
() -> {
handler.removeCallbacks(refreshInputTask);
@ -367,6 +380,7 @@ public final class MainActivity extends Activity {
protected void onPause() {
super.onPause();
foreground = false;
networkStatus.stop();
tvInputs.stop();
handler.removeCallbacks(refreshInputTask);
inputGeneration++;
@ -504,6 +518,8 @@ public final class MainActivity extends Activity {
private void renderApps() {
iconGeneration++;
// Removing focused children can focus another tile; retain the requested app across rebuilds.
String requestedSelection = selected;
List<AppRepository.App> previous = new ArrayList<>(visibleApps);
Set<String> hidden = hidden();
List<String> order = savedOrder();
@ -602,14 +618,16 @@ public final class MainActivity extends Activity {
if (!tiles.isEmpty()) {
settingsButton.setNextFocusDownId(tiles.values().iterator().next().getId());
inputButton.setNextFocusDownId(tiles.values().iterator().next().getId());
networkButton.setNextFocusDownId(tiles.values().iterator().next().getId());
}
String restore =
tiles.containsKey(selected)
? selected
tiles.containsKey(requestedSelection)
? requestedSelection
: (visibleApps.isEmpty() ? "" : visibleApps.get(0).pkg);
AppTile target = tiles.get(restore);
if (target != null) {
target.requestFocus();
selected = restore;
updateHero(findApp(restore));
if (reuse) target.post(() -> keepFocusVisible(target));
}
@ -875,15 +893,33 @@ public final class MainActivity extends Activity {
handler.post(
() -> {
if (!foreground || ticket != inputGeneration) return;
applyInputSources(sources);
});
});
}
private void applyInputSources(List<TvInputs.Source> sources) {
inputSources = sources;
boolean available = !sources.isEmpty();
if (!available && inputButton.hasFocus()) settingsButton.requestFocus();
if (!available && inputButton.hasFocus()) networkButton.requestFocus();
inputButton.setVisibility(available ? View.VISIBLE : View.GONE);
settingsButton.setNextFocusLeftId(available ? inputButton.getId() : View.NO_ID);
networkButton.setNextFocusLeftId(available ? inputButton.getId() : View.NO_ID);
if (!tiles.isEmpty())
inputButton.setNextFocusDownId(tiles.values().iterator().next().getId());
});
});
}
private void openNetworkSettings() {
for (String action : new String[] {
Settings.ACTION_WIFI_SETTINGS, Settings.ACTION_WIRELESS_SETTINGS, Settings.ACTION_SETTINGS
}) {
try {
startActivity(new Intent(action));
return;
} catch (ActivityNotFoundException | SecurityException e) {
// Some TV platforms omit a particular settings activity; try the portable fallback.
}
}
toast("Network settings unavailable");
}
private void showInputs() {
@ -1508,6 +1544,20 @@ public final class MainActivity extends Activity {
renderApps();
dismiss();
});
if ((app.info.activityInfo.applicationInfo.flags
& android.content.pm.ApplicationInfo.FLAG_SYSTEM) == 0)
action(
p,
"Uninstall app",
"Android will ask you to confirm",
() -> {
dismiss();
try {
startActivity(new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + app.pkg)));
} catch (ActivityNotFoundException | SecurityException e) {
toast("Uninstall unavailable · Use Android app info");
}
});
action(
p,
"Android app info",
@ -1531,6 +1581,8 @@ public final class MainActivity extends Activity {
moving = true;
updateFeaturedText();
selected = app.pkg;
AppTile tile = tiles.get(app.pkg);
if (tile != null) tile.requestFocus();
moveOriginal = new ArrayList<>();
for (AppRepository.App a : visibleApps) moveOriginal.add(a.pkg);
openHint.setText("↔ ↕ Move " + app.label + " · OK saves · Back cancels");
@ -1578,9 +1630,10 @@ public final class MainActivity extends Activity {
: key == KeyEvent.KEYCODE_DPAD_DOWN ? columns() : 0;
if (delta != 0 && index >= 0) {
int next = Math.max(0, Math.min(visibleApps.size() - 1, index + delta));
Collections.swap(visibleApps, index, next);
List<String> order = new ArrayList<>();
for (AppRepository.App a : visibleApps) order.add(a.pkg);
// Keep visibleApps in displayed order until renderApps compares it with the new order.
Collections.swap(order, index, next);
saveOrder(order);
renderApps();
openHint.setText(

View file

@ -0,0 +1,74 @@
package tv.luma.launcher;
import android.content.Context;
import android.content.res.ColorStateList;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.os.Handler;
import android.widget.ImageButton;
/** One foreground-only callback; no Wi-Fi scans, location access, or polling. */
final class NetworkStatus {
private final ConnectivityManager connectivity;
private final ImageButton button;
private final Handler handler;
private ConnectivityManager.NetworkCallback callback;
NetworkStatus(Context context, ImageButton button, Handler handler) {
connectivity = context.getSystemService(ConnectivityManager.class);
this.button = button;
this.handler = handler;
}
void start() {
if (callback != null || connectivity == null) return;
callback = new ConnectivityManager.NetworkCallback() {
@Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities capabilities) {
if (callback == this) show(capabilities);
}
@Override
public void onLost(Network network) {
if (callback == this) show(null);
}
};
try {
// Initial snapshot covers resume; subsequent state comes directly from callback capabilities.
show(connectivity.getNetworkCapabilities(connectivity.getActiveNetwork()));
connectivity.registerDefaultNetworkCallback(callback, handler);
} catch (SecurityException | IllegalArgumentException e) {
callback = null;
show(null);
}
}
void stop() {
ConnectivityManager.NetworkCallback previous = callback;
callback = null;
if (previous != null) {
try {
connectivity.unregisterNetworkCallback(previous);
} catch (IllegalArgumentException e) {
// Already removed by the platform.
}
}
}
private void show(NetworkCapabilities capabilities) {
boolean connected = capabilities != null;
boolean ethernet = connected && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET);
boolean wifi = connected && capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI);
boolean internet = connected && capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED);
String status = !connected ? "Network disconnected"
: (wifi ? "Wi-Fi" : ethernet ? "Ethernet" : "Network")
+ (internet ? " connected" : " · No internet access");
button.setImageResource(!connected ? R.drawable.ic_wifi_off
: ethernet ? R.drawable.ic_ethernet : R.drawable.ic_wifi);
button.setImageTintList(internet ? Ui.textColors()
: ColorStateList.valueOf(connected ? Ui.GOLD : Ui.MUTED));
button.setContentDescription(status + " · Open network settings");
button.setTooltipText(status);
}
}

View file

@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="#FFFFFFFF" android:pathData="M3,5L21,5L21,17L16,17L16,21L8,21L8,17L3,17ZM5,7L5,15L10,15L10,19L14,19L14,15L19,15L19,7ZM7,8L9,8L9,12L7,12ZM11,8L13,8L13,12L11,12ZM15,8L17,8L17,12L15,12Z" />
</vector>

View file

@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="#FFFFFFFF" android:pathData="M12,21L15,18C13.34,16.34 10.66,16.34 9,18ZM6,15L8,17C10.21,14.79 13.79,14.79 16,17L18,15C14.69,11.69 9.31,11.69 6,15ZM2,11L4,13C8.42,8.58 15.58,8.58 20,13L22,11C16.48,5.48 7.52,5.48 2,11Z" />
</vector>

View file

@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="#FFFFFFFF" android:pathData="M2.3,1L1,2.3L5.2,6.5C3.7,7.2 2.3,8.2 1,9.5L3,11.5C4.3,10.2 5.8,9.2 7.3,8.6L9.5,10.8C7.8,11.2 6.2,12 5,13.3L7,15.3C8.4,13.9 10.3,13.3 12.1,13.5L14.5,15.9C12.8,15.2 10.8,15.5 9.5,16.8L12,19.3L14.7,16.6L21.7,23.6L23,22.3ZM12,5C16.1,5 19.9,6.6 23,9.5L21,11.5C18.5,9 15.3,7.8 12,7.8L9.2,5.1C10.1,5 11,5 12,5Z" />
</vector>

View file

@ -1 +1,3 @@
Removes obsolete alternate-launcher shortcuts and routing integration. Avoids redundant window relayouts when remote input resets the screensaver timer. Background app-color transitions wait for a 250 ms pause in navigation and skip animations to an already displayed color. Tile focus stays immediate, with the same image quality and smooth final crossfade. No device-specific rendering paths.
Adds Uninstall app to the held-OK menu for user-installed apps, with Android confirmation. Fixes D-pad app rearranging and keeps focus on the moving app. Adds a network status shortcut beside Settings, with separate space for TV inputs. Removes the duplicate Personalize button at the bottom of Home.
Signing identity changed because the original key was lost. Devices running 1.1.12 or older need a one-time uninstall and reinstall of this release; Android cannot install it over the old signing identity. Reinstalling resets Luma settings and Plex credentials. Future updates use the new key.

View file

@ -260,3 +260,21 @@ Both devices passed the final 200 ms accent/coalescing regression, same-color ca
Final UI checks verified the removed package is absent on both devices, Settings and Default launcher contain no obsolete integration text/actions, Back stays in Luma, and physical-input controls remain visible only on the TV. The installed APK hashes match the final signed payload. Wallpaper, app art, original spacing, and focus behavior remain intact. Enabled accessibility lists remain Button Mapper only on the onn and null on the TV; the existing Home override remains Off on both. Memory saver remains Off on the onn and On on the TV. The supplied benchmark documents in the repository root were left untouched and untracked.
After settling with Android settings foreground, both launcher processes consumed zero CPU ticks over five seconds. This round's temporary diagnostic APKs, scripts, on-device reports, locks, and trace files were removed after archiving the reports locally. Both devices were returned to Luma. Android's stock launcher and unrelated apps/settings remain unchanged.
## 1.1.13 app actions and network shortcut (2026-10-25)
Built on Windows with JDK 17 and Android SDK/build tools 36, retaining minSdk 26 and targetSdk 34. VersionName 1.1.13 / versionCode 16. The original signing key was missing; the user explicitly authorized a replacement identity and a reinstall. The new RSA certificate SHA-256 is `5982677675475eab76e8aaa52f939b7a563aef69e869b8c5e342ac9e921b12ad`. The key and randomly generated signing password remain under ignored `.tools/`; neither is published. Build scripts now pass signing passwords through environment variables and refuse automatic key replacement.
On the authorized onn 4K Plus (Android 14/API 34), `scripts/check-app-move.py --adb <adb> --device <serial>` failed against installed 1.1.12: Right after selecting Move in grid left the first three visible apps in the same order. It passes against 1.1.13. The cause was mutating `visibleApps` before `renderApps` captured the displayed order, so the reuse comparison incorrectly skipped rebuilding. The fix swaps a separate order list, and preserves the requested selection while replacing focused children.
The final `HomeActionsInstrumentation` passed menu entry with remote OK, all four directions, upper/left boundaries, focus remaining on the moving app, Back restoring order, OK saving it across stop/start, and preference restoration. It also passed offline presentation followed by live-network recovery, callback stop/restart, absence of Personalize, and header bounds/D-pad navigation with simulated physical-input availability. The test exits Android touch mode with a remote arrow before requesting focus, so prior tap-based checks do not consume the first OK merely to leave touch mode.
`GridReuseInstrumentation` passed label-only reuse, focus callbacks, interrupted focus animation, hiding, reordering, and column changes. `WakeRegressionInstrumentation` passed interrupted loading, pause-only recovery, memory trimming, screensaver dismissal, and five stop/start cycles. Normal/rapid `NavigationInstrumentation` passed with zero dropped callbacks; FrameMetrics p95 was 16.37 ms normal and 16.64 ms rapid. These are functional navigation samples on one device, not a performance improvement claim or a comparison with another GPU.
The real UI check `scripts/check-home-actions.py` opened the native TV network page. Canceling Android's uninstall confirmation preserved the disposable Luma test app; confirming removed it for the current Android user and the resumed Luma library refreshed. The test checks the current user explicitly because the device has a second Android profile. System apps retain app info and do not receive an uninstall action. No user app was uninstalled by these checks.
Physical Ethernet, captive-portal/limited-internet hardware states, and real physical-input switching were not exercised in this run. Ethernet has its own vector port icon and accessible label selected by Android's active-network transport. Disconnected presentation was injected through the UI update seam without disconnecting wireless ADB. Input availability was simulated only for header bounds and focus; no input hardware or second TV was modified.
The signing migration required a reinstall of the authorized test device. The visible five-column layout, Kaleido-first ordering, Scenic screensaver with clock, and previously downloaded nature video were restored through Luma UI. Existing versions on the other two devices require a one-time reinstall; signature and update integrity checks remain enabled. Future releases must retain the new key.
Final cleanup restored the prior enabled-accessibility list (Button Mapper plus Luma's own Home override) and notification permission. Home returned from native Android settings to Luma after its existing accessibility redirect. Android's native Home selection and other launchers were preserved. The diagnostic APK was removed from all profiles, temporary on-device captures were deleted, and the installed APK SHA-256 matched the release manifest. The final Home screenshot was visually checked: the Wi-Fi icon has separate space beside the gear and the five-column app layout is intact.

Binary file not shown.

Binary file not shown.

View file

@ -1,11 +1,11 @@
{
"schema": 1,
"packageName": "tv.luma.launcher",
"versionCode": 15,
"versionName": "1.1.12",
"versionCode": 16,
"versionName": "1.1.13",
"minSdk": 26,
"apk": "Luma.apk",
"size": 2761885,
"sha256": "77892c9ac3eea5559423d3a7692374c1a4c676b6a5da1cd712773e0bc5eb91c6",
"notes": "Removes obsolete alternate-launcher shortcuts and routing integration. Avoids redundant window relayouts when remote input resets the screensaver timer. Background app-color transitions wait for a 250 ms pause in navigation and skip animations to an already displayed color. Tile focus stays immediate, with the same image quality and smooth final crossfade. No device-specific rendering paths."
"size": 2762079,
"sha256": "e15ddbc7f1ab31d39769f21bcf7f39a9866b38ed9fe53465013467f866b32c98",
"notes": "Adds Uninstall app to the held-OK menu for user-installed apps, with Android confirmation. Fixes D-pad app rearranging and keeps focus on the moving app. Adds a network status shortcut beside Settings, with separate space for TV inputs. Removes the duplicate Personalize button at the bottom of Home.\n\nSigning identity changed because the original key was lost. Devices running 1.1.12 or older need a one-time uninstall and reinstall of this release; Android cannot install it over the old signing identity. Reinstalling resets Luma settings and Plex credentials. Future updates use the new key."
}

View file

@ -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
View 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)

View file

@ -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
View 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'

View 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)

View file

@ -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'

View file

@ -1,6 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="tv.luma.launcher.tests">
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="34" />
<application android:label="Luma wake regression tests" />
<application android:label="Luma test app">
<activity android:name=".UninstallFixtureActivity" android:exported="true">
<intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LEANBACK_LAUNCHER" /></intent-filter>
</activity>
</application>
<instrumentation android:name="tv.luma.launcher.HomeActionsInstrumentation" android:targetPackage="tv.luma.launcher" android:functionalTest="true" />
<instrumentation android:name=".WakeRegressionInstrumentation" android:targetPackage="tv.luma.launcher" android:functionalTest="true" />
<instrumentation android:name="tv.luma.launcher.UpdaterInstrumentation" android:targetPackage="tv.luma.launcher" android:functionalTest="true" />
<instrumentation android:name=".PerformanceInstrumentation" android:targetPackage="tv.luma.launcher" android:functionalTest="true" />

View file

@ -0,0 +1,181 @@
package tv.luma.launcher;
import android.app.*;
import android.content.*;
import android.graphics.Rect;
import android.net.NetworkCapabilities;
import android.os.Bundle;
import android.view.*;
import android.widget.TextView;
import java.lang.reflect.*;
import java.util.*;
/** Real menu/key dispatch regression, with layout/preferences restored in finally. */
public final class HomeActionsInstrumentation extends Instrumentation {
private Activity activity;
private Object get(Object target, String name) throws Exception {
Field f = target.getClass().getDeclaredField(name);
f.setAccessible(true);
return f.get(target);
}
private void call(Object target, String name, Class<?> type, Object arg) {
runOnMainSync(() -> {
try {
Method m = type == null ? target.getClass().getDeclaredMethod(name)
: target.getClass().getDeclaredMethod(name, type);
m.setAccessible(true);
if (type == null) m.invoke(target); else m.invoke(target, arg);
} catch (Exception e) { throw new RuntimeException(e); }
});
waitForIdleSync();
}
private List<String> order() throws Exception {
return new ArrayList<>(((Map<String, ?>) get(activity, "tiles")).keySet());
}
private void key(int key) {
sendKeyDownUpSync(key);
android.os.SystemClock.sleep(180);
waitForIdleSync();
}
private void check(boolean ok, String message) {
if (!ok) throw new AssertionError(message);
}
private TextView text(View v, String prefix) {
if (v instanceof TextView && ((TextView) v).getText().toString().startsWith(prefix))
return (TextView) v;
if (v instanceof ViewGroup)
for (int i = 0; i < ((ViewGroup) v).getChildCount(); i++) {
TextView found = text(((ViewGroup) v).getChildAt(i), prefix);
if (found != null) return found;
}
return null;
}
private void begin(String pkg) throws Exception {
// A preceding tap-based check may leave Android in touch mode. A remote arrow exits it.
key(KeyEvent.KEYCODE_DPAD_UP);
View tile = (View) ((Map<?, ?>) get(activity, "tiles")).get(pkg);
runOnMainSync(() -> { tile.requestFocus(); tile.performLongClick(); });
waitForIdleSync();
Thread.sleep(350);
Dialog dialog = (Dialog) get(activity, "currentDialog");
TextView move = text(dialog.getWindow().getDecorView(), "Move in grid");
check(move != null, "move menu missing");
runOnMainSync(move::requestFocus);
key(KeyEvent.KEYCODE_DPAD_CENTER);
waitForIdleSync();
check((boolean) get(activity, "moving"), "remote OK did not enter move mode");
}
private void move(int key, List<String> expected, String pkg, int index) throws Exception {
int old = expected.indexOf(pkg);
Collections.swap(expected, old, index);
key(key);
waitForIdleSync();
check(order().equals(expected), "visible order did not follow arrow " + key);
check(pkg.equals(get(activity, "selected")), "moving selection lost");
check(pkg.equals(activity.getCurrentFocus().getTag()), "focus left moving app");
}
@Override public void onCreate(Bundle b) { super.onCreate(b); start(); }
@Override public void onStart() {
Bundle result = new Bundle();
StringBuilder report = new StringBuilder();
int status = Activity.RESULT_OK;
SharedPreferences prefs = getTargetContext().getSharedPreferences("luma", 0);
boolean hadOrder = prefs.contains("order");
String original = prefs.getString("order", "");
try {
activity = startActivitySync(new Intent(Intent.ACTION_MAIN)
.setComponent(new ComponentName("tv.luma.launcher", "tv.luma.launcher.MainActivity"))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
Thread.sleep(2000);
List<String> initial = order(), expected = new ArrayList<>(initial);
int columns = prefs.getInt("columns", 6);
check(initial.size() > columns + 1, "not enough apps for vertical movement");
String pkg = initial.get(0);
begin(pkg);
move(KeyEvent.KEYCODE_DPAD_RIGHT, expected, pkg, 1);
move(KeyEvent.KEYCODE_DPAD_DOWN, expected, pkg, columns + 1);
move(KeyEvent.KEYCODE_DPAD_UP, expected, pkg, 1);
move(KeyEvent.KEYCODE_DPAD_LEFT, expected, pkg, 0);
move(KeyEvent.KEYCODE_DPAD_LEFT, expected, pkg, 0);
move(KeyEvent.KEYCODE_DPAD_UP, expected, pkg, 0);
move(KeyEvent.KEYCODE_DPAD_RIGHT, expected, pkg, 1);
key(KeyEvent.KEYCODE_BACK);
check(order().equals(initial), "Back did not restore order");
check(!(boolean) get(activity, "moving"), "Back did not exit move mode");
report.append("PASS: remote menu entry, all four arrows, bounds, focus, Back cancellation\n");
begin(pkg);
expected = new ArrayList<>(initial);
move(KeyEvent.KEYCODE_DPAD_DOWN, expected, pkg, columns);
key(KeyEvent.KEYCODE_DPAD_CENTER);
check(!(boolean) get(activity, "moving"), "OK did not save");
runOnMainSync(() -> { callActivityOnPause(activity); callActivityOnStop(activity);
callActivityOnStart(activity); callActivityOnResume(activity); });
Thread.sleep(1200);
check(order().equals(expected), "saved move lost on resume");
report.append("PASS: OK saves order across stop/start\n");
View network = (View) get(activity, "networkButton");
View input = (View) get(activity, "inputButton");
View settings = (View) get(activity, "settingsButton");
List<TvInputs.Source> actual = (List<TvInputs.Source>) get(activity, "inputSources");
call(activity, "applyInputSources", List.class,
Collections.singletonList(new TvInputs.Source("test", "Test input", "Connected")));
Thread.sleep(250);
Rect nr = new Rect(), ir = new Rect(), sr = new Rect();
network.getGlobalVisibleRect(nr); input.getGlobalVisibleRect(ir); settings.getGlobalVisibleRect(sr);
check(!ir.isEmpty() && !nr.isEmpty() && !sr.isEmpty(), "header buttons clipped");
check(ir.right < nr.left && nr.right < sr.left, "header buttons overlap");
runOnMainSync(input::requestFocus);
key(KeyEvent.KEYCODE_DPAD_RIGHT);
check(network.hasFocus(), "input to network focus failed");
key(KeyEvent.KEYCODE_DPAD_RIGHT);
check(settings.hasFocus(), "network to settings focus failed");
key(KeyEvent.KEYCODE_DPAD_LEFT);
check(network.hasFocus(), "settings to network focus failed");
call(activity, "applyInputSources", List.class, Collections.emptyList());
check(input.getVisibility() == View.GONE, "input not hidden without capability");
call(activity, "applyInputSources", List.class, actual);
report.append("PASS: simulated physical-input header has separate bounds and D-pad focus\n");
Object monitor = get(activity, "networkStatus");
call(monitor, "show", NetworkCapabilities.class, null);
check(network.getContentDescription().toString().startsWith("Network disconnected"), "offline status");
call(monitor, "stop", null, null);
check(get(monitor, "callback") == null, "callback retained while stopped");
call(monitor, "start", null, null);
check(get(monitor, "callback") != null, "callback not restored");
check(!network.getContentDescription().toString().startsWith("Network disconnected"),
"live network did not recover after offline state");
check(text(activity.getWindow().getDecorView(), "Personalize") == null, "duplicate footer remains");
report.append("PASS: offline presentation, live-network recovery, callback stop/restart, footer\n");
} catch (Throwable t) {
status = Activity.RESULT_CANCELED;
report.append("FAIL: ").append(t).append('\n');
} finally {
if (activity != null) {
try {
if ((boolean) get(activity, "moving")) key(KeyEvent.KEYCODE_BACK);
} catch (Exception e) { status = Activity.RESULT_CANCELED; report.append("FAIL: move cleanup ").append(e); }
}
SharedPreferences.Editor edit = prefs.edit();
if (hadOrder) edit.putString("order", original); else edit.remove("order");
if (!edit.commit()) { status = Activity.RESULT_CANCELED; report.append("FAIL: order restore\n"); }
if (activity != null) {
try {
call(activity, "renderApps", null, null);
} catch (Exception e) { status = Activity.RESULT_CANCELED; report.append("FAIL: cleanup ").append(e); }
}
}
result.putString("stream", report.toString());
finish(status, result);
}
}

View file

@ -0,0 +1,4 @@
package tv.luma.launcher.tests;
/** Disposable app entry for exercising the real Android uninstall flow. */
public final class UninstallFixtureActivity extends android.app.Activity {}