Allow privileged apps to query contact provider across user
am: 6c1fbf2ed9
Change-Id: I7b77648c640df438f1fe5b1d3a90d44a7add3b8c
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-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-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/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index ff3e65c..022b61e 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);
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index 4c521f4..91a2a91 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) {
@@ -4239,7 +4243,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 +4340,10 @@
return mUseStrictPhoneNumberComparison ? "1" : "0";
}
+ public String getMinMatchParameter() {
+ return String.valueOf(mMinMatch);
+ }
+
/**
* Loads common nickname mappings into the database.
*/
@@ -4954,6 +4962,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 c43cc1e..26e3e51 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -9843,7 +9843,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/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..247da7d 100644
--- a/tests/src/com/android/providers/contacts/CallLogProviderTest.java
+++ b/tests/src/com/android/providers/contacts/CallLogProviderTest.java
@@ -63,6 +63,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 +83,8 @@
protected void setUp() throws Exception {
super.setUp();
mCallLogProvider = addProvider(CallLogProviderTestable.class, CallLog.AUTHORITY);
+ mOldMinMatch = mCallLogProvider.getMinMatchForTest();
+ mCallLogProvider.setMinMatchForTest(MIN_MATCH);
}
@Override
@@ -86,6 +92,7 @@
setUpWithVoicemailPermissions();
mResolver.delete(Calls.CONTENT_URI_WITH_VOICEMAIL, null, null);
setTimeForTest(null);
+ mCallLogProvider.setMinMatchForTest(mOldMinMatch);
super.tearDown();
}
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 {