Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ba301a3
fix(android): rotate helper signing identity
thymikee Nov 30, 2026
cd6a03b
fix(ci): sign Android helpers with ephemeral test key
thymikee Nov 30, 2026
3b1ed68
test(android): migrate helper identity fixtures
thymikee Nov 30, 2026
dbeb94b
fix(android): block release until helper signing is isolated
thymikee Nov 30, 2026
ab265ef
chore(android): format release guard tests
thymikee Nov 30, 2026
3905446
fix(android): use rotated helper instrumentation class
thymikee Nov 30, 2026
1b3a167
test(android): verify fail-closed helper release workflow
thymikee Nov 30, 2026
8d68837
test(android): use rotated snapshot runner in provider fixture
thymikee Nov 30, 2026
9a9739f
test: use declared Android IME service class in provider fixture
thymikee Nov 30, 2026
def7bc9
docs(android): name helper signing inputs consistently
thymikee Nov 30, 2026
edc2fe2
fix(android): preserve user IME across helper rotation
thymikee Nov 30, 2026
7b1f2c9
fix(android): replace helper IME in displaced restore record
thymikee Nov 30, 2026
8f53e67
style(android): format IME activation and restore files
thymikee Nov 30, 2026
baa3100
fix(android): preserve helper restore and legacy routing behavior
thymikee Nov 30, 2026
a865d81
fix(release): document signing pause and fail before build
thymikee Nov 30, 2026
b42de93
chore(gates): pin signing refusal and helper manifest
thymikee Nov 30, 2026
9078b11
docs(android): name signing inputs for helper builds
thymikee Nov 30, 2026
2ffdf98
test(android): prove installed helper bytes in IME fixture
thymikee Dec 1, 2026
60e3858
test(android): derive installed helper probe from fixture artifact
thymikee Dec 1, 2026
1721aa2
fix(android): detect legacy IME and align helper probes
thymikee Dec 1, 2026
c4af41b
fix(android): report invalid IME recovery and align probe fixture
thymikee Dec 1, 2026
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
4 changes: 3 additions & 1 deletion .github/actions/setup-android-replay-host/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runs:
run: |
VERSION="$(node -p 'require("./package.json").version')"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "value=${{ hashFiles('android/snapshot-helper/AndroidManifest.xml', 'android/snapshot-helper/debug.keystore', 'android/snapshot-helper/src/**', 'android/ime-helper/AndroidManifest.xml', 'android/ime-helper/res/**', 'android/ime-helper/src/**', 'scripts/build-android-helper.sh', 'scripts/package-android-helper.sh', '.github/actions/setup-android-replay-host/action.yml', '.github/actions/setup-android-sdk/action.yml') }}" >> "$GITHUB_OUTPUT"
echo "value=${{ hashFiles('android/snapshot-helper/AndroidManifest.xml', 'android/snapshot-helper/src/**', 'android/ime-helper/AndroidManifest.xml', 'android/ime-helper/res/**', 'android/ime-helper/src/**', 'scripts/build-android-helper.sh', 'scripts/package-android-helper.sh', '.github/actions/setup-android-replay-host/action.yml', '.github/actions/setup-android-sdk/action.yml') }}" >> "$GITHUB_OUTPUT"
shell: bash

# The helper build refuses to guess its build-tools version on CI, and that version decides
Expand All @@ -45,6 +45,8 @@ runs:
- name: Setup Android SDK
if: inputs.package-helpers == 'true'
uses: ./.github/actions/setup-android-sdk
with:
ephemeral-helper-signing: 'true'

- name: Restore packaged Android helpers
if: inputs.package-helpers == 'true'
Expand Down
25 changes: 25 additions & 0 deletions .github/actions/setup-android-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: 'Install the API 36 x86_64 Play Store emulator image'
required: false
default: 'false'
ephemeral-helper-signing:
description: 'Generate a run-scoped helper signing key for non-release CI builds'
required: false
default: 'false'

