Move ab_streaming_metadata under ab_config.

Add new config: ab_config.verify_payload_metadata.

Change-Id: I521dff92166c33dd9c2efa498dc599fe4bc83fde
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
Test: mmm, junit
Bug: 77150191
diff --git a/updater_sample/tests/res/raw/update_config_001_stream.json b/updater_sample/tests/res/raw/update_config_001_stream.json
index be51b7c..b024ad9 100644
--- a/updater_sample/tests/res/raw/update_config_001_stream.json
+++ b/updater_sample/tests/res/raw/update_config_001_stream.json
@@ -2,7 +2,9 @@
     "name": "streaming-001",
     "url": "http://foo.bar/update.zip",
     "ab_install_type": "STREAMING",
-    "ab_streaming_metadata": {
+    "ab_config": {
+        "verify_payload_metadata": true,
+        "force_switch_slot": true,
         "property_files": [
             {
                 "filename": "payload.bin",
@@ -10,8 +12,5 @@
                 "size": 8
             }
         ]
-    },
-    "ab_config": {
-        "force_switch_slot": true
     }
 }
diff --git a/updater_sample/tests/res/raw/update_config_002_stream.json b/updater_sample/tests/res/raw/update_config_002_stream.json
index 40c8fe1..12c18bb 100644
--- a/updater_sample/tests/res/raw/update_config_002_stream.json
+++ b/updater_sample/tests/res/raw/update_config_002_stream.json
@@ -1,10 +1,8 @@
 {
     "__": "*** Generated using tools/gen_update_config.py ***",
     "ab_config": {
-        "force_switch_slot": false
-    },
-    "ab_install_type": "STREAMING",
-    "ab_streaming_metadata": {
+        "verify_payload_metadata": true,
+        "force_switch_slot": false,
         "property_files": [
             {
                 "filename": "payload_metadata.bin",
@@ -38,6 +36,7 @@
             }
         ]
     },
+    "ab_install_type": "STREAMING",
     "name": "S ota_002_package",
     "url": "file:///data/my-sample-ota-builds-dir/ota_002_package.zip"
 }
\ No newline at end of file
diff --git a/updater_sample/tests/res/raw/update_config_003_nonstream.json b/updater_sample/tests/res/raw/update_config_003_nonstream.json
index 7c78b9d..2011f76 100644
--- a/updater_sample/tests/res/raw/update_config_003_nonstream.json
+++ b/updater_sample/tests/res/raw/update_config_003_nonstream.json
@@ -1,7 +1,15 @@
 {
     "__": "*** Generated using tools/gen_update_config.py ***",
     "ab_config": {
-        "force_switch_slot": false
+        "verify_payload_metadata": true,
+        "force_switch_slot": false,
+        "property_files": [
+            {
+                "filename": "payload.bin",
+                "offset": 195,
+                "size": 8
+            }
+        ]
     },
     "ab_install_type": "NON_STREAMING",
     "name": "S ota_002_package",
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 1cbd860..48d0e42 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/UpdateConfigTest.java
@@ -44,10 +44,12 @@
 @SmallTest
 public class UpdateConfigTest {
 
-    private static final String JSON_NON_STREAMING =
-            "{\"name\": \"vip update\", \"url\": \"file:///builds/a.zip\", "
-                    + " \"ab_install_type\": \"NON_STREAMING\","
-                    + " \"ab_config\": { \"force_switch_slot\": false } }";
+    private static final String JSON_NON_STREAMING = "{"
+            + " \"name\": \"vip update\", \"url\": \"file:///my-builds/a.zip\","
+            + " \"ab_install_type\": \"NON_STREAMING\","
+            + " \"ab_config\": {"
+            + "     \"force_switch_slot\": false,"
+            + "     \"verify_payload_metadata\": false } }";
 
     @Rule
     public final ExpectedException thrown = ExpectedException.none();
@@ -71,7 +73,7 @@
         assertSame("type is parsed",
                 UpdateConfig.AB_INSTALL_TYPE_NON_STREAMING,
                 config.getInstallType());
-        assertEquals("url is parsed", "file:///builds/a.zip", config.getUrl());
+        assertEquals("url is parsed", "file:///my-builds/a.zip", config.getUrl());
     }
 
     @Test
@@ -81,9 +83,9 @@
         assertEquals("http://foo.bar/update.zip", config.getUrl());
         assertSame(UpdateConfig.AB_INSTALL_TYPE_STREAMING, config.getInstallType());
         assertEquals("payload.bin",
-                config.getStreamingMetadata().getPropertyFiles()[0].getFilename());
-        assertEquals(195, config.getStreamingMetadata().getPropertyFiles()[0].getOffset());
-        assertEquals(8, config.getStreamingMetadata().getPropertyFiles()[0].getSize());
+                config.getAbConfig().getPropertyFiles()[0].getFilename());
+        assertEquals(195, config.getAbConfig().getPropertyFiles()[0].getOffset());
+        assertEquals(8, config.getAbConfig().getPropertyFiles()[0].getSize());
         assertTrue(config.getAbConfig().getForceSwitchSlot());
     }
 
@@ -96,9 +98,12 @@
 
     @Test
     public void getUpdatePackageFile_throwsErrorIfNotAFile() throws Exception {
-        String json = "{\"name\": \"upd\", \"url\": \"http://foo.bar\","
+        String json = "{"
+                + " \"name\": \"upd\", \"url\": \"http://foo.bar\","
                 + " \"ab_install_type\": \"NON_STREAMING\","
-                + " \"ab_config\": { \"force_switch_slot\": false } }";
+                + " \"ab_config\": {"
+                + "     \"force_switch_slot\": false,"
+                + "     \"verify_payload_metadata\": false } }";
         UpdateConfig config = UpdateConfig.fromJson(json);
         thrown.expect(RuntimeException.class);
         config.getUpdatePackageFile();
@@ -107,7 +112,7 @@
     @Test
     public void getUpdatePackageFile_works() throws Exception {
         UpdateConfig c = UpdateConfig.fromJson(JSON_NON_STREAMING);
-        assertEquals("/builds/a.zip", c.getUpdatePackageFile().getAbsolutePath());
+        assertEquals("/my-builds/a.zip", c.getUpdatePackageFile().getAbsolutePath());
     }
 
     private String readResource(int id) throws IOException {