To address the warning below (which will be disallowed): bootable/recovery/updater_sample/tests/Android.mk: warning: SystemUpdaterSampleTests (java:system) should not link to android.test.runner (java:platform) (See b/69899800 or the commit message in [1] for detailed discussions.) [1]: https://android-review.googlesource.com/c/platform/frameworks/ml/+/666428 Test: `mmma -j bootable/recovery` gives no warning. Test: Install and run SystemUpdaterSampleTests on device. Change-Id: I12a1556d572d9f332fcf43dc84cbe8fd1b6df89b
SystemUpdaterSample
This app demonstrates how to use Android system updates APIs to install
OTA updates. It contains a sample
client for update_engine to install A/B (seamless) updates and a sample of
applying non-A/B updates using recovery.
A/B (seamless) update is available since Android Nougat (API 24), but this sample targets the latest android.
Running on a device
The commands expected to be run from $ANDROID_BUILD_TOP.
- Compile the app
$ mmma bootable/recovery/updater_sample. - Install the app to the device using
$ adb install <APK_PATH>. - Add update config files.
Update Config file
Directory can be found in logs or on UI. Usually json config files are located in
/data/user/0/com.example.android.systemupdatersample/files/configs/. Example file
is located at res/raw/sample.json.
Development
- Create a UI with list of configs, current version, control buttons, progress bar and log viewer
- Add
PayloadSpecandPayloadSpecsfor working with update zip file - Add
UpdateConfigfor working with json config files - Add applying non-streaming update
- Add applying streaming update
- Prepare streaming update (partially downloading package)
- Add tests for
MainActivity - Add stop/reset the update
- Verify system partition checksum for package
- HAL compatibility check
- Change partition demo
- Add non-A/B updates demo
Running tests
- Build
$ mmma bootable/recovery/updater_sample/ - Install app
$ adb install $OUT/system/app/SystemUpdaterSample/SystemUpdaterSample.apk - Install tests
$ adb install $OUT/testcases/SystemUpdaterSampleTests/SystemUpdaterSampleTests.apk - Run tests
$ adb shell am instrument -w com.example.android.systemupdatersample.tests/android.support.test.runner.AndroidJUnitRunner - Run a test file
$ adb shell am instrument \ -w com.example.android.systemupdatersample.tests/android.support.test.runner.AndroidJUnitRunner \ -c com.example.android.systemupdatersample.util.PayloadSpecsTest
Getting access to update_engine API and read/write access to /data
Run adb shell as a root, and set SELinux mode to permissive (0):
$ adb root
$ adb shell
# setenforce 0
# getenforce