App 2.19.3: update log on the Logs tab

Every update and install step, with the platform's own result, kept
across the restart an install causes, so a failed install on the car
can be read off the screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-23 21:15:44 +02:00
co-authored by Claude Opus 5.5
parent 50217aef74
commit 51beea5ed8
11 changed files with 147 additions and 7 deletions
@@ -83,10 +83,12 @@ final class UpdateHook {
message = runCheck(app, listener, main);
} catch (Throwable t) {
Log.w(TAG, "Update check threw", t);
message = "Update check failed";
// The class only: a network error's text can carry the server's address.
message = "Update check failed (" + t.getClass().getSimpleName() + ")";
} finally {
checking.set(false);
}
UpdateLog.record(app, "Check: " + message);
if (listener != null) {
final String result = message;
main.post(() -> listener.onResult(result));
@@ -112,10 +114,11 @@ final class UpdateHook {
message = runUsbInstall(app);
} catch (Throwable t) {
Log.w(TAG, "USB install threw", t);
message = "Installing from USB failed";
message = "Installing from USB failed: " + t;
} finally {
checking.set(false);
}
UpdateLog.record(app, "USB: " + message);
if (listener != null) {
final String result = message;
main.post(() -> listener.onResult(result));
@@ -141,6 +144,7 @@ final class UpdateHook {
if (best == null) {
return "No newer NilsMG4-unstable-<version>.apk on a USB stick (installed: " + current + ")";
}
UpdateLog.record(app, "USB: found " + best + " (" + best.length() + " bytes)");
File sidecar = new File(best.getPath() + ".sha256");
String expected = sidecar.isFile() && sidecar.length() < 16 * 1024
? OtaUpdater.parseExpectedSha256(new String(java.nio.file.Files.readAllBytes(sidecar.toPath()),
@@ -156,6 +160,7 @@ final class UpdateHook {
StringBuilder hex = new StringBuilder();
for (byte b : digest.digest()) hex.append(String.format(java.util.Locale.US, "%02x", b));
if (!hex.toString().equalsIgnoreCase(expected)) return "Not installed: " + best.getName() + " does not match its SHA-256";
UpdateLog.record(app, "USB: SHA-256 matches");
String version = OtaUpdater.versionFromAssetName(best.getName());
switch (OtaUpdater.install(app, best)) {
case SESSION_STARTED: