From c6f8fb0c4f1204bd85a2ec75958076787d769b0b Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Wed, 20 Apr 2022 18:58:53 +0900 Subject: [PATCH] Enable optimizer on service-connectivity The optimizer has been enabled in downstream branches (including those used for upcoming module releases) for a few months. This brings aosp in line with them. This is a cherry-pick of change: I3be9422a431a5b5bc1478960ce332a89377bd632 where proguard.flags have been replaced with the most up-to-date version used in downstream branches. Test: m Merged-In: I3be9422a431a5b5bc1478960ce332a89377bd632 Change-Id: I55455eb58d3fdc4dbf3ea81961d5c7756fea0046 --- service/Android.bp | 5 +++++ service/proguard.flags | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 service/proguard.flags diff --git a/service/Android.bp b/service/Android.bp index 25b970a4d5..7dbdc92a69 100644 --- a/service/Android.bp +++ b/service/Android.bp @@ -216,6 +216,11 @@ java_library { apex_available: [ "com.android.tethering", ], + optimize: { + enabled: true, + shrink: true, + proguard_flags_files: ["proguard.flags"], + }, lint: { strict_updatability_linting: true }, } diff --git a/service/proguard.flags b/service/proguard.flags new file mode 100644 index 0000000000..94397ab5f1 --- /dev/null +++ b/service/proguard.flags @@ -0,0 +1,18 @@ +# Make sure proguard keeps all connectivity classes +# TODO: instead of keeping everything, consider listing only "entry points" +# (service loader, JNI registered methods, etc) and letting the optimizer do its job +-keep class android.net.** { *; } +-keep class com.android.connectivity.** { *; } +-keep class com.android.net.** { *; } +-keep class !com.android.server.nearby.**,com.android.server.** { *; } + +# Prevent proguard from stripping out any nearby-service and fast-pair-lite-protos fields. +-keep class com.android.server.nearby.NearbyService { *; } +-keep class com.android.server.nearby.service.proto { *; } + +# The lite proto runtime uses reflection to access fields based on the names in +# the schema, keep all the fields. +# This replicates the base proguard rule used by the build by default +# (proguard_basic_keeps.flags), but needs to be specified here because the +# com.google.protobuf package is jarjared to the below package. +-keepclassmembers class * extends com.android.connectivity.com.google.protobuf.MessageLite { ; }