[automerger skipped] Import translations. DO NOT MERGE
am: 0f89ffc9ef -s ours
am skip reason: subject contains skip directive

Change-Id: Id193a8e07e1d96781c9dc2fd9e1ea659fae6d8c0
diff --git a/Android.bp b/Android.bp
index b6bddce..8991628 100644
--- a/Android.bp
+++ b/Android.bp
@@ -6,8 +6,7 @@
         "src/com/android/providers/contacts/EventLogTags.logtags",
     ],
     libs: [
-        "ext",
-        "telephony-common",
+        "ext"
     ],
     static_libs: [
         "android-common",
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index eb68085..a725953 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -26,7 +26,7 @@
     <string name="local_invisible_directory" msgid="705244318477396120">"Sonstige"</string>
     <string name="voicemail_from_column" msgid="435732568832121444">"Mailboxnachricht von "</string>
     <string name="debug_dump_title" msgid="4916885724165570279">"Kontaktdatenbank kopieren"</string>
-    <string name="debug_dump_database_message" msgid="406438635002392290">"Du 1) erstellst eine Kopie deiner Datenbank, die alle Kontaktinformationen und Anruflisteneinträge auf dem internen Speicher enthält, und 2) sendest diese Kopie per E-Mail. Denke daran, die Kopie so schnell wie möglich zu löschen, nachdem du sie vom Gerät kopiert hast oder die E-Mail empfangen wurde."</string>
+    <string name="debug_dump_database_message" msgid="406438635002392290">"Du 1) erstellst eine Kopie deiner Datenbank, die alle Kontaktinformationen und Anruflisten auf dem internen Speicher enthält, und 2) sendest diese Kopie per E-Mail. Denke daran, die Kopie so schnell wie möglich zu löschen, nachdem du sie vom Gerät kopiert hast oder die E-Mail empfangen wurde."</string>
     <string name="debug_dump_delete_button" msgid="7832879421132026435">"Jetzt löschen"</string>
     <string name="debug_dump_start_button" msgid="2837506913757600001">"Starten"</string>
     <string name="debug_dump_email_sender_picker" msgid="3534420908672176460">"Programm zum Senden der Datei auswählen"</string>
diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
index b1c7431..e9f97d2 100644
--- a/res/values-eu/strings.xml
+++ b/res/values-eu/strings.xml
@@ -24,7 +24,7 @@
     <string name="upgrade_out_of_memory_notification_text" msgid="2581831842693151968">"Sakatu bertsio-berritzea osatzeko."</string>
     <string name="default_directory" msgid="93961630309570294">"Kontaktuak"</string>
     <string name="local_invisible_directory" msgid="705244318477396120">"Beste bat"</string>
-    <string name="voicemail_from_column" msgid="435732568832121444">"Mezu bat utzi du erantzungailuan honek: "</string>
+    <string name="voicemail_from_column" msgid="435732568832121444">"Honen ahots-mezua: "</string>
     <string name="debug_dump_title" msgid="4916885724165570279">"Kopiatu kontaktuen datu-basea"</string>
     <string name="debug_dump_database_message" msgid="406438635002392290">"Bi gauza egitera zoaz: 1) kontaktuekin erlazionatutako informazio guztia eta deien erregistro osoa jasotzen dituen datu-basearen kopia bat egingo duzu eta barneko memorian gordeko duzu eta 2) posta elektronikoz bidaliko duzu. Gogoratu kopia ezabatu behar duzula gailutik kopiatu edo mezu elektronikoa jaso bezain laster."</string>
     <string name="debug_dump_delete_button" msgid="7832879421132026435">"Ezabatu"</string>
diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml
index 9fa5c9b..4af29ec 100644
--- a/res/values-fa/strings.xml
+++ b/res/values-fa/strings.xml
@@ -17,7 +17,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="sharedUserLabel" msgid="8024311725474286801">"Android Core Apps"</string>
-    <string name="app_label" msgid="3389954322874982620">"فضای ذخیره‌سازی مخاطبین"</string>
+    <string name="app_label" msgid="3389954322874982620">"حافظه مخاطبین"</string>
     <string name="provider_label" msgid="6012150850819899907">"مخاطبین"</string>
     <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"برای ارتقای مخاطبین به حافظه بیشتری نیاز است."</string>
     <string name="upgrade_out_of_memory_notification_title" msgid="8888171924684998531">"ارتقا حافظه برای مخاطبین"</string>
diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml
index 478e5ce..a9b2025 100644
--- a/res/values-hi/strings.xml
+++ b/res/values-hi/strings.xml
@@ -19,17 +19,17 @@
     <string name="sharedUserLabel" msgid="8024311725474286801">"Android Core Apps"</string>
     <string name="app_label" msgid="3389954322874982620">"संपर्क मेमोरी"</string>
     <string name="provider_label" msgid="6012150850819899907">"संपर्क"</string>
-    <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"संपर्क अपग्रेड के लिए ज़्यादा मेमोरी की आवश्यकता होती है."</string>
+    <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"संपर्क अपग्रेड के लिए अधिक मेमोरी की आवश्यकता होती है."</string>
     <string name="upgrade_out_of_memory_notification_title" msgid="8888171924684998531">"संपर्कों के लिए मेमोरी अपग्रेड करना"</string>
-    <string name="upgrade_out_of_memory_notification_text" msgid="2581831842693151968">"अपग्रेड पूरा करने के लिए टैप करें."</string>
+    <string name="upgrade_out_of_memory_notification_text" msgid="2581831842693151968">"अपग्रेड पूर्ण करने के लिए टैप करें."</string>
     <string name="default_directory" msgid="93961630309570294">"संपर्क"</string>
     <string name="local_invisible_directory" msgid="705244318477396120">"अन्य"</string>
     <string name="voicemail_from_column" msgid="435732568832121444">"इनका ध्‍वनि‍मेल: "</string>
     <string name="debug_dump_title" msgid="4916885724165570279">"संपर्क डेटाबेस की कॉपी बनाएं"</string>
-    <string name="debug_dump_database_message" msgid="406438635002392290">"आप 1) मोबाइल मेमोरी में अपने उस डेटाबेस की कॉपी बनाने वाले हैं जिसमें सभी संपर्कों से जुड़ी जानकारी और सभी कॉल लॉग शामिल हैं, और 2) उसे ईमेल करने वाले हैं. जैसे ही आप डिवाइस से इसकी कॉपी सफलतापूर्वक बना लें या ईमेल मिल जाए तो कॉपी हटाना न भूलें."</string>
+    <string name="debug_dump_database_message" msgid="406438635002392290">"आप 1) मोबाइल मेमोरी में अपने उस डेटाबेस की कॉपी बनाने वाले हैं जिसमें सभी संपर्कों संबंधी जानकारी और सभी कॉल लॉग शामिल हैं, और 2) उसे ईमेल करने वाले हैं. जैसे ही आप डिवाइस से इसकी कॉपी सफलतापूर्वक बना लें या ईमेल प्राप्त हो जाए तो कॉपी को हटाना न भूलें."</string>
     <string name="debug_dump_delete_button" msgid="7832879421132026435">"अभी हटाएं"</string>
     <string name="debug_dump_start_button" msgid="2837506913757600001">"प्रारंभ करें"</string>
     <string name="debug_dump_email_sender_picker" msgid="3534420908672176460">"अपनी फ़ाइल भेजने के लिए कोई प्रोग्राम चुनें"</string>
     <string name="debug_dump_email_subject" msgid="108188398416385976">"संपर्क Db अनुलग्न है"</string>
-    <string name="debug_dump_email_body" msgid="4577749800871444318">"मेरी समस्त संपर्क जानकारी के साथ मेरा संपर्क डेटाबेस अनुलग्न है. सावधानी से काम करें."</string>
+    <string name="debug_dump_email_body" msgid="4577749800871444318">"मेरी समस्त संपर्क जानकारी के साथ मेरा संपर्क डेटाबेस अनुलग्न है. सावधानी से कार्य करें."</string>
 </resources>
diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
index 4e7a44c..1756ab8 100644
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -26,7 +26,7 @@
     <string name="local_invisible_directory" msgid="705244318477396120">"その他"</string>
     <string name="voicemail_from_column" msgid="435732568832121444">"受信ボイスメール: "</string>
     <string name="debug_dump_title" msgid="4916885724165570279">"連絡先データベースをコピー"</string>
-    <string name="debug_dump_database_message" msgid="406438635002392290">"1)すべての連絡先関連情報とすべての通話履歴を格納したデータベースを内部ストレージにコピーし、2)メールで送信しようとしています。デバイスからのコピーが完了した時点またはメールが受信された時点ですぐにコピーを削除してください。"</string>
+    <string name="debug_dump_database_message" msgid="406438635002392290">"1)すべての連絡先関連情報とすべての通話履歴を格納したデータベースを内部ストレージにコピーし、2)メールで送信しようとしています。端末からのコピーが完了した時点またはメールが受信された時点ですぐにコピーを削除してください。"</string>
     <string name="debug_dump_delete_button" msgid="7832879421132026435">"今すぐ削除"</string>
     <string name="debug_dump_start_button" msgid="2837506913757600001">"開始"</string>
     <string name="debug_dump_email_sender_picker" msgid="3534420908672176460">"ファイルを送信するプログラムを選択"</string>
diff --git a/res/values-lo/strings.xml b/res/values-lo/strings.xml
index 1efef33..b75c816 100644
--- a/res/values-lo/strings.xml
+++ b/res/values-lo/strings.xml
@@ -18,7 +18,7 @@
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="sharedUserLabel" msgid="8024311725474286801">"ແອັບພລິເຄຊັນຫຼັກຂອງ Android"</string>
     <string name="app_label" msgid="3389954322874982620">"ບ່ອນຈັດເກັບຂໍ້ມູນລາຍຊື່ຜູ່ຕິດຕໍ່"</string>
-    <string name="provider_label" msgid="6012150850819899907">"ລາຍຊື່ຜູ້ຕິດຕໍ່"</string>
+    <string name="provider_label" msgid="6012150850819899907">"ລາຍຊື່ຜູ່ຕິດຕໍ່"</string>
     <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"ການອັບເກຣດລາຍຊື່ຜູ່ຕິດຕໍ່ ຈະຕ້ອງໃຊ້ໜ່ວຍຄວາມຈຳເພີ່ມຕື່ມ."</string>
     <string name="upgrade_out_of_memory_notification_title" msgid="8888171924684998531">"ອັບເກຣດບ່ອນຈັດເກັບຂໍ້ມູນລາຍຊື່ຜູ່ຕິດຕໍ່"</string>
     <string name="upgrade_out_of_memory_notification_text" msgid="2581831842693151968">"ແຕະເພື່ອສຳເລັດການອັບເກຣດ."</string>
diff --git a/res/values-mk/strings.xml b/res/values-mk/strings.xml
index 84ff871..dc1a07a 100644
--- a/res/values-mk/strings.xml
+++ b/res/values-mk/strings.xml
@@ -17,7 +17,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="sharedUserLabel" msgid="8024311725474286801">"Основни апликации на Android"</string>
-    <string name="app_label" msgid="3389954322874982620">"Склад за контакти"</string>
+    <string name="app_label" msgid="3389954322874982620">"Меморирање контакти"</string>
     <string name="provider_label" msgid="6012150850819899907">"Контакти"</string>
     <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"За надградбата на контакти е потребно повеќе меморија."</string>
     <string name="upgrade_out_of_memory_notification_title" msgid="8888171924684998531">"Надградување меморија за контакти"</string>
diff --git a/res/values-ml/strings.xml b/res/values-ml/strings.xml
index 1ed08d2..dc2abdf 100644
--- a/res/values-ml/strings.xml
+++ b/res/values-ml/strings.xml
@@ -18,11 +18,11 @@
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="sharedUserLabel" msgid="8024311725474286801">"Android കോർ അപ്ലിക്കേഷനുകൾ"</string>
     <string name="app_label" msgid="3389954322874982620">"കോൺടാക്റ്റുകളുടെ സ്റ്റോറേജ്"</string>
-    <string name="provider_label" msgid="6012150850819899907">"കോണ്‍ടാക്റ്റുകള്‍"</string>
+    <string name="provider_label" msgid="6012150850819899907">"വിലാസങ്ങൾ"</string>
     <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"കോൺ‌ടാക്റ്റുകൾ അപ്‌ഗ്രേഡുചെയ്യാൻ കൂടുതൽ മെമ്മറി ആവശ്യമാണ്."</string>
     <string name="upgrade_out_of_memory_notification_title" msgid="8888171924684998531">"കോൺ‌ടാക്റ്റുകൾക്കായുള്ള സ്റ്റോറേജ്  അപ്‌ഗ്രേഡുചെയ്യുന്നു"</string>
     <string name="upgrade_out_of_memory_notification_text" msgid="2581831842693151968">"അപ്‌ഗ്രേഡ് പൂർത്തിയാക്കാൻ ടാപ്പുചെയ്യുക."</string>
-    <string name="default_directory" msgid="93961630309570294">"കോണ്‍‌ടാക്റ്റുകള്‍"</string>
+    <string name="default_directory" msgid="93961630309570294">"വിലാസങ്ങൾ"</string>
     <string name="local_invisible_directory" msgid="705244318477396120">"മറ്റുള്ളവ"</string>
     <string name="voicemail_from_column" msgid="435732568832121444">"ഈ നമ്പറിൽ നിന്നുള്ള വോയ്‌സ്‌മെയിൽ "</string>
     <string name="debug_dump_title" msgid="4916885724165570279">"കോൺടാക്റ്റുകളുടെ ഡാറ്റാബേസ് പകർത്തുക"</string>
diff --git a/res/values-ta/strings.xml b/res/values-ta/strings.xml
index c6e2539..1116f19 100644
--- a/res/values-ta/strings.xml
+++ b/res/values-ta/strings.xml
@@ -16,7 +16,7 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="sharedUserLabel" msgid="8024311725474286801">"Android முக்கிய ஆப்ஸ்"</string>
+    <string name="sharedUserLabel" msgid="8024311725474286801">"Android முக்கிய பயன்பாடுகள்"</string>
     <string name="app_label" msgid="3389954322874982620">"தொடர்புகள் சேமிப்பிடம்"</string>
     <string name="provider_label" msgid="6012150850819899907">"தொடர்புகள்"</string>
     <string name="upgrade_out_of_memory_notification_ticker" msgid="7638747231223520477">"தொடர்புகளின் மேம்படுத்தலுக்கு கூடுதல் நினைவகம் தேவை."</string>
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index ff3e65c..3999520 100644
--- a/src/com/android/providers/contacts/CallLogProvider.java
+++ b/src/com/android/providers/contacts/CallLogProvider.java
@@ -183,6 +183,7 @@
     private CallLogDatabaseHelper mDbHelper;
     private DatabaseUtils.InsertHelper mCallsInserter;
     private boolean mUseStrictPhoneNumberComparation;
+    private int mMinMatch;
     private VoicemailPermissions mVoicemailPermissions;
     private CallLogInsertionHelper mCallLogInsertionHelper;
 
@@ -214,6 +215,9 @@
         mUseStrictPhoneNumberComparation =
             context.getResources().getBoolean(
                     com.android.internal.R.bool.config_use_strict_phone_number_comparation);
+        mMinMatch =
+            context.getResources().getInteger(
+                    com.android.internal.R.integer.config_phonenumber_compare_min_match);
         mVoicemailPermissions = new VoicemailPermissions(context);
         mCallLogInsertionHelper = createCallLogInsertionHelper(context);
 
@@ -239,6 +243,16 @@
         return DefaultCallLogInsertionHelper.getInstance(context);
     }
 
