Fix aapt2 pseudo-translating donottranslate* files

Bug: 126423638

Test: After building android doing this in the 'out' folder:
Test:
Test: ./soong/host/linux-x86/bin/aapt d --values resources \
Test:     ./target/product/sailfish/system/product/priv-app/SystemUIGoogle/SystemUIGoogle.apk \
Test:     | less
Test:
Test: search for `system_ui_aod_date_pattern` in the output, found this:
Test:           (string8) "[éééḾḾḾð one two]"
Test:           (string8) "<U+200F><U+202E>eeeMMMd<U+202C><U+200F>"
Test: (the en-XA and ar-XB pseudo-translated versions of the string)
Test:
Test: After the fix and rebuild the dump only finds the original English string ("eeeMMMd")
Test: Also flashed the image, switched to en-XA, and left the phone around for more than 24 hours.
Change-Id: I2fb7c5b5ee7d3d3200410593346682ed16559056
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp
index 5336141..8577921 100644
--- a/tools/aapt2/ResourceParser_test.cpp
+++ b/tools/aapt2/ResourceParser_test.cpp
@@ -217,6 +217,29 @@
   EXPECT_THAT(str->value->spans[1].last_char, Eq(13u));
 }
 
+TEST_F(ResourceParserTest, ParseStringTranslatableAttribute) {
+  // If there is no translate attribute the default is 'true'
+  EXPECT_TRUE(TestParse(R"(<string name="foo1">Translate</string>)"));
+  String* str = test::GetValue<String>(&table_, "string/foo1");
+  ASSERT_THAT(str, NotNull());
+  ASSERT_TRUE(str->IsTranslatable());
+
+  // Explicit 'true' translate attribute
+  EXPECT_TRUE(TestParse(R"(<string name="foo2" translatable="true">Translate</string>)"));
+  str = test::GetValue<String>(&table_, "string/foo2");
+  ASSERT_THAT(str, NotNull());
+  ASSERT_TRUE(str->IsTranslatable());
+
+  // Explicit 'false' translate attribute
+  EXPECT_TRUE(TestParse(R"(<string name="foo3" translatable="false">Do not translate</string>)"));
+  str = test::GetValue<String>(&table_, "string/foo3");
+  ASSERT_THAT(str, NotNull());
+  ASSERT_FALSE(str->IsTranslatable());
+
+  // Invalid value for the translate attribute, should be boolean ('true' or 'false')
+  EXPECT_FALSE(TestParse(R"(<string name="foo4" translatable="yes">Translate</string>)"));
+}
+
 TEST_F(ResourceParserTest, IgnoreXliffTagsOtherThanG) {
   std::string input = R"(
       <string name="foo" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">