From 238beb73739071735a6bcbe462e27ab09a747f02 Mon Sep 17 00:00:00 2001 From: Zhomart Mukhamejanov Date: Wed, 9 May 2018 16:25:40 -0700 Subject: updater_sample: add switch slot demo - Add util/UpdateEngineProperties.java - Set SWITCH_SLOT_ON_REBOOT=0 when update is applied - Allow user to switch slot to the updated partition manually - Add config "ab_config.force_switch_slot" - Add ab_force_switch_slot to tools/gen_update_config.py Test: manually on the marlin device Bug: 79492522 Change-Id: I52f818b576d52a052b5427ba3f732cb2371ddb06 Signed-off-by: Zhomart Mukhamejanov --- updater_sample/README.md | 6 +- updater_sample/res/layout/activity_main.xml | 17 +++++ updater_sample/res/raw/sample.json | 5 ++ updater_sample/res/values/strings.xml | 2 + .../android/systemupdatersample/UpdateConfig.java | 48 +++++++++++-- .../systemupdatersample/ui/MainActivity.java | 83 ++++++++++++++++++++-- .../util/UpdateEngineProperties.java | 37 ++++++++++ .../tests/res/raw/update_config_stream_001.json | 3 + .../tests/res/raw/update_config_stream_002.json | 3 + .../systemupdatersample/UpdateConfigTest.java | 8 ++- updater_sample/tools/gen_update_config.py | 14 +++- 11 files changed, 210 insertions(+), 16 deletions(-) create mode 100644 updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineProperties.java diff --git a/updater_sample/README.md b/updater_sample/README.md index 95e57dbe9..c68c07caf 100644 --- a/updater_sample/README.md +++ b/updater_sample/README.md @@ -44,6 +44,10 @@ saved uncompressed (`ZIP_STORED`), so that their data can be downloaded directly with the offset and length. As `payload.bin` itself is already in compressed format, the size penalty is marginal. +if `ab_config.force_switch_slot` set true device will boot to the +updated partition on next reboot; otherwise button "Switch Slot" will +become active, and user can manually set updated partition as the active slot. + Config files can be generated using `tools/gen_update_config.py`. Running `./tools/gen_update_config.py --help` shows usage of the script. @@ -85,8 +89,8 @@ which HTTP headers are supported. - [x] Add stop/reset the update - [x] Add demo for passing HTTP headers to `UpdateEngine#applyPayload` - [x] [Package compatibility check](https://source.android.com/devices/architecture/vintf/match-rules) +- [x] Deferred switch slot demo - [ ] Add tests for `MainActivity` -- [ ] Change partition demo - [ ] Verify system partition checksum for package - [ ] Add non-A/B updates demo diff --git a/updater_sample/res/layout/activity_main.xml b/updater_sample/res/layout/activity_main.xml index 7a12d3474..d9e56b4b3 100644 --- a/updater_sample/res/layout/activity_main.xml +++ b/updater_sample/res/layout/activity_main.xml @@ -178,6 +178,23 @@ android:text="Reset" /> + + +