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

Commit e4bd1602 authored by Jake Wharton's avatar Jake Wharton
Browse files

Add rule emissions for appComponentFactory

This attribute was added in API 28 and is reflectively instantiated from a zero-argument constructor.

Test: make aapt2_tests
Change-Id: Ie9de0764165c6fe6c6fcda6cc38b0cc633f03bbd
parent cfbc767b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -259,6 +259,13 @@ class ManifestVisitor : public BaseVisitor {
            AddClass(node->line_number, result.value());
          }
        }
        attr = node->FindAttribute(xml::kSchemaAndroid, "appComponentFactory");
        if (attr) {
          Maybe<std::string> result = util::GetFullyQualifiedClassName(package_, attr->value);
          if (result) {
            AddClass(node->line_number, result.value());
          }
        }
        if (main_dex_only_) {
          xml::Attribute* default_process = node->FindAttribute(xml::kSchemaAndroid, "process");
          if (default_process) {
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ TEST(ProguardRulesTest, ManifestRuleDefaultConstructorOnly) {
  std::unique_ptr<xml::XmlResource> manifest = test::BuildXmlDom(R"(
      <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <application
            android:appComponentFactory="com.foo.BarAppComponentFactory"
            android:backupAgent="com.foo.BarBackupAgent"
            android:name="com.foo.BarApplication"
            >
@@ -54,6 +55,7 @@ TEST(ProguardRulesTest, ManifestRuleDefaultConstructorOnly) {

  std::string actual = GetKeepSetString(set);

  EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarAppComponentFactory { <init>(); }"));
  EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarBackupAgent { <init>(); }"));
  EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarApplication { <init>(); }"));
  EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarActivity { <init>(); }"));