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/tests/res/raw/update_config_stream_001.json | 3 +++ updater_sample/tests/res/raw/update_config_stream_002.json | 3 +++ .../com/example/android/systemupdatersample/UpdateConfigTest.java | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'updater_sample/tests') diff --git a/updater_sample/tests/res/raw/update_config_stream_001.json b/updater_sample/tests/res/raw/update_config_stream_001.json index 15127cf2c..be51b7c95 100644 --- a/updater_sample/tests/res/raw/update_config_stream_001.json +++ b/updater_sample/tests/res/raw/update_config_stream_001.json @@ -10,5 +10,8 @@ "size": 8 } ] + }, + "ab_config": { + "force_switch_slot": true } } diff --git a/updater_sample/tests/res/raw/update_config_stream_002.json b/updater_sample/tests/res/raw/update_config_stream_002.json index cf4469b1c..5d7874cdb 100644 --- a/updater_sample/tests/res/raw/update_config_stream_002.json +++ b/updater_sample/tests/res/raw/update_config_stream_002.json @@ -1,5 +1,8 @@ { "__": "*** Generated using tools/gen_update_config.py ***", + "ab_config": { + "force_switch_slot": false + }, "ab_install_type": "STREAMING", "ab_streaming_metadata": { "property_files": [ diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java index 0975e76be..000f5663b 100644 --- a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java +++ b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java @@ -18,6 +18,7 @@ package com.example.android.systemupdatersample; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -45,7 +46,8 @@ public class UpdateConfigTest { private static final String JSON_NON_STREAMING = "{\"name\": \"vip update\", \"url\": \"file:///builds/a.zip\", " - + " \"ab_install_type\": \"NON_STREAMING\"}"; + + " \"ab_install_type\": \"NON_STREAMING\"," + + " \"ab_config\": { \"force_switch_slot\": false } }"; @Rule public final ExpectedException thrown = ExpectedException.none(); @@ -82,6 +84,7 @@ public class UpdateConfigTest { config.getStreamingMetadata().getPropertyFiles()[0].getFilename()); assertEquals(195, config.getStreamingMetadata().getPropertyFiles()[0].getOffset()); assertEquals(8, config.getStreamingMetadata().getPropertyFiles()[0].getSize()); + assertTrue(config.getAbConfig().getForceSwitchSlot()); } @Test @@ -94,7 +97,8 @@ public class UpdateConfigTest { @Test public void getUpdatePackageFile_throwsErrorIfNotAFile() throws Exception { String json = "{\"name\": \"upd\", \"url\": \"http://foo.bar\"," - + " \"ab_install_type\": \"NON_STREAMING\"}"; + + " \"ab_install_type\": \"NON_STREAMING\"," + + " \"ab_config\": { \"force_switch_slot\": false } }"; UpdateConfig config = UpdateConfig.fromJson(json); thrown.expect(RuntimeException.class); config.getUpdatePackageFile(); -- cgit v1.2.3