Skip to content

Latest commit

 

History

History

android

README.md

PM console for Android

The screens are the site itself: the app opens https://pm.security.cab/console/ in Chrome without browser chrome (a Trusted Web Activity). So it does everything the site does, signs in the way the site does (Chrome's own session), and needs no release when the console changes.

Around the site, the app uses what only an installed app has:

What How it is used Code
Home-screen widget In progress, queued next, needs me, unread instructions, and the task being worked on. Each number opens its screen StatusWidget, Fleet
Dictation Long-press the icon and choose Dictate, or tap the "Ask the fleet" quick-settings tile: the words land in the Ask box DictateActivity, AskTileService
Share and selection Share text from any app, or select text and choose "Ask the fleet": it lands in the Ask box. An enroll command lands in provisioning on the Agents screen instead ShareActivity, Links
Long-press shortcuts Dictate, Ask, Needs me, Now, Messages. They move the open app to that screen and do not reload it OpenActivity, res/xml/shortcuts
Notifications The site's notifications arrive as the app's own, with its mark in the status bar; the app asks for the permission itself the helper library's activities
Links https://pm.security.cab/... links open in the app the launcher activity's intent filter

Words handed to the site (shared, selected or dictated) travel after the # of the address, which a browser never sends to a server; they sit in the Ask box until the owner presses Send.

The widget's own sign-in

A widget cannot use the browser's session, so the phone is linked once:

  1. Add the "PM status" widget to the home screen and tap it.
  2. The app opens at More, Phones, showing "Link this phone?". Approve.
  3. The widget fills in. It reads again every half hour, when the app is opened, and when its refresh mark is tapped.

The phone makes a random value and shows the site only its hash; after the approval it presents the value itself and is given a token that can read the widget's summary and nothing else. The owner can remove a phone under More, Phones, and the widget then goes back to "Tap to link".

How the app and the site trust each other

  • The app names the site in its manifest (asset_statements).
  • The site names the app in /.well-known/assetlinks.json: package today.developing.pmconsole, signed by the certificate in signing-fingerprint.txt. pm-console serves that file from PM_CONSOLE_ANDROID_SHA256.

If the two disagree the app still works, with a browser bar at the top.

Build and release

GitHub Actions builds the app on every push to main that touches it (.github/workflows/pm-console-android.yml), and by hand:

gh workflow run pm-console-android.yml
bash pm-stack/console/android/build.sh        # here: needs JAVA_HOME (17 or 21) and ANDROID_HOME

A build names its own version from its commit (build.sh): a code that rises with the commit's time, so each build installs over the one before, and a name that says the day and the commit.

Every build ends up signed and released with nobody involved, twice:

  • pm-console-android-v<code>: that build. Once made it is never changed.
  • pm-console-android: one address that always holds the newest build and is never taken back to an older one. The site hands this one out.

Each carries pm-console.apk, pm-console.apk.sha256 and a version.json (name, code, commit, sha256, size, when, certificate). release.sh makes both. Where the signing happens depends on where the key is.

The pm-stack host held the key (how it started). The workflow's build was unsigned and kept as the artifact pm-console-apk-unsigned, with the version it was built as. On the host, pm-console-android-release.timer runs release-built.sh every ten minutes: it takes the newest unsigned build made on main, signs it there with sign.sh (which refuses a result that does not carry the certificate in signing-fingerprint.txt), releases it, and puts it where the console serves the app from. That path is now the fallback: since 2026-11-29 the workflow signs in CI (below), release-built.sh sees the signed artifact and stands down, and the timer is a no-op while CI holds the key. If that unit fails it shows on the console's Services screen and in its notifications, like any other.

Only a build this repository made on main, by a push or by hand, is ever signed: a run of a pull request, another branch or a fork is not, whatever it is called.

By hand, the same steps:

gh run download <run-id> -n pm-console-apk-unsigned -D /tmp/pm-apk
nix shell nixpkgs#apksigner -c bash pm-stack/console/android/sign.sh /tmp/pm-apk/app-release-unsigned.apk
install -m 644 /tmp/pm-apk/pm-console.apk ~/.local/state/pm-console/android/pm-console.apk

GitHub holds the key (the owner's decision, 2026-11-29, #16828). The build is signed in the workflow, checked against the same certificate, and released by the same release.sh; the host then finds nothing to do, and a release no longer waits for the host to be up.

Giving GitHub the key

Done on 2026-11-29, on the owner's order (#16828): the key was copied from the pm-stack host into the environment secrets, so the workflow signs and releases by itself and the host's timer stands down.

The key remains on the pm-stack host at ~/.local/state/pm-console/android/release.p12, with its password in keystore-password beside it — the host copy is what sign.sh uses if the fallback path ever runs. The workflow signs because the pm-console-android environment of the repository holds two secrets:

  • PM_CONSOLE_ANDROID_KEYSTORE_B64: the keystore, base64;
  • PM_CONSOLE_ANDROID_KEYSTORE_PASSWORD: its password.

The environment is limited to the main branch (Settings, Environments), so a workflow run on any other branch cannot read the key.

A build signed by any other key fails before anything is released, in build.sh or in sign.sh. Losing the key means a new key, a new fingerprint and a reinstall; nothing else depends on it.

Install

On the phone, open https://pm.security.cab/console/, sign in, and go to More, Phones, "Download the app" (/console/pm-console.apk, owner only). What that is, in order:

  1. the build GitHub released, fetched from the release and checked against its version.json; this needs nothing of the laptop;
  2. otherwise the laptop's signed build (~/.local/state/pm-console/android/pm-console.apk), or the copy of it kept at Cloudflare when the laptop is away.

The page says which it is. Later builds install over it.

The native parts are checked by compiling the build and reading its merged manifest; the site's side of each (the Ask box taking handed-over words, linking a phone, the summary) is tested in test/. The app with no connection is checked on a device in CI: the pm-console-android-offline workflow (nightly, and on demand) starts an emulator, installs the built APK, and drives it against the demo edge — open, aeroplane mode, open again from the icon, answer a question, swipe the app away, network back — and checks the demo edge saw that answer exactly once. See offline-check.sh for the steps.