Skip to content

Commit

Permalink
Ignore Support Library Preferences proguard rules
Browse files Browse the repository at this point in the history
Ignore the preferences Support Library's overly broad -keep rules in
favor of a more limited set of necessary rules specified in
chrome/android/java/proguard.flags.

Bug: 972581
Change-Id: I7c8d36ff950a58c32ed2e7ddb0a639f28502f77f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773211
Reviewed-by: Sam Maier <smaier@chromium.org>
Commit-Queue: Natalie Chouinard <chouinard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691224}
  • Loading branch information
sudonatalie authored and Commit Bot committed Aug 28, 2019
1 parent cfade93 commit d65f5f6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@
public <init>();
}

# Referenced by android.support.v7.preference.PreferenceInflater
-keep public class android.support.v14.preference.SwitchPreference {}

# Inflated via reflection
-keep public class android.support.v7.preference.Preference {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class android.support.v7.preference.PreferenceScreen {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class android.support.v7.preference.PreferenceCategory {
public <init>(android.content.Context, android.util.AttributeSet);
}

# These classes aren't themselves referenced, but __ProcessService[0,1,2...] are
# referenced, and we look up these services by appending a number onto the name
# of the base class. Thus, we need to keep the base class name around so that
Expand Down Expand Up @@ -433,31 +447,6 @@
# keep rules. Add a commonly used SearchView to the keep list until b/109831488 is resolved.
-keep class android.support.v7.widget.SearchView { <init>(...); }

################################################################################
# obj/third_party/android_deps/com_android_support_preference_v7_java/proguard.txt
################################################################################
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Preference objects are inflated via reflection
-keep public class android.support.v7.preference.Preference {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class * extends android.support.v7.preference.Preference {
public <init>(android.content.Context, android.util.AttributeSet);
}

################################################################################
# obj/third_party/android_deps/com_android_support_recyclerview_v7_java/proguard.txt
################################################################################
Expand Down
14 changes: 14 additions & 0 deletions chrome/android/java/proguard.flags
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
public <init>();
}

# Referenced by android.support.v7.preference.PreferenceInflater
-keep public class android.support.v14.preference.SwitchPreference {}

# Inflated via reflection
-keep public class android.support.v7.preference.Preference {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class android.support.v7.preference.PreferenceScreen {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keep public class android.support.v7.preference.PreferenceCategory {
public <init>(android.content.Context, android.util.AttributeSet);
}

# These classes aren't themselves referenced, but __ProcessService[0,1,2...] are
# referenced, and we look up these services by appending a number onto the name
# of the base class. Thus, we need to keep the base class name around so that
Expand Down
3 changes: 2 additions & 1 deletion third_party/android_deps/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ java_annotation_processor("dagger_processor") {
}

# The section below is generated by running
# `//tools/android/roll/android_deps/fetch_all.sh`
# `//tools/android/roll/android_deps/fetch_all.py`

# === Generated Code Start ===
# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
Expand Down Expand Up @@ -338,6 +338,7 @@ android_aar_prebuilt("com_android_support_preference_v7_java") {
":com_android_support_support_compat_java",
":com_android_support_support_fragment_java",
]
ignore_proguard_configs = true
}

# This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ class BuildConfigGenerator extends DefaultTask {
sb.append(' # Target needs to exclude *xmlpull* files as already included in Android SDK.\n')
sb.append(' jar_excluded_patterns = [ "*xmlpull*" ]\n')
break
case 'com_android_support_preference_v7':
// Replace broad library -keep rules with a more limited set in
// chrome/android/java/proguard.flags instead.
sb.append(' ignore_proguard_configs = true\n')
break
}
}

Expand Down

0 comments on commit d65f5f6

Please sign in to comment.