No contacts can be found after an automatic MCCMNC number is added to android.
Because different sim cards correspond to different mccmnc, the value of min_match changes,
The new min_match value is inconsistent with the min_match saved in the previous phone_lookup table, and thus cannot be matched.
Modify as follows:
1. Add URI
Modify ContactsProvider2.java,
Private static final int PHONE_LOOKUP = 4000;
Add a line below:
Private static final int PHONE_LOOKUP2 = 4001; // New Add
Matcher. addURI (ContactsContract. AUTHORITY, "provider_status", PROVIDER_STATUS );
Add a line below:
Matcher. addURI (ContactsContract. AUTHORITY, "phone_lookup2", PHONE_LOOKUP2); // New Add
2. Implement the method to process the corresponding URI
Modify the updateInTransaction () of contactsProvider2.java ().
Case PHONE_LOOKUP2:
Final SQLiteDatabase mDb = mDbHelper. get (). getWritableDatabase (); // mDb
Cursor c = mDb. query (Tables. PHONE_LOOKUP,
New String [] {PhoneLookupColumns. DATA_ID,
PhoneLookupColumns. RAW_CONTACT_ID,
PhoneLookupColumns. NORMALIZED_NUMBER,
PhoneLookupColumns. MIN_MATCH },
Null, null );
While (c. moveToNext ()){
Long dataId = c. getLong (0 );
Long rawContactId = c. getLong (1 );
String normalizeNumber = c. getString (2 );
String oldMinMatch = c. getString (3 );
ContentValues phoneValues = new ContentValues ();
PhoneValues. put (PhoneLookupColumns. RAW_CONTACT_ID, rawContactId );
PhoneValues. put (PhoneLookupColumns. DATA_ID, dataId );
PhoneValues. put (PhoneLookupColumns. NORMALIZED_NUMBER, normalizeNumber );
// Get minMatch
Log. d (TAG, "[PHONE_LOOKUP2] 1. normalizeNumber:" + normalizeNumber );
String minMatch = PhoneNumberUtils. toCallerIDMinMatch (normalizeNumber );
PhoneValues. put (PhoneLookupColumns. MIN_MATCH, minMatch );
Log. d (TAG, "[PHONE_LOOKUP2] 2. normalizeNumber:" + normalizeNumber + "oldMinMatch:" + oldMinMatch + "minMatch:" + minMatch );
MDb. update (Tables. PHONE_LOOKUP, phoneValues, PhoneLookupColumns. DATA_ID + "=" + dataId + "AND" + PhoneLookupColumns. RAW_CONTACT_ID + "=" + rawContactId, null );
}
C. close ();
Break;
3. start updating min_match in the phone_lookup table.
------------ [JB 4.2] ------------
Modify AbstractStartSIMService. java under the Contacts package
Case FINISH_IMPORTING Add the following code before canStopSelf () in the break of this case:
......
If (canStopSelf ){
Log. I (TAG, "Will call stopSelf here .")
// New add
ContentResolver contentResolver = mContext. getContentResolver ();
Uri uri = Uri. parse ("content: // com. android. contacts/phone_lookup2 ");
ContentResolver. update (uri, new ContentValues (), null, null );
// End
StopSelf ();
}
------------ [KK 4.4] ------------
Modify SIMProcessorManager. java, SIMProcessorManager () --> handleMessage (),
Add the following code before callStopService:
......
LogUtils. d (TAG, "handleMessage MSF_SEND_STOP_SERVICE ");
// New add
ContentResolver contentResolver = mContext. getContentResolver ();
Uri uri = Uri. parse ("content: // com. android. contacts/phone_lookup2 ");
ContentResolver. update (uri, new ContentValues (), null, null );
// End
CallStopService ();
......