Merge "ContactTiles include display_name_alt col" into ub-contactsdialer-a-dev
diff --git a/src/com/android/contacts/common/preference/ContactsPreferences.java b/src/com/android/contacts/common/preference/ContactsPreferences.java
index 1d7b120..ca38af7 100644
--- a/src/com/android/contacts/common/preference/ContactsPreferences.java
+++ b/src/com/android/contacts/common/preference/ContactsPreferences.java
@@ -21,6 +21,7 @@
 import android.content.SharedPreferences.Editor;
 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.os.Handler;
+import android.preference.PreferenceManager;
 import android.provider.Settings;
 import android.provider.Settings.SettingNotFoundException;
 import android.text.TextUtils;
@@ -238,8 +239,10 @@
 
     /**
      * If there are currently no preferences (which means this is the first time we are run),
-     * check to see if there are any preferences stored in system settings (pre-L) which can be
-     * copied into our own SharedPreferences.
+     * For sort order and display order, check to see if there are any preferences stored in
+     * system settings (pre-L) which can be copied into our own SharedPreferences.
+     * For default account setting, check to see if there are any preferences stored in the previous
+     * SharedPreferences which can be copied into current SharedPreferences.
      */
     private void maybeMigrateSystemSettings() {
         if (!mPreferences.contains(SORT_ORDER_KEY)) {
@@ -261,5 +264,16 @@
             }
             setDisplayOrder(displayOrder);
         }
+
+        if (!mPreferences.contains(mDefaultAccountKey)) {
+            final SharedPreferences previousPrefs =
+                    PreferenceManager.getDefaultSharedPreferences(mContext);
+            final String defaultAccount = previousPrefs.getString(mDefaultAccountKey, null);
+            if (!TextUtils.isEmpty(defaultAccount)) {
+                final AccountWithDataSet accountWithDataSet = AccountWithDataSet.unstringify(
+                        defaultAccount);
+                setDefaultAccount(accountWithDataSet);
+            }
+        }
     }
 }
diff --git a/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java b/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
index 6a40611..e204722 100644
--- a/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/AccountTypeTest.java
@@ -20,7 +20,7 @@
 import android.test.InstrumentationTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
-import com.android.contacts.common.R;
+import com.android.contacts.common.tests.R;
 
 /**
  * Test case for {@link AccountType}.
diff --git a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
index dc3da45..3265162 100644
--- a/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
+++ b/tests/src/com/android/contacts/common/model/account/ExternalAccountTypeTest.java
@@ -33,7 +33,7 @@
 import android.util.Log;
 
 import com.android.contacts.common.model.dataitem.DataKind;
-import com.android.contacts.common.R;
+import com.android.contacts.common.tests.R;
 import com.google.common.base.Objects;
 
 import java.util.List;