Merge "Make sure Proguard keeps zygote preload class."

This commit is contained in:
TreeHugger Robot
2019-03-07 13:56:21 +00:00
committed by Android (Google) Code Review
2 changed files with 12 additions and 0 deletions

View File

@@ -281,6 +281,15 @@ class ManifestVisitor : public BaseVisitor {
AddClass(node->line_number, result.value(), "");
}
}
attr = node->FindAttribute(xml::kSchemaAndroid, "zygotePreloadName");
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) {

View File

@@ -42,6 +42,7 @@ TEST(ProguardRulesTest, ManifestRuleDefaultConstructorOnly) {
android:appComponentFactory="com.foo.BarAppComponentFactory"
android:backupAgent="com.foo.BarBackupAgent"
android:name="com.foo.BarApplication"
android:zygotePreloadName="com.foo.BarZygotePreload"
>
<activity android:name="com.foo.BarActivity"/>
<service android:name="com.foo.BarService"/>
@@ -63,6 +64,7 @@ TEST(ProguardRulesTest, ManifestRuleDefaultConstructorOnly) {
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarReceiver { <init>(); }"));
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarProvider { <init>(); }"));
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarInstrumentation { <init>(); }"));
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarZygotePreload { <init>(); }"));
actual = GetKeepSetString(set, /** minimal_rules */ true);
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarAppComponentFactory { <init>(); }"));
@@ -73,6 +75,7 @@ TEST(ProguardRulesTest, ManifestRuleDefaultConstructorOnly) {
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarReceiver { <init>(); }"));
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarProvider { <init>(); }"));
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarInstrumentation { <init>(); }"));
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarZygotePreload { <init>(); }"));
}
TEST(ProguardRulesTest, FragmentNameRuleIsEmitted) {