Using Proguard to shrink apk size.

Contacts proguard.flags change, add keep class for tests.

BUG 27314641

Change-Id: I4a169e50602ebdcea197baa54f4f887a76acdeb5
(cherry picked from commit 6035674bd506f3c9bdb49c9ce271747d7eff229e)
diff --git a/proguard.flags b/proguard.flags
index feaa360..bad57a9 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -10,6 +10,14 @@
 }
 
 -keep class com.android.contacts.common.** { *;}
+# For test:
+-keep class com.android.contacts.commonbind.analytics.AnalyticsUtil { *;}
+-keep class com.android.contacts.interactions.** { *;}
+-keep class com.google.common.base.Objects { *;}
+-keep class com.google.common.base.Preconditions { *;}
+-keep class com.google.common.collect.Lists { *;}
+-keep class com.google.common.collect.Maps { *;}
+-keep class com.google.common.collect.Sets { *;}
 
 # Any class or method annotated with NeededForTesting or NeededForReflection.
 -keep @com.android.contacts.common.testing.NeededForTesting class *
@@ -18,5 +26,10 @@
 @com.android.contacts.common.testing.NeededForTesting *;
 @com.android.contacts.test.NeededForReflection *;
 }
+# Keep classes and methods that have the guava @VisibleForTesting annotation
+-keep @com.google.common.annotations.VisibleForTesting class *
+-keepclassmembers class * {
+  @com.google.common.annotations.VisibleForTesting *;
+}
 
 -verbose
diff --git a/src/com/android/contacts/ContactsApplication.java b/src/com/android/contacts/ContactsApplication.java
index f0dc91b..0ba1f02 100644
--- a/src/com/android/contacts/ContactsApplication.java
+++ b/src/com/android/contacts/ContactsApplication.java
@@ -33,8 +33,10 @@
 import com.android.contacts.common.util.Constants;
 import com.android.contacts.commonbind.analytics.AnalyticsUtil;
 
+import com.android.contacts.common.testing.NeededForTesting;
 import com.google.common.annotations.VisibleForTesting;
 
+@NeededForTesting
 public class ContactsApplication extends Application {
     private static final boolean ENABLE_LOADER_LOG = false; // Don't submit with true
     private static final boolean ENABLE_FRAGMENT_LOG = false; // Don't submit with true
diff --git a/src/com/android/contacts/editor/ContactEditorUtils.java b/src/com/android/contacts/editor/ContactEditorUtils.java
index 728211f..3aae923 100644
--- a/src/com/android/contacts/editor/ContactEditorUtils.java
+++ b/src/com/android/contacts/editor/ContactEditorUtils.java
@@ -41,6 +41,7 @@
 /**
  * Utility methods for the "account changed" notification in the new contact creation flow.
  */
+@NeededForTesting
 public class ContactEditorUtils {
     private static final String TAG = "ContactEditorUtils";
 
@@ -119,6 +120,7 @@
      * @param defaultAccount the account used to save a newly created contact.  Or pass {@code null}
      *     If the user selected "local only".
      */
+    @NeededForTesting
     public void saveDefaultAndAllAccounts(AccountWithDataSet defaultAccount) {
         final SharedPreferences.Editor editor = mPrefs.edit()
                 .putBoolean(mAnythingSavedKey, true);
@@ -210,6 +212,7 @@
      * {@link #getDefaultAccount} will return a valid account.  (Either an account which still
      * exists, or {@code null} which should be interpreted as "local only".)
      */
+    @NeededForTesting
     public boolean shouldShowAccountChangedNotification() {
         if (isFirstLaunch()) {
             return true;
diff --git a/src/com/android/contacts/editor/EditorUiUtils.java b/src/com/android/contacts/editor/EditorUiUtils.java
index b87d4f4..dd3067b 100644
--- a/src/com/android/contacts/editor/EditorUiUtils.java
+++ b/src/com/android/contacts/editor/EditorUiUtils.java
@@ -52,6 +52,7 @@
 import com.android.contacts.common.model.account.AccountType;
 import com.android.contacts.common.model.account.GoogleAccountType;
 import com.android.contacts.common.model.dataitem.DataKind;
+import com.android.contacts.common.testing.NeededForTesting;
 import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
 import com.android.contacts.util.ContactPhotoUtils;
 import com.android.contacts.widget.QuickContactImageView;
@@ -64,6 +65,7 @@
 /**
  * Utility methods for creating contact editor.
  */
+@NeededForTesting
 public class EditorUiUtils {
 
     // Maps DataKind.mimeType to editor view layouts.
@@ -114,6 +116,7 @@
     /**
      * Returns the account name and account type labels to display for local accounts.
      */
+    @NeededForTesting
     public static Pair<String,String> getLocalAccountInfo(Context context,
             String accountName, AccountType accountType) {
         if (TextUtils.isEmpty(accountName)) {
@@ -130,6 +133,7 @@
     /**
      * Returns the account name and account type labels to display for the given account type.
      */
+    @NeededForTesting
     public static Pair<String,String> getAccountInfo(Context context, String accountName,
             AccountType accountType) {
         CharSequence accountTypeDisplayLabel = accountType.getDisplayLabel(context);
@@ -213,6 +217,7 @@
     /**
      * Returns a ringtone string based on the ringtone URI and version #.
      */
+    @NeededForTesting
     public static String getRingtoneStringFromUri(Uri pickedUri, int currentVersion) {
         if (isNewerThanM(currentVersion)) {
             if (pickedUri == null) return ""; // silent ringtone
@@ -225,6 +230,7 @@
     /**
      * Returns a ringtone URI, based on the string and version #.
      */
+    @NeededForTesting
     public static Uri getRingtoneUriFromString(String str, int currentVersion) {
         if (str != null) {
             if (isNewerThanM(currentVersion) && TextUtils.isEmpty(str)) return null;