+    @VisibleForTesting
+    public void setMinMatchForTest(int minMatch) {
+        mMinMatch = minMatch;
+    }
+
+    @VisibleForTesting
+    public int getMinMatchForTest() {
+        return mMinMatch;
+    }
+
     protected CallLogDatabaseHelper getDatabaseHelper(final Context context) {
         return CallLogDatabaseHelper.getInstance(context);
     }
@@ -331,7 +345,8 @@
                 if (!TextUtils.isEmpty(phoneNumber)) {
                     qb.appendWhere("PHONE_NUMBERS_EQUAL(number, ");
                     qb.appendWhereEscapeString(phoneNumber);
-                    qb.appendWhere(mUseStrictPhoneNumberComparation ? ", 1)" : ", 0)");
+                    qb.appendWhere(mUseStrictPhoneNumberComparation ? ", 1)"
+                            : ", 0, " + mMinMatch + ")");
                 } else {
                     qb.appendWhere(Calls.NUMBER_PRESENTATION + "!="
                             + Calls.PRESENTATION_ALLOWED);
@@ -728,9 +743,8 @@
                     mDbHelper.getWritableDatabase().execSQL(
                             UNHIDE_BY_PHONE_ACCOUNT_QUERY, handleArgs);
                 } else {
-                    TelecomManager tm = TelecomManager.from(getContext());
+                    TelecomManager tm = getContext().getSystemService(TelecomManager.class);
                     if (tm != null) {
-
                         PhoneAccount account = tm.getPhoneAccount(handle);
                         if (account != null && account.getAddress() != null) {
                             // We did not find any items for the specific phone account, so run the
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index 4c521f4..2e5cdac 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -982,6 +982,7 @@
     private boolean mUseStrictPhoneNumberComparisonBase;
     private boolean mUseStrictPhoneNumberComparisonForRussia;
     private boolean mUseStrictPhoneNumberComparisonForKazakhstan;
+    private int mMinMatch;
 
     private String[] mSelectionArgs1 = new String[1];
     private NameSplitter.Name mName = new NameSplitter.Name();
@@ -1071,6 +1072,9 @@
         } else {
             mUseStrictPhoneNumberComparison = mUseStrictPhoneNumberComparisonBase;
         }
+
+        mMinMatch = mContext.getResources().getInteger(
+                com.android.internal.R.integer.config_phonenumber_compare_min_match);
     }
 
     private boolean getConfig(String configKey, int defaultResId) {
@@ -3217,8 +3221,7 @@
         //       ON_BOOT_COMPLETE instead of PRE_BOOT_COMPLETE.
         SubscriptionManager sm = SubscriptionManager.from(mContext);
         if (sm != null) {
-            Log.i(TAG, "count: " + sm.getAllSubscriptionInfoCount());
-            for (SubscriptionInfo info : sm.getAllSubscriptionInfoList()) {
+            for (SubscriptionInfo info : sm.getActiveSubscriptionInfoList()) {
                 String iccId = info.getIccId();
                 int subId = info.getSubscriptionId();
                 if (!TextUtils.isEmpty(iccId) &&
@@ -4239,7 +4242,7 @@
         sb.setLength(0);
         sb.append("PHONE_NUMBERS_EQUAL(" + Tables.DATA + "." + Phone.NUMBER + ", ");
         DatabaseUtils.appendEscapedSQLString(sb, number);
-        sb.append(mUseStrictPhoneNumberComparison ? ", 1)" : ", 0)");
+        sb.append(mUseStrictPhoneNumberComparison ? ", 1)" : ", 0, " + mMinMatch + ")");
         qb.appendWhere(sb.toString());
     }
 
@@ -4336,6 +4339,10 @@
         return mUseStrictPhoneNumberComparison ? "1" : "0";
     }
 
+    public String getMinMatchParameter() {
+        return String.valueOf(mMinMatch);
+    }
+
     /**
      * Loads common nickname mappings into the database.
      */
@@ -4954,6 +4961,16 @@
         return mUseStrictPhoneNumberComparison;
     }
 
+    @VisibleForTesting
+    public void setMinMatchForTest(int minMatch) {
+        mMinMatch = minMatch;
+    }
+
+    @VisibleForTesting
+    public int getMinMatchForTest() {
+        return mMinMatch;
+    }
+
     @NeededForTesting
     /* package */ String querySearchIndexContentForTest(long contactId) {
         return DatabaseUtils.stringForQuery(getReadableDatabase(),
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 02c8bf0..89f3c70 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -9664,7 +9664,8 @@
     @VisibleForTesting
     protected boolean isPhone() {
         if (!mIsPhoneInitialized) {
-            mIsPhone = new TelephonyManager(getContext()).isVoiceCapable();
+            TelephonyManager tm = getContext().getSystemService(TelephonyManager.class);
+            mIsPhone = tm.isVoiceCapable();
             mIsPhoneInitialized = true;
         }
         return mIsPhone;
@@ -9828,7 +9829,7 @@
      * @return the currently active {@link ContactsDatabaseHelper} for the current thread.
      */
     @NeededForTesting
-    protected ContactsDatabaseHelper getThreadActiveDatabaseHelperForTest() {
+    public ContactsDatabaseHelper getThreadActiveDatabaseHelperForTest() {
         return mDbHelper.get();
     }
 
diff --git a/src/com/android/providers/contacts/VoicemailPermissions.java b/src/com/android/providers/contacts/VoicemailPermissions.java
index 7e409ea..58e7a14 100644
--- a/src/com/android/providers/contacts/VoicemailPermissions.java
+++ b/src/com/android/providers/contacts/VoicemailPermissions.java
@@ -18,8 +18,9 @@
 
 import android.content.Context;
 import android.os.Binder;
-import android.telecom.DefaultDialerManager;
+import android.telecom.TelecomManager;
 import android.telephony.TelephonyManager;
+import android.text.TextUtils;
 
 import com.android.providers.contacts.util.ContactsPermissions;
 
@@ -41,9 +42,20 @@
                 || callerHasCarrierPrivileges();
     }
 
+    private boolean isDefaultOrSystemDialer(String callingPackage) {
+        // Note: Mimics previous dependency on DefaultDialerManager; that code just returns false
+        // here if the calling package is empty.
+        if (TextUtils.isEmpty(callingPackage)) {
+            return false;
+        }
+        TelecomManager tm = mContext.getSystemService(TelecomManager.class);
+        return (callingPackage.equals(tm.getDefaultDialerPackage())
+                || callingPackage.equals(tm.getSystemDialerPackage()));
+    }
+
     /** Determine if the calling process has full read access to all voicemails. */
     public boolean callerHasReadAccess(String callingPackage) {
-        if (DefaultDialerManager.isDefaultOrSystemDialer(mContext, callingPackage)) {
+        if (isDefaultOrSystemDialer(callingPackage)) {
             return true;
         }
         return callerHasPermission(android.Manifest.permission.READ_VOICEMAIL);
@@ -52,7 +64,7 @@
     /** Determine if the calling process has the permission required to update and remove all
      * voicemails */
     public boolean callerHasWriteAccess(String callingPackage) {
-        if (DefaultDialerManager.isDefaultOrSystemDialer(mContext, callingPackage)) {
+        if (isDefaultOrSystemDialer(callingPackage)) {
             return true;
         }
         return callerHasPermission(android.Manifest.permission.WRITE_VOICEMAIL);
diff --git a/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java b/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java
index 965780e..82e35f1 100644
--- a/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java
+++ b/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java
@@ -174,6 +174,7 @@
 
     protected String[] mSelectionArgs1 = new String[1];
     protected String[] mSelectionArgs2 = new String[2];
+    protected String[] mSelectionArgs3 = new String[3];
 
     protected long mMimeTypeIdIdentity;
     protected long mMimeTypeIdEmail;
@@ -794,8 +795,8 @@
                 " AND d1." + Data.RAW_CONTACT_ID + " IN (" + rawContactIdSet1 + ")" +
                 " AND d2." + Data.RAW_CONTACT_ID + " IN (" + rawContactIdSet2 + ")" +
                 " AND PHONE_NUMBERS_EQUAL(d1." + Phone.NUMBER + ",d2." + Phone.NUMBER + "," +
-                        String.valueOf(mDbHelper.getUseStrictPhoneNumberComparisonParameter()) +
-                        ")";
+                        (mDbHelper.getUseStrictPhoneNumberComparisonParameter().equals("1") ? "1)"
+                         : "0," + mDbHelper.getMinMatchParameter() + ")");
         return (countOnly) ? RawContactMatchingSelectionStatement.SELECT_COUNT + sql :
                 RawContactMatchingSelectionStatement.SELECT_ID + sql;
     }
@@ -1195,6 +1196,12 @@
                 + " AND " + RawContactsColumns.AGGREGATION_NEEDED + "=0"
                 + " AND " + RawContacts.CONTACT_ID + " IN " + Tables.DEFAULT_DIRECTORY;
 
+        String SELECTION_MIN_MATCH = "dataA." + Data.RAW_CONTACT_ID + "=?"
+                + " AND PHONE_NUMBERS_EQUAL(dataA." + Phone.NUMBER + ", "
+                        + "dataB." + Phone.NUMBER + ",?,?)"
+                + " AND " + RawContactsColumns.AGGREGATION_NEEDED + "=0"
+                + " AND " + RawContacts.CONTACT_ID + " IN " + Tables.DEFAULT_DIRECTORY;
+
         String[] COLUMNS = new String[] {
                 Tables.RAW_CONTACTS + "." + RawContacts._ID,
                 RawContacts.CONTACT_ID,
diff --git a/src/com/android/providers/contacts/aggregation/ContactAggregator.java b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
index e5bd2ea..a104339 100644
--- a/src/com/android/providers/contacts/aggregation/ContactAggregator.java
+++ b/src/com/android/providers/contacts/aggregation/ContactAggregator.java
@@ -800,11 +800,25 @@
 
     private void updateMatchScoresBasedOnPhoneMatches(SQLiteDatabase db, long rawContactId,
             ContactMatcher matcher) {
-        mSelectionArgs2[0] = String.valueOf(rawContactId);
-        mSelectionArgs2[1] = mDbHelper.getUseStrictPhoneNumberComparisonParameter();
-        Cursor c = db.query(PhoneLookupQuery.TABLE, PhoneLookupQuery.COLUMNS,
+        Cursor c;
+        String useStrictPhoneNumberComparison =
+                mDbHelper.getUseStrictPhoneNumberComparisonParameter();
+
+        if (useStrictPhoneNumberComparison.equals("1")) {
+            mSelectionArgs2[0] = String.valueOf(rawContactId);
+            mSelectionArgs2[1] = useStrictPhoneNumberComparison;
+            c = db.query(PhoneLookupQuery.TABLE, PhoneLookupQuery.COLUMNS,
                 PhoneLookupQuery.SELECTION,
                 mSelectionArgs2, null, null, null, SECONDARY_HIT_LIMIT_STRING);
+        } else {
+            mSelectionArgs3[0] = String.valueOf(rawContactId);
+            mSelectionArgs3[1] = useStrictPhoneNumberComparison;
+            mSelectionArgs3[2] = mDbHelper.getMinMatchParameter();
+            c = db.query(PhoneLookupQuery.TABLE, PhoneLookupQuery.COLUMNS,
+                PhoneLookupQuery.SELECTION_MIN_MATCH,
+                mSelectionArgs3, null, null, null, SECONDARY_HIT_LIMIT_STRING);
+        }
+
         try {
             while (c.moveToNext()) {
                 long contactId = c.getLong(PhoneLookupQuery.CONTACT_ID);
diff --git a/src/com/android/providers/contacts/aggregation/ContactAggregator2.java b/src/com/android/providers/contacts/aggregation/ContactAggregator2.java
index e0bc3bb..6b1424c 100644
--- a/src/com/android/providers/contacts/aggregation/ContactAggregator2.java
+++ b/src/com/android/providers/contacts/aggregation/ContactAggregator2.java
@@ -665,11 +665,25 @@
 
     private void updateMatchScoresBasedOnPhoneMatches(SQLiteDatabase db, long rawContactId,
             RawContactMatcher matcher) {
-        mSelectionArgs2[0] = String.valueOf(rawContactId);
-        mSelectionArgs2[1] = mDbHelper.getUseStrictPhoneNumberComparisonParameter();
-        Cursor c = db.query(PhoneLookupQuery.TABLE, PhoneLookupQuery.COLUMNS,
+        Cursor c;
+        String useStrictPhoneNumberComparison =
+                mDbHelper.getUseStrictPhoneNumberComparisonParameter();
+
+        if (useStrictPhoneNumberComparison.equals("1")) {
+            mSelectionArgs2[0] = String.valueOf(rawContactId);
+            mSelectionArgs2[1] = useStrictPhoneNumberComparison;
+            c = db.query(PhoneLookupQuery.TABLE, PhoneLookupQuery.COLUMNS,
                 PhoneLookupQuery.SELECTION,
                 mSelectionArgs2, null, null, null, SECONDARY_HIT_LIMIT_STRING);
+        } else {
+            mSelectionArgs3[0] = String.valueOf(rawContactId);
+            mSelectionArgs3[1] = useStrictPhoneNumberComparison;
+            mSelectionArgs3[2] = mDbHelper.getMinMatchParameter();
+            c = db.query(PhoneLookupQuery.TABLE, PhoneLookupQuery.COLUMNS,
+                PhoneLookupQuery.SELECTION_MIN_MATCH,
+                mSelectionArgs3, null, null, null, SECONDARY_HIT_LIMIT_STRING);
+        }
+
         try {
             while (c.moveToNext()) {
                 long rId = c.getLong(PhoneLookupQuery.RAW_CONTACT_ID);
@@ -1029,6 +1043,11 @@
                 + "dataB." + Phone.NUMBER + ",?)"
                 + " AND " + RawContacts.CONTACT_ID + " IN " + Tables.DEFAULT_DIRECTORY;
 
+        String SELECTION_MIN_MATCH = "dataA." + Data.RAW_CONTACT_ID + "=?"
+                + " AND PHONE_NUMBERS_EQUAL(dataA." + Phone.NUMBER + ", "
+                + "dataB." + Phone.NUMBER + ",?,?)"
+                + " AND " + RawContacts.CONTACT_ID + " IN " + Tables.DEFAULT_DIRECTORY;
+
         String[] COLUMNS = new String[] {
                 Tables.RAW_CONTACTS + "." + RawContacts._ID,
                 RawContacts.CONTACT_ID,
diff --git a/tests/src/com/android/providers/contacts/CallLogProviderTest.java b/tests/src/com/android/providers/contacts/CallLogProviderTest.java
index 93806e0..bc609e2 100644
--- a/tests/src/com/android/providers/contacts/CallLogProviderTest.java
+++ b/tests/src/com/android/providers/contacts/CallLogProviderTest.java
@@ -16,9 +16,8 @@
 
 package com.android.providers.contacts;
 
-import com.android.internal.telephony.CallerInfo;
+import android.telecom.CallerInfo;
 import com.android.internal.telephony.PhoneConstants;
-import com.android.providers.contacts.CallLogDatabaseHelper.DbProperties;
 import com.android.providers.contacts.testutil.CommonDatabaseUtils;
 
 import android.content.ComponentName;
@@ -63,6 +62,10 @@
     /** Total number of columns exposed by call_log provider. */
     private static final int NUM_CALLLOG_FIELDS = 34;
 
+    private static final int MIN_MATCH = 7;
+
+    private int mOldMinMatch;
+
     private CallLogProviderTestable mCallLogProvider;
 
     @Override
@@ -79,6 +82,8 @@
     protected void setUp() throws Exception {
         super.setUp();
         mCallLogProvider = addProvider(CallLogProviderTestable.class, CallLog.AUTHORITY);
+        mOldMinMatch = mCallLogProvider.getMinMatchForTest();
+        mCallLogProvider.setMinMatchForTest(MIN_MATCH);
     }
 
     @Override
@@ -86,6 +91,7 @@
         setUpWithVoicemailPermissions();
         mResolver.delete(Calls.CONTENT_URI_WITH_VOICEMAIL, null, null);
         setTimeForTest(null);
+        mCallLogProvider.setMinMatchForTest(mOldMinMatch);
         super.tearDown();
     }
 
@@ -180,7 +186,7 @@
 
     public void testAddCall() {
         CallerInfo ci = new CallerInfo();
-        ci.name = "1-800-GOOG-411";
+        ci.setName("1-800-GOOG-411");
         ci.numberType = Phone.TYPE_CUSTOM;
         ci.numberLabel = "Directory";
         final ComponentName sComponentName = new ComponentName(
@@ -202,7 +208,7 @@
         values.put(Calls.NUMBER_PRESENTATION, Calls.PRESENTATION_ALLOWED);
         values.put(Calls.DATE, 2000);
         values.put(Calls.DURATION, 40);
-        values.put(Calls.CACHED_NAME, ci.name);
+        values.put(Calls.CACHED_NAME, ci.getName());
         values.put(Calls.CACHED_NUMBER_TYPE, (String) null);
         values.put(Calls.CACHED_NUMBER_LABEL, (String) null);
         values.put(Calls.COUNTRY_ISO, "us");
diff --git a/tests/src/com/android/providers/contacts/CallerInfoIntegrationTest.java b/tests/src/com/android/providers/contacts/CallerInfoIntegrationTest.java
index 867f01f..f57c060 100644
--- a/tests/src/com/android/providers/contacts/CallerInfoIntegrationTest.java
+++ b/tests/src/com/android/providers/contacts/CallerInfoIntegrationTest.java
@@ -22,7 +22,7 @@
 import android.provider.ContactsContract.RawContacts;
 import android.test.suitebuilder.annotation.MediumTest;
 
-import com.android.internal.telephony.CallerInfo;
+import android.telecom.CallerInfo;
 import com.android.providers.contacts.testutil.DataUtil;
 
 /**
@@ -49,9 +49,9 @@
         insertPhoneNumber(rawContactId, "800-466-4411");
 
         CallerInfo callerInfo = CallerInfo.getCallerInfo(getProvider().getContext(), "18004664411");
-        assertEquals("800-466-4411", callerInfo.phoneNumber);
+        assertEquals("800-466-4411", callerInfo.getPhoneNumber());
         assertEquals("Home", callerInfo.phoneLabel);
-        assertEquals("Hot Tamale", callerInfo.name);
+        assertEquals("Hot Tamale", callerInfo.getName());
         assertEquals("ring", String.valueOf(callerInfo.contactRingtoneUri));
         assertEquals(true, callerInfo.shouldSendToVoicemail);
         assertEquals("content://com.android.contacts/phone_lookup_enterprise/18004664411",
diff --git a/tests/src/com/android/providers/contacts/ContactsActor.java b/tests/src/com/android/providers/contacts/ContactsActor.java
index 470f64b..89f296b 100644
--- a/tests/src/com/android/providers/contacts/ContactsActor.java
+++ b/tests/src/com/android/providers/contacts/ContactsActor.java
@@ -16,6 +16,8 @@
 
 package com.android.providers.contacts;
 
+import static org.mockito.Mockito.when;
+
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AccountManagerCallback;
@@ -57,6 +59,7 @@
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.StatusUpdates;
+import android.telecom.TelecomManager;
 import android.telephony.TelephonyManager;
 import android.test.IsolatedContext;
 import android.test.mock.MockContentResolver;
@@ -68,6 +71,8 @@
 
 import com.google.android.collect.Sets;
 
+import org.mockito.Mockito;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -271,6 +276,8 @@
         }
     }
 
+    private TelecomManager mMockTelecomManager;
+
     /**
      * A context wrapper that reports a different user id.
      *
@@ -322,6 +329,9 @@
                 if (Context.TELEPHONY_SERVICE.equals(name)) {
                     return mMockTelephonyManager;
                 }
+                if (Context.TELECOM_SERVICE.equals(name)) {
+                    return mMockTelecomManager;
+                }
                 // Use overallContext here; super.getSystemService() somehow won't return
                 // DevicePolicyManager.
                 return overallContext.getSystemService(name);
@@ -369,6 +379,9 @@
                 if (Context.TELEPHONY_SERVICE.equals(name)) {
                     return mMockTelephonyManager;
                 }
+                if (Context.TELECOM_SERVICE.equals(name)) {
+                    return mMockTelecomManager;
+                }
                 // Use overallContext here; super.getSystemService() somehow won't return
                 // DevicePolicyManager.
                 return overallContext.getSystemService(name);
@@ -403,6 +416,9 @@
         mMockAccountManager = new MockAccountManager(mProviderContext);
         mockUserManager = new MockUserManager(mProviderContext);
         mMockTelephonyManager = new MockTelephonyManager(mProviderContext);
+        mMockTelecomManager = Mockito.mock(TelecomManager.class);
+        when(mMockTelecomManager.getDefaultDialerPackage()).thenReturn("");
+        when(mMockTelecomManager.getSystemDialerPackage()).thenReturn("");
         provider = addProvider(providerClass, authority);
     }
 
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index 32a0306..6421c8f 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -70,6 +70,7 @@
 import android.provider.ContactsContract.StreamItemPhotos;
 import android.provider.ContactsContract.StreamItems;
 import android.provider.OpenableColumns;
+import android.telephony.PhoneNumberUtils;
 import android.test.MoreAsserts;
 import android.test.suitebuilder.annotation.LargeTest;
 import android.text.TextUtils;
@@ -129,6 +130,31 @@
 
     private static final String TAG = ContactsProvider2Test.class.getSimpleName();
 
+    private static final int MIN_MATCH = 7;
+
+    private int mOldMinMatch1;
+    private int mOldMinMatch2;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        final ContactsProvider2 cp = (ContactsProvider2) getProvider();
+        final ContactsDatabaseHelper dbHelper = cp.getThreadActiveDatabaseHelperForTest();
+        mOldMinMatch1 = PhoneNumberUtils.getMinMatchForTest();
+        mOldMinMatch2 = dbHelper.getMinMatchForTest();
+        PhoneNumberUtils.setMinMatchForTest(MIN_MATCH);
+        dbHelper.setMinMatchForTest(MIN_MATCH);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        final ContactsProvider2 cp = (ContactsProvider2) getProvider();
+        final ContactsDatabaseHelper dbHelper = cp.getThreadActiveDatabaseHelperForTest();
+        PhoneNumberUtils.setMinMatchForTest(mOldMinMatch1);
+        dbHelper.setMinMatchForTest(mOldMinMatch2);
+        super.tearDown();
+    }
+
     public void testConvertEnterpriseUriWithEnterpriseDirectoryToLocalUri() {
         String phoneNumber = "886";
         String directory = String.valueOf(Directory.ENTERPRISE_DEFAULT);
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java
index 927b215..b19a10f 100644
--- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java
+++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregator2Test.java
@@ -34,10 +34,12 @@
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.StatusUpdates;
+import android.telephony.PhoneNumberUtils;
 import android.test.MoreAsserts;
 import android.test.suitebuilder.annotation.MediumTest;
 
 import com.android.providers.contacts.BaseContactsProvider2Test;
+import com.android.providers.contacts.ContactsDatabaseHelper;
 import com.android.providers.contacts.ContactsProvider2;
 import com.android.providers.contacts.TestUtils;
 import com.android.providers.contacts.tests.R;
@@ -69,11 +71,32 @@
             AggregationExceptions.RAW_CONTACT_ID2
     };
 
+    private static final int MIN_MATCH = 7;
+
+    private static int mOldMinMatch1;
+    private static int mOldMinMatch2;
+
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         // Enable new aggregator.
         final ContactsProvider2 cp = (ContactsProvider2) getProvider();
         cp.setNewAggregatorForTest(true);
+
+        final ContactsDatabaseHelper dbHelper = cp.getThreadActiveDatabaseHelperForTest();
+        mOldMinMatch1 = PhoneNumberUtils.getMinMatchForTest();
+        mOldMinMatch2 = dbHelper.getMinMatchForTest();
+        PhoneNumberUtils.setMinMatchForTest(MIN_MATCH);
+        dbHelper.setMinMatchForTest(MIN_MATCH);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        final ContactsProvider2 cp = (ContactsProvider2) getProvider();
+        final ContactsDatabaseHelper dbHelper = cp.getThreadActiveDatabaseHelperForTest();
+        PhoneNumberUtils.setMinMatchForTest(mOldMinMatch1);
+        dbHelper.setMinMatchForTest(mOldMinMatch2);
+        super.tearDown();
     }
 
     public void testCrudAggregationExceptions() throws Exception {
diff --git a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
index fb4f930..56f0883 100644
--- a/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
+++ b/tests/src/com/android/providers/contacts/aggregation/ContactAggregatorTest.java
@@ -34,10 +34,12 @@
 import android.provider.ContactsContract.Data;
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.StatusUpdates;
+import android.telephony.PhoneNumberUtils;
 import android.test.MoreAsserts;
 import android.test.suitebuilder.annotation.MediumTest;
 
 import com.android.providers.contacts.BaseContactsProvider2Test;
+import com.android.providers.contacts.ContactsDatabaseHelper;
 import com.android.providers.contacts.ContactsProvider2;
 import com.android.providers.contacts.TestUtils;
 import com.android.providers.contacts.tests.R;
@@ -63,17 +65,38 @@
     private static final Account ACCOUNT_2 = new Account("account_name_2", "account_type_2");
     private static final Account ACCOUNT_3 = new Account("account_name_3", "account_type_3");
 
+    private static final int MIN_MATCH = 7;
+
+    private int mOldMinMatch1;
+    private int mOldMinMatch2;
+
     private static final String[] AGGREGATION_EXCEPTION_PROJECTION = new String[] {
             AggregationExceptions.TYPE,
             AggregationExceptions.RAW_CONTACT_ID1,
             AggregationExceptions.RAW_CONTACT_ID2
     };
 
+    @Override
     protected void setUp() throws Exception {
         super.setUp();
         final ContactsProvider2 cp = (ContactsProvider2) getProvider();
         // Make sure to use ContactAggregator.java class
         cp.setNewAggregatorForTest(false);
+
+        final ContactsDatabaseHelper dbHelper = cp.getThreadActiveDatabaseHelperForTest();
+        mOldMinMatch1 = PhoneNumberUtils.getMinMatchForTest();
+        mOldMinMatch2 = dbHelper.getMinMatchForTest();
+        PhoneNumberUtils.setMinMatchForTest(MIN_MATCH);
+        dbHelper.setMinMatchForTest(MIN_MATCH);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        final ContactsProvider2 cp = (ContactsProvider2) getProvider();
+        final ContactsDatabaseHelper dbHelper = cp.getThreadActiveDatabaseHelperForTest();
+        PhoneNumberUtils.setMinMatchForTest(mOldMinMatch1);
+        dbHelper.setMinMatchForTest(mOldMinMatch2);
+        super.tearDown();
     }
 
     public void testCrudAggregationExceptions() throws Exception {