Skip to content

Commit a84d66f

Browse files
committed
Gift mode: allow device to sleep instead of keeping screen on
Previously gift mode kept FLAG_KEEP_SCREEN_ON indefinitely, draining the battery. Now when allow_sleep is enabled, gift mode clears the flag and optionally disables WiFi after showing the gift screen and writing the screensaver. The NOOK sleeps until the user taps to wake. Also includes CI improvements: - versionCode regression guard in set-version.sh - Tag moves to version-bumped commit after CI stamps manifest - Updated release docs
1 parent 5f36912 commit a84d66f

5 files changed

Lines changed: 53 additions & 3 deletions

File tree

.github/workflows/build-apk.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ jobs:
6969
git commit -m "Bump version to ${GITHUB_REF_NAME#v}"
7070
git push origin HEAD:main
7171
fi
72+
- name: Move tag to version-bumped commit
73+
if: startsWith(github.ref, 'refs/tags/')
74+
shell: bash
75+
run: |
76+
set -euo pipefail
77+
# After committing the version bump to main, the tag still points
78+
# to the pre-bump commit. Move it so raw.githubusercontent.com
79+
# serves the correct AndroidManifest.xml for this tag.
80+
BUMP_SHA="$(git rev-parse HEAD)"
81+
git tag -f "${GITHUB_REF_NAME}" "${BUMP_SHA}"
82+
git push origin "${GITHUB_REF_NAME}" --force
83+
7284
7385
- name: Configure release signing
7486
if: startsWith(github.ref, 'refs/tags/')

AGENTS/release.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,23 @@ unless the user explicitly requests it.
66

77
## Release flow (tags + GitHub Actions)
88

9-
Releases are driven by annotated tags like `v0.1.0`. The CI workflow
9+
Releases are driven by tags like `v0.1.0`. The CI workflow
1010
`build-apk.yml` stamps the manifest version, builds a signed release APK,
1111
and publishes a GitHub Release with the APK attached.
1212

13+
### Safety guards (automated)
14+
15+
- **versionCode regression check**`set-version.sh` compares the computed
16+
versionCode against the previous tag's manifest and **fails the build** if
17+
it hasn't increased. This prevents releasing a tag with a stale or duplicate
18+
versionCode.
19+
- **Tag moves to version-bumped commit** — After CI commits the version bump
20+
to `main`, it force-pushes the tag to that commit. This ensures
21+
`raw.githubusercontent.com/.../v0.9.4/AndroidManifest.xml` serves the
22+
correct version (not the pre-bump snapshot). Without this, downstream
23+
consumers (e.g. `bpmct/nooks`) that read the manifest from the tag ref
24+
would see stale version info.
25+
1326
### Versioning nuance (when to bump major/minor/patch)
1427

1528
This project follows semantic-versioning *in spirit*:

AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.bpmct.trmnl_nook_simple_touch"
4-
android:versionCode="90399"
5-
android:versionName="0.9.3" >
4+
android:versionCode="90599"
5+
android:versionName="0.9.5" >
66

77
<uses-permission android:name="android.permission.INTERNET" />
88
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

src/com/bpmct/trmnl_nook_simple_touch/DisplayActivity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,16 @@ private void showGiftModeScreen() {
10101010

10111011
// Write gift mode screen to screensaver so NOOK shows it when asleep
10121012
writeGiftModeScreensaver(code, fromName, toName);
1013+
1014+
// Allow device to sleep; user tap wakes it
1015+
if (ApiPrefs.isAllowSleep(this)) {
1016+
setKeepScreenAwake(false);
1017+
if (ApiPrefs.isAutoDisableWifi(this)) {
1018+
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
1019+
if (wifi != null) wifi.setWifiEnabled(false);
1020+
}
1021+
logD("gift mode: sleep-ready (tap to wake)");
1022+
}
10131023
}
10141024

10151025
private LinearLayout createStepRow(String number, String text) {

tools/set-version.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ if [[ ! -f "${MANIFEST}" ]]; then
3535
exit 1
3636
fi
3737

38+
# Guard: ensure new versionCode is strictly higher than the previous release tag
39+
PREV_TAG="$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)"
40+
if [[ -n "${PREV_TAG}" ]]; then
41+
PREV_CODE="$(git show "${PREV_TAG}:${MANIFEST}" 2>/dev/null \
42+
| sed -n 's/.*android:versionCode="\([0-9]*\)".*/\1/p' || true)"
43+
if [[ -n "${PREV_CODE}" && "${VERSION_CODE}" -le "${PREV_CODE}" ]]; then
44+
echo "error: new versionCode ${VERSION_CODE} is not higher than previous tag ${PREV_TAG} (versionCode=${PREV_CODE})" >&2
45+
echo "hint: this usually means the tag version was not bumped correctly" >&2
46+
exit 1
47+
fi
48+
if [[ -n "${PREV_CODE}" ]]; then
49+
echo "versionCode check passed: ${VERSION_CODE} > ${PREV_CODE} (${PREV_TAG})"
50+
fi
51+
fi
52+
3853
python3 - <<PY
3954
import re
4055
from pathlib import Path

0 commit comments

Comments
 (0)