outputs:
build-tools-dir:
Expand Down Expand Up @@ -76,3 +80,24 @@ runs:
echo "AGENT_DEVICE_ANDROID_BUILD_TOOLS=$BUILD_TOOLS_VERSION" >> "$GITHUB_ENV"
echo "build-tools-dir=$BUILD_TOOLS_DIR" >> "$GITHUB_OUTPUT"
echo "system-image-dir=$SYSTEM_IMAGE_DIR" >> "$GITHUB_OUTPUT"

- name: Generate ephemeral Android helper signing key
if: inputs.ephemeral-helper-signing == 'true'
shell: bash
run: |
set -euo pipefail
KEYSTORE="$RUNNER_TEMP/agent-device-ci-helper-${GITHUB_RUN_ID}-${GITHUB_JOB}.jks"
keytool -genkeypair \
-keystore "$KEYSTORE" \
-storepass agent-device-ci-only \
-keypass agent-device-ci-only \
-alias agent-device-ci-helper \
-keyalg RSA \
-keysize 2048 \
-validity 1 \
-dname 'CN=Agent Device CI Helper, O=Callstack, C=PL'
chmod 600 "$KEYSTORE"
echo "AGENT_DEVICE_ANDROID_KEYSTORE=$KEYSTORE" >> "$GITHUB_ENV"
echo "AGENT_DEVICE_ANDROID_KEY_ALIAS=agent-device-ci-helper" >> "$GITHUB_ENV"
echo "AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD=agent-device-ci-only" >> "$GITHUB_ENV"
echo "AGENT_DEVICE_ANDROID_KEY_PASSWORD=agent-device-ci-only" >> "$GITHUB_ENV"
88 changes: 7 additions & 81 deletions .github/workflows/release-android-snapshot-helper.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Release Android Snapshot Helper

on:
# release.yml calls this after publishing a stable release; dispatch reruns it for one tag.
workflow_call:
inputs:
release_tag:
Expand All @@ -14,89 +13,16 @@ on:
description: GitHub Release tag to upload assets to, for example v0.13.3.
required: true
type: string
checkout_ref:
description: Optional branch, tag, or commit SHA to build. Defaults to the selected workflow ref.
required: false
type: string

permissions:
contents: write
permissions: {}

jobs:
publish-android-snapshot-helper:
name: Publish Android Snapshot Helper
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
name: Block Android Snapshot Helper release until signing is isolated
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Checkout
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
with:
ref: ${{ inputs.checkout_ref || github.ref }}

- name: Checkout release validator
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
with:
repository: ${{ job.workflow_repository }}
ref: ${{ job.workflow_sha }}
path: .release-validator
sparse-checkout: scripts/release-version.mjs
sparse-checkout-cone-mode: false
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '24.13'

- name: Resolve release metadata
id: meta
env:
TAG_NAME: ${{ inputs.release_tag }}
run: |
set -euo pipefail
node .release-validator/scripts/release-version.mjs asset-tag "$TAG_NAME"
VERSION="${TAG_NAME#v}"
echo "tag=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
shell: bash

# Exports AGENT_DEVICE_ANDROID_BUILD_TOOLS, which the helper build requires on CI.
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk

- name: Check Java toolchain
run: |
javac --version
java --version

- name: Package Android snapshot helper
id: package
env:
RELEASE_ASSET_DIR: ${{ github.workspace }}/.tmp/release-assets
RELEASE_VERSION: ${{ steps.meta.outputs.version }}
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
AGENT_DEVICE_ANDROID_HELPER: snapshot
run: |
set -euo pipefail
mkdir -p "${RELEASE_ASSET_DIR}"
sh ./scripts/package-android-helper.sh \
"$RELEASE_VERSION" \
"$RELEASE_TAG" \
"${RELEASE_ASSET_DIR}"
shell: bash

