Add ability to pass in a config string for FRROs

This enables passing them and and storing them in the .frro file but no
further.

Bug: 243066074
Test: Manual
Change-Id: I5c9723e69d175a536f9739619c6b6bf3162a5027
diff --git a/cmds/idmap2/tests/FabricatedOverlayTests.cpp b/cmds/idmap2/tests/FabricatedOverlayTests.cpp
index 91331ca..e804c87 100644
--- a/cmds/idmap2/tests/FabricatedOverlayTests.cpp
+++ b/cmds/idmap2/tests/FabricatedOverlayTests.cpp
@@ -43,10 +43,17 @@
 TEST(FabricatedOverlayTests, SetResourceValue) {
   auto overlay =
       FabricatedOverlay::Builder("com.example.overlay", "SandTheme", "com.example.target")
-          .SetResourceValue("com.example.target:integer/int1", Res_value::TYPE_INT_DEC, 1U)
-          .SetResourceValue("com.example.target.split:integer/int2", Res_value::TYPE_INT_DEC, 2U)
-          .SetResourceValue("string/int3", Res_value::TYPE_REFERENCE, 0x7f010000)
-          .SetResourceValue("com.example.target:string/string1", Res_value::TYPE_STRING, "foobar")
+          .SetResourceValue(
+              "com.example.target:integer/int1", Res_value::TYPE_INT_DEC, 1U, "port")
+          .SetResourceValue(
+              "com.example.target.split:integer/int2", Res_value::TYPE_INT_DEC, 2U, "land")
+          .SetResourceValue(
+              "string/int3", Res_value::TYPE_REFERENCE, 0x7f010000, "xxhdpi-v7")
+          .SetResourceValue(
+              "com.example.target:string/string1",
+              Res_value::TYPE_STRING,
+              "foobar",
+              "en-rUS-normal-xxhdpi-v21")
           .Build();
   ASSERT_TRUE(overlay);
   auto container = FabricatedOverlayContainer::FromOverlay(std::move(*overlay));
@@ -66,44 +73,48 @@
 
   auto& it = pairs->pairs[0];
   ASSERT_EQ("com.example.target:integer/int1", it.resource_name);
-  auto entry = std::get_if<TargetValue>(&it.value);
+  auto entry = std::get_if<TargetValueWithConfig>(&it.value);
   ASSERT_NE(nullptr, entry);
-  ASSERT_EQ(1U, entry->data_value);
-  ASSERT_EQ(Res_value::TYPE_INT_DEC, entry->data_type);
+  ASSERT_EQ(1U, entry->value.data_value);
+  ASSERT_EQ(Res_value::TYPE_INT_DEC, entry->value.data_type);
+  ASSERT_EQ("port", entry->config);
 
   it = pairs->pairs[1];
   ASSERT_EQ("com.example.target:string/int3", it.resource_name);
-  entry = std::get_if<TargetValue>(&it.value);
+  entry = std::get_if<TargetValueWithConfig>(&it.value);
   ASSERT_NE(nullptr, entry);
-  ASSERT_EQ(0x7f010000, entry->data_value);
-  ASSERT_EQ(Res_value::TYPE_REFERENCE, entry->data_type);
+  ASSERT_EQ(0x7f010000, entry->value.data_value);
+  ASSERT_EQ(Res_value::TYPE_REFERENCE, entry->value.data_type);
+  ASSERT_EQ("xxhdpi-v7", entry->config);
 
   it = pairs->pairs[2];
   ASSERT_EQ("com.example.target:string/string1", it.resource_name);
-  entry = std::get_if<TargetValue>(&it.value);
+  entry = std::get_if<TargetValueWithConfig>(&it.value);
   ASSERT_NE(nullptr, entry);
-  ASSERT_EQ(Res_value::TYPE_STRING, entry->data_type);
-  ASSERT_EQ(std::string("foobar"), string_pool.string8At(entry->data_value).value_or(""));
+  ASSERT_EQ(Res_value::TYPE_STRING, entry->value.data_type);
+  ASSERT_EQ(std::string("foobar"), string_pool.string8At(entry->value.data_value).value_or(""));
+  ASSERT_EQ("en-rUS-normal-xxhdpi-v21", entry->config);
 
   it = pairs->pairs[3];
   ASSERT_EQ("com.example.target.split:integer/int2", it.resource_name);
-  entry = std::get_if<TargetValue>(&it.value);
+  entry = std::get_if<TargetValueWithConfig>(&it.value);
   ASSERT_NE(nullptr, entry);
-  ASSERT_EQ(2U, entry->data_value);
-  ASSERT_EQ(Res_value::TYPE_INT_DEC, entry->data_type);
+  ASSERT_EQ(2U, entry->value.data_value);
+  ASSERT_EQ(Res_value::TYPE_INT_DEC, entry->value.data_type);
+  ASSERT_EQ("land", entry->config);
 }
 
 TEST(FabricatedOverlayTests, SetResourceValueBadArgs) {
   {
     auto builder =
         FabricatedOverlay::Builder("com.example.overlay", "SandTheme", "com.example.target")
-            .SetResourceValue("int1", Res_value::TYPE_INT_DEC, 1U);
+            .SetResourceValue("int1", Res_value::TYPE_INT_DEC, 1U, "");
     ASSERT_FALSE(builder.Build());
   }
   {
     auto builder =
         FabricatedOverlay::Builder("com.example.overlay", "SandTheme", "com.example.target")
-            .SetResourceValue("com.example.target:int2", Res_value::TYPE_INT_DEC, 1U);
+            .SetResourceValue("com.example.target:int2", Res_value::TYPE_INT_DEC, 1U, "");
     ASSERT_FALSE(builder.Build());
   }
 }
