Android Process-Death State Restoration Check
Exercise an Android app through a real adb force-stop and cold relaunch, then verify that important visible state survives. Use it for Android and Jetpack Compose state-restoration regression checks that should go beyond a saved-state unit test.
The runner uses Android's UI hierarchy dump to verify text before and after process death. Your app must display a test marker for the state being checked. It supports a durable cold-start check and a background-process kill mode that can exercise activity saved-state restoration.
Install
python -m pip install android-process-death-check
Install Android platform-tools, enable USB debugging or start an emulator, and confirm the device is visible with adb devices.
Run a check
android-process-death-check \
--package com.example.notes \
--component com.example.notes/.MainActivity \
--expect-before "Draft 42" \
--expect-after "Draft 42" \
--mode background-kill \
--persist-regex 'Draft marker: ([A-Za-z0-9-]+)'
The force-stop mode launches, checks, force-stops, and cold-starts the activity. The background-kill mode sends the app home, asks Android to kill its background process, verifies the process exited, and relaunches the existing task. With --persist-regex, the runner compares one captured marker before and after without printing the UI hierarchy. Use --device SERIAL when multiple devices are connected. Exit code 0 means assertions passed, 1 means state was missing or changed, and 2 means the adb check could not run.
Compose and Android state testing
Keep transient UI state that must survive process death in SavedStateHandle or rememberSaveable, and durable application data in storage. Expose an accessibility marker from that state and compare it with --persist-regex. The background-kill mode approximates OS process reclamation; device/OS behavior varies, so pair it with instrumentation tests and test the Android versions you support. Avoid asserting transient animation or time-dependent labels.
The example/ directory contains a small Compose app whose UUID is stored only through rememberSaveable. Build it with Android Studio or Gradle, install dev.buxerr.processdeathfixture, then run:
android-process-death-check \
--package dev.buxerr.processdeathfixture \
--component dev.buxerr.processdeathfixture/.MainActivity \
--mode background-kill \
--persist-regex 'Saved marker: ([a-f0-9-]+)'
The expected result is the same captured UUID after Android kills and recreates the background activity process.
Development
python -m unittest discover -s tests -v
Keywords: Android process death test, Compose state restoration, adb force stop relaunch test, Android saved state CI, process recreation UI test.
License
MIT
Metadata
Release files for android-process-death-check 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| android_process_death_check-0.1.0.tar.gz | 7.1 kB | With provenance | Details for android_process_death_check-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| android_process_death_check-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for android_process_death_check-0.1.0-py3-none-any.whl |
Total release size: 14.3 kB
Release files / android_process_death_check-0.1.0.tar.gz
| Download URL | android_process_death_check-0.1.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e703d9f857d07c0c32e7f7f876c740f71179231a307f17b65baa0c11bff849c6
|
|
BLAKE2b-256 checksum How to use checksums |
87dfbb342efa9f0a7b73cf13b049357cf28f3fafc76c90d0aec8c92017541098
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / android_process_death_check-0.1.0-py3-none-any.whl
| Download URL | android_process_death_check-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1567879677f83e3e1f896b9e16ef412470b0cc38f8254c544ba94e48a54ae176
|
|
BLAKE2b-256 checksum How to use checksums |
8340079e73c00e7421c8cd02bb650298cda944f70fc0884e6fd04c71b3d6fe20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logSecurity for android-process-death-check 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for android_process_death_check-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.