- name: Upload helper assets to GitHub Release
env:
APK_PATH: ${{ steps.package.outputs.apk_path }}
CHECKSUM_PATH: ${{ steps.package.outputs.checksum_path }}
MANIFEST_PATH: ${{ steps.package.outputs.manifest_path }}
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
- name: Refuse source checkout with the production signing key
run: |
set -euo pipefail
gh release upload "$RELEASE_TAG" \
"$APK_PATH" \
"$CHECKSUM_PATH" \
"$MANIFEST_PATH" \
--clobber
shell: bash
echo 'Published Android helpers require an isolated signer and a stable external key. This workflow cannot sign source checkout scripts.' >&2
exit 1
Comment thread
thymikee marked this conversation as resolved.
Resolved
11 changes: 10 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ name: Release
# dry-run (PR), nightly (main-owned schedule or dispatch), or stable (a vX.Y.Z tag on
# main). The tag ruleset, which only admins can bypass, is the stable release's
# approval: a tag publishes without another review.
# Nightly and stable publishing are paused until the Android helper has an isolated signer and
# stable external key. The build preflight fails before checkout, npm publish, or asset upload.
on:
pull_request:
paths:
Expand Down Expand Up @@ -88,6 +90,12 @@ jobs:
env:
VERSION: ${{ needs.plan.outputs.version }}
steps:
- name: Pause nightly and stable release until helper signing is isolated
if: needs.plan.outputs.mode != 'dry-run'
Comment thread
thymikee marked this conversation as resolved.
Resolved
run: |
echo 'Published Android helpers require an isolated signer and a stable external key. Release is blocked until that path is configured.' >&2
exit 1

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
Expand All @@ -112,6 +120,8 @@ jobs:
# Exports AGENT_DEVICE_ANDROID_BUILD_TOOLS, which the helper build requires on CI.
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk
with:
ephemeral-helper-signing: 'true'

- name: Stamp release version
run: node .release-tools/scripts/release-version.mjs stamp "$VERSION"
Expand Down Expand Up @@ -243,7 +253,6 @@ jobs:
uses: ./.github/workflows/release-ios-runner.yml
with:
release_tag: v${{ needs.plan.outputs.version }}

android-snapshot-helper:
name: Android helper assets
needs: [plan, github-release]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
# Exports AGENT_DEVICE_ANDROID_BUILD_TOOLS, which the helper build requires on CI.
- name: Setup Android SDK
uses: ./.github/actions/setup-android-sdk
with:
ephemeral-helper-signing: 'true'

# dist is fully determined by the base commit, so reuse it across PR runs
# against the same base. Startup medians are still measured fresh on this
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ xcuserdata/
*.xcresult
*.ipa
*.apk
*.jks
*.keystore
*.dSYM
*.dSYM.zip
*.app
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ described below. A local `npm publish` from the repository root refuses to run.
The core and every public workspace package release together at one version. Private packages
stay unpublished. The workflow supports these release modes:

Nightly and stable publishing are currently paused until Android helper signing uses an isolated
signer with a stable external key. The Release build stops before npm publish or asset upload.
Pull-request dry runs still build with a disposable key. A tag or GitHub Release created by an
admin may already exist, but this paused workflow does not publish packages or attach helper assets.

- **Nightly** (`npm install -g agent-device@nightly`): once a day, at 01:23 UTC, the workflow
checks `main`. It publishes `X.Y.Z-nightly.<YYYYMMDD>.<run>` under the `nightly` dist-tag when
`main`'s HEAD has changed since the last nightly and its CI passed, waiting up to 20 minutes for
Expand Down
4 changes: 2 additions & 2 deletions android/ime-helper/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.callstack.agentdevice.imehelper">
package="com.callstack.agentdevice.imehelper.v2">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="36" />

<application
Expand All @@ -9,7 +9,7 @@
android:theme="@android:style/Theme.NoDisplay">

<service
android:name=".TestInputMethodService"
android:name="com.callstack.agentdevice.imehelper.TestInputMethodService"
android:label="Agent Device Test IME"
android:permission="android.permission.BIND_INPUT_METHOD"
android:exported="true"
Expand Down
9 changes: 7 additions & 2 deletions android/ime-helper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ verified the same way (bundled npm-packaged dist + version-keyed manifest.json),

