Loading tools/aapt2/cmd/Link.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -1085,6 +1085,10 @@ class Linker { const auto localeconfig_entry = ResolveTableEntry(context_, &final_table_, localeconfig_reference); if (!localeconfig_entry) { // If locale config is resolved from external symbols - skip validation. if (context_->GetExternalSymbols()->FindByReference(*localeconfig_reference)) { return true; } context_->GetDiagnostics()->Error( android::DiagMessage(localeConfig->compiled_value->GetSource()) << "no localeConfig entry"); Loading tools/aapt2/cmd/Link_test.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -840,6 +840,43 @@ TEST_F(LinkTest, LocaleConfigVerification) { ASSERT_TRUE(Link(link1_args, &diag)); } TEST_F(LinkTest, LocaleConfigVerificationExternalSymbol) { StdErrDiagnostics diag; const std::string base_files_dir = GetTestPath("base"); ASSERT_TRUE(CompileFile(GetTestPath("res/xml/locales_config.xml"), R"( <locale-config xmlns:android="http://schemas.android.com/apk/res/android"> <locale android:name="en-US"/> <locale android:name="pt"/> <locale android:name="es-419"/> <locale android:name="zh-Hans-SG"/> </locale-config>)", base_files_dir, &diag)); const std::string base_apk = GetTestPath("base.apk"); std::vector<std::string> link_args = { "--manifest", GetDefaultManifest("com.aapt2.app"), "-o", base_apk, }; ASSERT_TRUE(Link(link_args, base_files_dir, &diag)); const std::string localeconfig_manifest = GetTestPath("localeconfig_manifest.xml"); const std::string out_apk = GetTestPath("out.apk"); WriteFile(localeconfig_manifest, android::base::StringPrintf(R"( <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aapt2.app"> <application android:localeConfig="@xml/locales_config"> </application> </manifest>)")); link_args = LinkCommandBuilder(this) .SetManifestFile(localeconfig_manifest) .AddParameter("-I", base_apk) .Build(out_apk); ASSERT_TRUE(Link(link_args, &diag)); } TEST_F(LinkTest, LocaleConfigWrongTag) { StdErrDiagnostics diag; const std::string compiled_files_dir = GetTestPath("compiled"); Loading Loading
tools/aapt2/cmd/Link.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -1085,6 +1085,10 @@ class Linker { const auto localeconfig_entry = ResolveTableEntry(context_, &final_table_, localeconfig_reference); if (!localeconfig_entry) { // If locale config is resolved from external symbols - skip validation. if (context_->GetExternalSymbols()->FindByReference(*localeconfig_reference)) { return true; } context_->GetDiagnostics()->Error( android::DiagMessage(localeConfig->compiled_value->GetSource()) << "no localeConfig entry"); Loading
tools/aapt2/cmd/Link_test.cpp +37 −0 Original line number Diff line number Diff line Loading @@ -840,6 +840,43 @@ TEST_F(LinkTest, LocaleConfigVerification) { ASSERT_TRUE(Link(link1_args, &diag)); } TEST_F(LinkTest, LocaleConfigVerificationExternalSymbol) { StdErrDiagnostics diag; const std::string base_files_dir = GetTestPath("base"); ASSERT_TRUE(CompileFile(GetTestPath("res/xml/locales_config.xml"), R"( <locale-config xmlns:android="http://schemas.android.com/apk/res/android"> <locale android:name="en-US"/> <locale android:name="pt"/> <locale android:name="es-419"/> <locale android:name="zh-Hans-SG"/> </locale-config>)", base_files_dir, &diag)); const std::string base_apk = GetTestPath("base.apk"); std::vector<std::string> link_args = { "--manifest", GetDefaultManifest("com.aapt2.app"), "-o", base_apk, }; ASSERT_TRUE(Link(link_args, base_files_dir, &diag)); const std::string localeconfig_manifest = GetTestPath("localeconfig_manifest.xml"); const std::string out_apk = GetTestPath("out.apk"); WriteFile(localeconfig_manifest, android::base::StringPrintf(R"( <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.aapt2.app"> <application android:localeConfig="@xml/locales_config"> </application> </manifest>)")); link_args = LinkCommandBuilder(this) .SetManifestFile(localeconfig_manifest) .AddParameter("-I", base_apk) .Build(out_apk); ASSERT_TRUE(Link(link_args, &diag)); } TEST_F(LinkTest, LocaleConfigWrongTag) { StdErrDiagnostics diag; const std::string compiled_files_dir = GetTestPath("compiled"); Loading