From 2fb24a2e4a82ccf5a9932bd633c8c7a97fcbfe8b Mon Sep 17 00:00:00 2001 From: Paul Westbrook Date: Fri, 1 Aug 2014 10:53:36 -0700 Subject: [PATCH] Use test proguard config for eng builds Since unit tests only run on eng builds, modify the proguard config to only keep the methods/classes needed for unit tests in eng builds The test proguard config probably is keeping too many methods. We should also evaluate whether it is valid for unit test to use methods that are not used in user builds The resulting apk size is 8714188 bytes, from 9866129 According to the proguard output, the final number of program classes is 4409, from the previous count of 10932 Change-Id: Ie7065a454e1ff80a4b3f953684940d88b17f6db7 --- Android.mk | 3 + proguard-test.flags | 170 ++++++++++++++++++++++++++++++++++++++++++++ proguard.flags | 169 ------------------------------------------- 3 files changed, 173 insertions(+), 169 deletions(-) create mode 100644 proguard-test.flags diff --git a/Android.mk b/Android.mk index dfdd97712..7dcbb4d34 100644 --- a/Android.mk +++ b/Android.mk @@ -55,6 +55,9 @@ LOCAL_STATIC_JAVA_LIBRARIES += owasp-html-sanitizer LOCAL_PACKAGE_NAME := Email LOCAL_PROGUARD_FLAG_FILES := proguard.flags $(unified_email_dir)/proguard.flags +ifeq (eng,$(TARGET_BUILD_VARIANT)) + LOCAL_PROGUARD_FLAG_FILES += proguard-test.flags +endif LOCAL_SDK_VERSION := current diff --git a/proguard-test.flags b/proguard-test.flags new file mode 100644 index 000000000..f0e87428d --- /dev/null +++ b/proguard-test.flags @@ -0,0 +1,170 @@ +#Email-specific proguard flags, required for tests, that are not covered by UnifiedEmail go here + +-keep class com.android.emailcommon.provider.Account + +-keepclasseswithmembers class * { + public static void actionEditIncomingSettings(android.app.Activity, int, com.android.emailcommon.provider.Account); +} + +-keepclasseswithmembers class * { + public static void actionEditOutgoingSettings(android.app.Activity, int, com.android.emailcommon.provider.Account); +} + +-keepclasseswithmembers class * { + public *** newInstance(com.android.emailcommon.provider.Account, android.content.Context); +} + +-keepclasseswithmembers class android.content.SharedPreferences$Editor { + *** apply(); +} + +-keep class * extends org.apache.james.mime4j.util.TempStorage + +# Keep names that are used only by unit tests or by animators +-keep class ** { + *** *ForTest(...); + *** *Anim(...); +} + +-keepclasseswithmembers class com.android.emailcommon.internet.Rfc822Output { + *** getHtmlBody(java.lang.String); + *** buildBodyText(android.content.Context, com.android.emailcommon.provider.EmailContent$Message, boolean); +} + +-keepclasseswithmembers class com.android.emailcommon.mail.Address { + (java.lang.String); + (java.lang.String,java.lang.String); + *** parseAndPack(java.lang.String); +} + +-keepclasseswithmembers class com.android.email.SecurityPolicy { + *** setContext(android.content.Context); +} + +-keepclasseswithmembers class com.android.emailcommon.utility.Utility { + *** dumpCursor(android.database.Cursor); + *** fromUtf8(byte[]); + *** isFirstUtf8Byte(byte); + *** replaceBareLfWithCrlf(java.lang.String); +} + +-keepclasseswithmembers class com.android.email.provider.EmailProvider { + *** getReadableDatabase(android.content.Context); +} + +-keepclasseswithmembers class com.android.emailcommon.provider.EmailContent$Attachment { + *** createUniqueFile(java.lang.String); +} + +-keepclasseswithmembers class com.android.email.Preferences { + *** getAccountByContentUri(android.net.Uri); +} + +-keep class com.android.emailcommon.mail.Message$RecipientType + +-keepclasseswithmembers class com.android.emailcommon.mail.Message { + *** setRecipient(com.android.emailcommon.mail.Message$RecipientType, com.android.emailcommon.mail.Address); +} + +-keepclasseswithmembers class com.android.emailcommon.internet.MimeHeader { + *** writeToString(); +} + +-keepclasseswithmembers class com.android.emailcommon.internet.MimeMessage { + (); + (java.io.InputStream); + *** getExtendedHeader(java.lang.String); + *** setExtendedHeader(java.lang.String, java.lang.String); + *** getExtendedHeaders(); + *** setExtendedHeaders(java.lang.String); +} + +-keepclasseswithmembers class com.android.emailcommon.internet.MimeUtility { + *** foldAndEncode(java.lang.String); + *** findPartByContentId(com.android.emailcommon.mail.Part, java.lang.String); + *** findFirstPartByMimeType(com.android.emailcommon.mail.Part, java.lang.String); +} + +-keepclasseswithmembers class com.android.email.mail.transport.SmtpSender { + *** setTransport(com.android.email.mail.transport.MailTransport); +} + +-keepclasseswithmembers class com.android.email.mail.Store { + *** requireStructurePrefetch(); +} + +-keepclasseswithmembers class com.android.email.mail.store.ImapStore { + *** setTransport(com.android.email.mail.transport.MailTransport); +} + +-keepclasseswithmembers class com.android.email.mail.store.ImapFolder { + *** getMessages(int, int, com.android.emailcommon.mail.Folder$MessageRetrievalListener); + *** getMessages(com.android.emailcommon.mail.Folder$MessageRetrievalListener); + *** getMessages(java.lang.String[], com.android.emailcommon.mail.Folder$MessageRetrievalListener); + *** getUnreadMessageCount(); +} + +-keepclasseswithmembers class com.android.email.mail.store.Pop3Store { + *** setTransport(com.android.email.mail.transport.MailTransport); +} + +-keepclasseswithmembers class com.android.email.mail.store.Pop3Store$Pop3Folder { + *** getMessages(int, int, com.android.emailcommon.mail.Folder$MessageRetrievalListener); + *** getMessages(com.android.emailcommon.mail.Folder$MessageRetrievalListener); + *** getMessages(java.lang.String[], com.android.emailcommon.mail.Folder$MessageRetrievalListener); + *** getUnreadMessageCount(); + *** isOpen(); +} + +-keep class com.android.emailcommon.mail.Flag + +-keepclasseswithmembers class com.android.emailcommon.mail.Folder { + *** getUnreadMessageCount(); + *** delete(boolean); + *** getRole(); +} + +-keep class com.android.emailcommon.mail.Folder$FolderRole + +-keepclasseswithmembers class com.android.emailcommon.mail.PackedString$Builder { + (); + (java.lang.String); + *** get(java.lang.String); + *** put(java.lang.String, java.lang.String); +} + +-keepclasseswithmembers class com.android.email.provider.ContentCache$CounterMap { + *** getCount(...); + *** size(); +} + +-keepclasseswithmembers class com.android.emailcommon.provider.Account { + *** getShortcutSafeUri(); + *** refresh(android.content.Context); +} + +-keepclasseswithmembers class com.android.emailcommon.provider.Policy { + *** setAttachmentFlagsForNewPolicy(android.content.Context, + com.android.emailcommon.provider.Account, + com.android.emailcommon.provider.Policy); + *** clearAccountPolicy(android.content.Context, + com.android.emailcommon.provider.Account); +} + +-keep class org.apache.james.mime4j.field.Field { + *** getBody(); +} + +# The following classes are used only by unit tests. +# We should move them into tests/ if possible. + +-keep class org.apache.james.mime4j.message.Message { + *; +} + +-keepclasseswithmembers class org.apache.commons.io.IOUtils { + *** toByteArray(java.io.InputStream); + *** toByteArray(java.io.Reader); + *** toByteArray(java.io.Reader, java.lang.String); + *** toByteArray(java.lang.String); +} diff --git a/proguard.flags b/proguard.flags index 6b0a84488..d21d40f7d 100644 --- a/proguard.flags +++ b/proguard.flags @@ -1,174 +1,5 @@ #Email-specific proguard flags that are not covered by UnifiedEmail go here --keep class com.android.emailcommon.provider.Account - --keepclasseswithmembers class * { - public static void actionEditIncomingSettings(android.app.Activity, int, com.android.emailcommon.provider.Account); -} - --keepclasseswithmembers class * { - public static void actionEditOutgoingSettings(android.app.Activity, int, com.android.emailcommon.provider.Account); -} - -keepclasseswithmembers class * { public *** newInstance(com.android.emailcommon.provider.Account, android.content.Context); } - --keepclasseswithmembers class * { - public *** newInstance(com.android.emailcommon.provider.Account, android.content.Context); -} - --keepclasseswithmembers class android.content.SharedPreferences$Editor { - *** apply(); -} - --keep class * extends org.apache.james.mime4j.util.TempStorage - -# Keep names that are used only by unit tests or by animators --keep class ** { - *** *ForTest(...); - *** *Anim(...); -} - --keepclasseswithmembers class com.android.emailcommon.internet.Rfc822Output { - *** getHtmlBody(java.lang.String); - *** buildBodyText(android.content.Context, com.android.emailcommon.provider.EmailContent$Message, boolean); -} - --keepclasseswithmembers class com.android.emailcommon.mail.Address { - (java.lang.String); - (java.lang.String,java.lang.String); - *** parseAndPack(java.lang.String); -} - --keepclasseswithmembers class com.android.email.SecurityPolicy { - *** setContext(android.content.Context); -} - --keepclasseswithmembers class com.android.emailcommon.utility.Utility { - *** dumpCursor(android.database.Cursor); - *** fromUtf8(byte[]); - *** isFirstUtf8Byte(byte); - *** replaceBareLfWithCrlf(java.lang.String); -} - --keepclasseswithmembers class com.android.email.provider.EmailProvider { - *** getReadableDatabase(android.content.Context); -} - --keepclasseswithmembers class com.android.emailcommon.provider.EmailContent$Attachment { - *** createUniqueFile(java.lang.String); -} - --keepclasseswithmembers class com.android.email.Preferences { - *** getAccountByContentUri(android.net.Uri); -} - --keep class com.android.emailcommon.mail.Message$RecipientType - --keepclasseswithmembers class com.android.emailcommon.mail.Message { - *** setRecipient(com.android.emailcommon.mail.Message$RecipientType, com.android.emailcommon.mail.Address); -} - --keepclasseswithmembers class com.android.emailcommon.internet.MimeHeader { - *** writeToString(); -} - --keepclasseswithmembers class com.android.emailcommon.internet.MimeMessage { - (); - (java.io.InputStream); - *** getExtendedHeader(java.lang.String); - *** setExtendedHeader(java.lang.String, java.lang.String); - *** getExtendedHeaders(); - *** setExtendedHeaders(java.lang.String); -} - --keepclasseswithmembers class com.android.emailcommon.internet.MimeUtility { - *** foldAndEncode(java.lang.String); - *** findPartByContentId(com.android.emailcommon.mail.Part, java.lang.String); - *** findFirstPartByMimeType(com.android.emailcommon.mail.Part, java.lang.String); -} - --keepclasseswithmembers class com.android.email.mail.transport.SmtpSender { - *** setTransport(com.android.email.mail.transport.MailTransport); -} - --keepclasseswithmembers class com.android.email.mail.Store { - *** requireStructurePrefetch(); -} - --keepclasseswithmembers class com.android.email.mail.store.ImapStore { - *** setTransport(com.android.email.mail.transport.MailTransport); -} - --keepclasseswithmembers class com.android.email.mail.store.ImapFolder { - *** getMessages(int, int, com.android.emailcommon.mail.Folder$MessageRetrievalListener); - *** getMessages(com.android.emailcommon.mail.Folder$MessageRetrievalListener); - *** getMessages(java.lang.String[], com.android.emailcommon.mail.Folder$MessageRetrievalListener); - *** getUnreadMessageCount(); -} - --keepclasseswithmembers class com.android.email.mail.store.Pop3Store { - *** setTransport(com.android.email.mail.transport.MailTransport); -} - --keepclasseswithmembers class com.android.email.mail.store.Pop3Store$Pop3Folder { - *** getMessages(int, int, com.android.emailcommon.mail.Folder$MessageRetrievalListener); - *** getMessages(com.android.emailcommon.mail.Folder$MessageRetrievalListener); - *** getMessages(java.lang.String[], com.android.emailcommon.mail.Folder$MessageRetrievalListener); - *** getUnreadMessageCount(); - *** isOpen(); -} - --keep class com.android.emailcommon.mail.Flag - --keepclasseswithmembers class com.android.emailcommon.mail.Folder { - *** getUnreadMessageCount(); - *** delete(boolean); - *** getRole(); -} - --keep class com.android.emailcommon.mail.Folder$FolderRole - --keepclasseswithmembers class com.android.emailcommon.mail.PackedString$Builder { - (); - (java.lang.String); - *** get(java.lang.String); - *** put(java.lang.String, java.lang.String); -} - --keepclasseswithmembers class com.android.email.provider.ContentCache$CounterMap { - *** getCount(...); - *** size(); -} - --keepclasseswithmembers class com.android.emailcommon.provider.Account { - *** getShortcutSafeUri(); - *** refresh(android.content.Context); -} - --keepclasseswithmembers class com.android.emailcommon.provider.Policy { - *** setAttachmentFlagsForNewPolicy(android.content.Context, - com.android.emailcommon.provider.Account, - com.android.emailcommon.provider.Policy); - *** clearAccountPolicy(android.content.Context, - com.android.emailcommon.provider.Account); -} - --keep class org.apache.james.mime4j.field.Field { - *** getBody(); -} - -# The following classes are used only by unit tests. -# We should move them into tests/ if possible. - --keep class org.apache.james.mime4j.message.Message { - *; -} - --keepclasseswithmembers class org.apache.commons.io.IOUtils { - *** toByteArray(java.io.InputStream); - *** toByteArray(java.io.Reader); - *** toByteArray(java.io.Reader, java.lang.String); - *** toByteArray(java.lang.String); -}