```sh
VERSION="$(node -p 'require("./package.json").version')"
# Export AGENT_DEVICE_ANDROID_KEYSTORE, AGENT_DEVICE_ANDROID_KEY_ALIAS,
# AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD, and AGENT_DEVICE_ANDROID_KEY_PASSWORD
# from your secret store before running this in a trusted signing shell.
AGENT_DEVICE_ANDROID_HELPER=ime sh ./scripts/build-android-helper.sh "$VERSION" .tmp/android-ime-helper
```

The shared script needs its build-tools version named by `AGENT_DEVICE_ANDROID_BUILD_TOOLS`; see
the [snapshot helper's Build section](../snapshot-helper/README.md#build) for the full rule.
The root `build:android-*` and `package:android-*` scripts, and `pnpm prepack`, need the same
four signing values. Use a disposable caller-owned key for a local test build.

## Run

```sh
PACKAGE="com.callstack.agentdevice.imehelper"
SERVICE="$PACKAGE/.TestInputMethodService"
PACKAGE="com.callstack.agentdevice.imehelper.v2"
SERVICE="$PACKAGE/com.callstack.agentdevice.imehelper.TestInputMethodService"
VERSION="$(node -p 'require("./package.json").version')"

adb install -r ".tmp/android-ime-helper/agent-device-android-ime-helper-$VERSION.apk"
Expand Down
6 changes: 3 additions & 3 deletions android/snapshot-helper/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.callstack.agentdevice.snapshothelper">
package="com.callstack.agentdevice.snapshothelper.v2">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="36" />
<uses-permission android:name="android.permission.INTERNET" />

Expand All @@ -10,8 +10,8 @@
android:theme="@android:style/Theme.NoDisplay" />

<instrumentation
android:name=".SnapshotInstrumentation"
android:targetPackage="com.callstack.agentdevice.snapshothelper"
android:name="com.callstack.agentdevice.snapshothelper.SnapshotInstrumentation"
android:targetPackage="com.callstack.agentdevice.snapshothelper.v2"
android:label="Agent Device Snapshot Helper"
android:functionalTest="true" />
</manifest>
56 changes: 48 additions & 8 deletions android/snapshot-helper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,41 @@ unavailable, it falls back to the active-window root.

The helper is intentionally provider-neutral. Local `adb`, cloud ADB tunnels, and remote device
providers can all install and run the same APK as long as they can execute ADB-style operations.
Released helper APKs use the committed `debug.keystore`; do not rotate it casually, because Android
requires a stable signing certificate for `adb install -r` upgrades.
The snapshot and IME helpers use rotated package identities. The release workflow is blocked until
an isolated signing stage can use a stable externally managed key. The repository does not contain a private key.
Android treats the rotated packages as new applications, so a compromised legacy package cannot
satisfy the current helper manifest or receive package-scoped host commands.

## Signing rotation

Generate and protect the release key outside this repository. Do not use the removed legacy key.
The release workflow must keep signing credentials away from the job that checks out and runs the
planned source commit. Before enabling releases, add a trusted signing stage that treats the build
artifact as untrusted data, validates its paths and expected APKs, signs both helpers, updates their
checksums and manifests, and uploads the final npm tarballs. Scope the key and passwords to that
stage, pin its code to the workflow commit, and verify the certificate fingerprint. The GitHub
snapshot asset must come from those same signed package bytes. Configure
Comment thread
thymikee marked this conversation as resolved.
Resolved
`AGENT_DEVICE_ANDROID_KEYSTORE`, `AGENT_DEVICE_ANDROID_KEY_ALIAS`,
`AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD`, and `AGENT_DEVICE_ANDROID_KEY_PASSWORD` only for that stage.

The first rotated release installs beside the legacy packages. The host addresses only
`com.callstack.agentdevice.snapshothelper.v2` and `com.callstack.agentdevice.imehelper.v2`.
After you verify both rotated helpers on a device, remove the legacy packages:

```sh
adb uninstall com.callstack.agentdevice.snapshothelper
adb uninstall com.callstack.agentdevice.imehelper
```

If the legacy IME is active, select another input method before you remove it. Do not configure a
legacy helper as the restore target for a rotated helper session. Package removal is an explicit
deployment step because it changes device state and can affect an active input method.

If close reports an invalid saved keyboard, list installed input methods with `adb shell ime list -s`.
Select a non-helper keyboard with `adb shell ime set <service>`. Then delete the stale
`agent_device_ime_helper_previous_ime` and `agent_device_ime_helper_rebind_displaced` secure
settings with `adb shell settings delete secure <key>`. Restart the daemon to clear its recovery
marker after it confirms that no helper is active.

## Accessibility services

Expand All @@ -27,16 +60,23 @@ See [issue #4179](https://github.com/callstack/agent-device/issues/4179).

```sh
VERSION="$(node -p 'require("./package.json").version')"
AGENT_DEVICE_ANDROID_HELPER=snapshot sh ./scripts/build-android-helper.sh "$VERSION" .tmp/android-snapshot-helper
# Export AGENT_DEVICE_ANDROID_KEYSTORE, AGENT_DEVICE_ANDROID_KEY_ALIAS,
# AGENT_DEVICE_ANDROID_KEYSTORE_PASSWORD, and AGENT_DEVICE_ANDROID_KEY_PASSWORD
# from your secret store before running this in a trusted signing shell.
AGENT_DEVICE_ANDROID_HELPER=snapshot sh ./scripts/build-android-helper.sh \
"$VERSION" .tmp/android-snapshot-helper
```

The build uses Android SDK command-line tools directly. It expects `ANDROID_HOME` or
`ANDROID_SDK_ROOT` to point at an SDK with `platforms/android-36`, and it compiles with the
build-tools version named by `AGENT_DEVICE_ANDROID_BUILD_TOOLS` (or the script's last positional).
CI must name that version; a local build without it uses the newest version under `build-tools`
and says so on stderr.
`pnpm prepack` builds the npm-bundled helper into `android/snapshot-helper/dist`; npm users get
that APK in the package and the first helper-backed `snapshot` installs it automatically when
The root `build:android-*` and `package:android-*` scripts need the same four signing values.
`pnpm prepack` reaches those scripts through release preparation and needs the values too; it
builds the npm-bundled helper into `android/snapshot-helper/dist`.
For a local test build, use a disposable caller-owned key; never use the release signing key.
Npm users get that APK in the package and the first helper-backed `snapshot` installs it when
missing or outdated.

## Run
Expand All @@ -50,7 +90,7 @@ adb shell am instrument -w \
-e timeoutMs 8000 \
-e maxDepth 128 \
-e maxNodes 5000 \
com.callstack.agentdevice.snapshothelper/.SnapshotInstrumentation
com.callstack.agentdevice.snapshothelper.v2/com.callstack.agentdevice.snapshothelper.SnapshotInstrumentation
```

`maxDepth` also caps recursive traversal depth inside the helper.
Expand Down Expand Up @@ -80,11 +120,11 @@ Snapshot mode uses the idle wait configured above.
```sh
# Read the interactive-window viewport without capturing a snapshot.
adb shell am instrument -w -e mode viewport \
com.callstack.agentdevice.snapshothelper/.SnapshotInstrumentation
com.callstack.agentdevice.snapshothelper.v2/com.callstack.agentdevice.snapshothelper.SnapshotInstrumentation

# Inject a planned touch gesture, described by a base64 JSON payload.
adb shell am instrument -w -e mode gesture -e payloadBase64 "$PAYLOAD" \
com.callstack.agentdevice.snapshothelper/.SnapshotInstrumentation
com.callstack.agentdevice.snapshothelper.v2/com.callstack.agentdevice.snapshothelper.SnapshotInstrumentation
```

The `gesture` payload is a base64-encoded JSON object using protocol `android-touch-plan-v1`:
Expand Down
Binary file removed android/snapshot-helper/debug.keystore
Binary file not shown.
Loading
Loading