Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Versions after 2.17 are `MAJOR.MINOR.PATCH` (2.17 is followed by 2.17.1 or 2.18.
`docs/testing.md`, "Versions and releases"); the headings below keep the numbers as they
were released.

## 2.30.1 — 2026-11-25

- Opening the app right after an update no longer crashes it (#308, since 2.27.0): the web
page's service was stopped before it had become a foreground service; now it stops itself
as soon as it may.
- No trailing comma after the version under Exit in a build without a git commit.

## 2.30.0 — 2026-11-24

- The Android screens in the brand's fonts (#306, brass 1.5.1), as the debug page: the menu
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId "com.openipc.decoder"
minSdk 21
targetSdk 36
versionCode 72
versionName "2.30.0"
versionCode 73
versionName "2.30.1"
// Keep only these locales of the libraries' resources, as in the other OpenIPC apps
resourceConfigurations += ['en', 'ru', 'zh-rCN']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public boolean dispatchKeyEvent(KeyEvent event) {
// Exit | Reset | Debug | UDP
LinearLayout actionRow = gridRow(layout);
// The version under Exit, small (#176): beside it, it would widen every cell
String ver = "v" + version + ", " + gitHash;
String ver = versionLine(version, gitHash);
SpannableString s = new SpannableString("Exit\n" + ver);
s.setSpan(new RelativeSizeSpan(0.5f), 5, s.length(), 0);
s.setSpan(new Brass.MonoSpan(activity), 5, s.length(), 0);
Expand Down Expand Up @@ -440,6 +440,11 @@ static boolean isNavigationKey(int keyCode) {
}
}

/** The version and the commit; a build without git has no hash, and then no comma (#308). */
static String versionLine(String version, String gitHash) {
return "v" + version + (gitHash == null || gitHash.isEmpty() ? "" : ", " + gitHash);
}

/** A row of the menu grid (#177), as wide as the menu. */
private LinearLayout gridRow(LinearLayout menu) {
LinearLayout row = new LinearLayout(activity);
Expand Down
13 changes: 12 additions & 1 deletion android/app/src/main/java/com/openipc/decoder/WebService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public final class WebService extends Service {
/** Not the camex tunnel's (its library uses its own id). */
private static final int NOTIFICATION_ID = 0x5745;

/**
* Started, its {@link #onStartCommand} not run yet: Android ends the app when a service
* asked for with startForegroundService is stopped before startForeground (#308). Main thread.
*/
private static boolean pending;

/** After {@code MY_PACKAGE_REPLACED}: the page back, when it is allowed and the app is shut. */
static void startAfterUpdate(Context c) {
if (!WebPort.allowed(c)) {
Expand All @@ -42,11 +48,13 @@ static void startAfterUpdate(Context c) {
if (Decoder.openOrOpening()) return;
Intent i = new Intent(c, WebService.class);
try {
pending = true;
// exempt from the background limits on foreground services: the update broadcast
if (Build.VERSION.SDK_INT >= 26) c.startForegroundService(i);
else c.startService(i);
Log.i(TAG, "Updated: the web page is back, nothing else (no video, no tunnel)");
} catch (RuntimeException e) {
pending = false;
Log.w(TAG, "Updated: the web page could not be started: " + e.getMessage());
}
}
Expand Down Expand Up @@ -77,6 +85,7 @@ public void onDestroy() {

/** The app's screen is open: its own process keeps the page from now on. */
static void stop(Context c) {
if (pending) return; // it stops itself once it may, in onStartCommand (#308)
try {
c.stopService(new Intent(c, WebService.class));
} catch (RuntimeException e) {
Expand All @@ -92,7 +101,9 @@ public int onStartCommand(Intent intent, int flags, int startId) {
} else {
startForeground(NOTIFICATION_ID, n);
}
if (!WebPort.allowed(this)) {
pending = false;
// remote access off, or the app opened meanwhile: its screen keeps the page (#308)
if (!WebPort.allowed(this) || Decoder.openOrOpening()) {
stopSelf();
return START_NOT_STICKY;
}
Expand Down
21 changes: 21 additions & 0 deletions android/app/src/test/java/com/openipc/decoder/VersionLineTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) OpenIPC https://openipc.org Prosperity Public License 3.0.0
*
* VersionLineTest.java — the version under Exit in the menu (#308)
*
*/

package com.openipc.decoder;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class VersionLineTest {
@Test
public void aBuildWithoutACommitHasNoComma() {
assertEquals("v2.30.1, 7677ab0", MenuManager.versionLine("2.30.1", "7677ab0"));
assertEquals("v2.30.1", MenuManager.versionLine("2.30.1", ""));
assertEquals("v2.30.1", MenuManager.versionLine("2.30.1", null));
}
}
26 changes: 26 additions & 0 deletions tests/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,32 @@ if [ -z "$SHOTS" ]; then
$ADB forward --remove tcp:18085 >/dev/null 2>&1 || true
fi

# the app opened right after an update, with the page's service still starting: no crash (#308)
if [ -z "$SHOTS" ]; then
$ADB logcat -c 2>/dev/null || true
$ADB push /w/decoder.apk /data/local/tmp/update.apk >/dev/null
n=0
late=0
installed=0
while [ "$n" -lt 5 ]; do
n=$((n + 1))
# in one shell on the device: no adb round trip between the two
# (pm's exit code is of no use on old Androids: its Success is counted, Qodo on #309)
$ADB shell "pm install -r /data/local/tmp/update.apk 2>&1; am start -n $PKG/.Decoder >/dev/null" |
grep '^Success' >/dev/null && installed=$((installed + 1)) || true
sleep 8
# the service must not outlive the opened screen either
! $ADB shell dumpsys activity services "$PKG" | grep -q 'ServiceRecord.*WebService' || late=$((late + 1))
done
$ADB shell rm -f /data/local/tmp/update.apk
$ADB logcat -d > "$OUT/logcat-update-open.txt" 2>&1 || true
races=$(grep -c 'Updated: the web page is back' "$OUT/logcat-update-open.txt" || true)
if ! grep -q 'did not then call Service.startForeground' "$OUT/logcat-update-open.txt" && [ "$late" = 0 ] &&
[ "$installed" = 5 ]; then
ok "opened right after an update, 5 times ($races with the service starting): no crash, the service gone"
else bad "opened right after an update: a crash, the service stayed ($late) or updates failed ($installed of 5; tests/out/logcat-update-open.txt)"; fi
fi

$ADB logcat -d -b crash > "$OUT/crash.log" 2>&1 || true
if grep -q "$PKG" "$OUT/crash.log"; then bad "crash in logcat (tests/out/crash.log)"; else ok "no crash"; fi

Expand Down
Loading