@@ -112,8 +123,9 @@
   auto overlay =
       FabricatedOverlay::Builder("com.example.overlay", "SandTheme", "com.example.target")
           .SetOverlayable("TestResources")
-          .SetResourceValue("com.example.target:integer/int1", Res_value::TYPE_INT_DEC, 1U)
-          .SetResourceValue("com.example.target:string/string1", Res_value::TYPE_STRING, "foobar")
+          .SetResourceValue("com.example.target:integer/int1", Res_value::TYPE_INT_DEC, 1U, "")
+          .SetResourceValue(
+              "com.example.target:string/string1", Res_value::TYPE_STRING, "foobar", "")
           .Build();
   ASSERT_TRUE(overlay);
   TemporaryFile tf;
@@ -142,17 +154,17 @@
 
   auto& it = pairs->pairs[0];
   ASSERT_EQ("com.example.target:integer/int1", it.resource_name);
-  auto entry = std::get_if<TargetValue>(&it.value);
+  auto entry = std::get_if<TargetValueWithConfig>(&it.value);
   ASSERT_NE(nullptr, entry);
-  EXPECT_EQ(1U, entry->data_value);
-  EXPECT_EQ(Res_value::TYPE_INT_DEC, entry->data_type);
+  EXPECT_EQ(1U, entry->value.data_value);
+  EXPECT_EQ(Res_value::TYPE_INT_DEC, entry->value.data_type);
 
   it = pairs->pairs[1];
   ASSERT_EQ("com.example.target:string/string1", it.resource_name);
-  entry = std::get_if<TargetValue>(&it.value);
+  entry = std::get_if<TargetValueWithConfig>(&it.value);
   ASSERT_NE(nullptr, entry);
-  ASSERT_EQ(Res_value::TYPE_STRING, entry->data_type);
-  ASSERT_EQ(std::string("foobar"), string_pool.string8At(entry->data_value).value_or(""));
+  ASSERT_EQ(Res_value::TYPE_STRING, entry->value.data_type);
+  ASSERT_EQ(std::string("foobar"), string_pool.string8At(entry->value.data_value).value_or(""));
 }
 
 }  // namespace android::idmap2
diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp
index a3799f9..ee9a424 100644
--- a/cmds/idmap2/tests/IdmapTests.cpp
+++ b/cmds/idmap2/tests/IdmapTests.cpp
@@ -261,9 +261,9 @@
 
   auto frro = FabricatedOverlay::Builder("com.example.overlay", "SandTheme", "test.target")
                   .SetOverlayable("TestResources")
-                  .SetResourceValue("integer/int1", Res_value::TYPE_INT_DEC, 2U)
-                  .SetResourceValue("string/str1", Res_value::TYPE_REFERENCE, 0x7f010000)
-                  .SetResourceValue("string/str2", Res_value::TYPE_STRING, "foobar")
+                  .SetResourceValue("integer/int1", Res_value::TYPE_INT_DEC, 2U, "")
+                  .SetResourceValue("string/str1", Res_value::TYPE_REFERENCE, 0x7f010000, "")
+                  .SetResourceValue("string/str2", Res_value::TYPE_STRING, "foobar", "")
                   .Build();
 
   ASSERT_TRUE(frro);
diff --git a/cmds/idmap2/tests/ResourceMappingTests.cpp b/cmds/idmap2/tests/ResourceMappingTests.cpp
index c05abcf..ca9a444 100644
--- a/cmds/idmap2/tests/ResourceMappingTests.cpp
+++ b/cmds/idmap2/tests/ResourceMappingTests.cpp
@@ -194,9 +194,9 @@
 TEST(ResourceMappingTests, FabricatedOverlay) {
   auto frro = FabricatedOverlay::Builder("com.example.overlay", "SandTheme", "test.target")
                   .SetOverlayable("TestResources")
-                  .SetResourceValue("integer/int1", Res_value::TYPE_INT_DEC, 2U)
-                  .SetResourceValue("string/str1", Res_value::TYPE_REFERENCE, 0x7f010000)
-                  .SetResourceValue("string/str2", Res_value::TYPE_STRING, "foobar")
+                  .SetResourceValue("integer/int1", Res_value::TYPE_INT_DEC, 2U, "")
+                  .SetResourceValue("string/str1", Res_value::TYPE_REFERENCE, 0x7f010000, "")
+                  .SetResourceValue("string/str2", Res_value::TYPE_STRING, "foobar", "")
                   .Build();
 
   ASSERT_TRUE(frro);