No contacts can be found after an automatic MCCMNC number is added to android.

Source: Internet
Author: User

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 ();
......

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.