Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac82a762 authored by Iurii Makhno's avatar Iurii Makhno Committed by Android (Google) Code Review
Browse files

Merge "Do not validate localeConfig if it is referenced as external symbol."

parents eedc2745 a7ba6b68
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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");
+37 −0
Original line number Diff line number Diff line
@@ -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");