Android 簡訊收件者自動匹配與使用者輸入的顯示不一致

來源:互聯網
上載者:User

Android 簡訊收件者自動匹配與使用者輸入的顯示不一致
1.將號碼“12345678”存為連絡人Test後
2.進入簡訊編輯介面,在收件者一欄輸入“13712345678”,再切換到文字輸入框,使收件者那個控制項失焦,可以看到收件者立即顯示為“Test”,再返回去點擊那個收件者,發現目標號碼變成了“12345678”。
3.發送資訊,提示發送失敗。
PS:使用者本來想要把簡訊發送到“13712345678”的,結果因為電話薄裡面存了個“12345678”的連絡人,系統就把發送目標的號碼給變更了,導致資訊發送失敗。

號碼匹配相關的問題都可以先用以下方式驗證,如果還有異常,請提交eService到mediatek.
alps\frameworks\ex\chips\src\com\android\ex\chips\RecipientAlternatesAdapter.java中getRecipientEntryByPhoneNumber() 替換成下面的code:


public static RecipientEntry getRecipientEntryByPhoneNumber(Context context, String phoneNumber) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] phoneNumber: " + phoneNumber); /// M: MTK debug log
if (phoneNumber == null || TextUtils.isEmpty(phoneNumber)) {
return null;
}
final String[] PHONE_LOOKUP_PROJECTION = new String[] {
Phone._ID, // 0
Phone.CONTACT_ID, // 1
Phone.NUMBER, // 2
Phone.NORMALIZED_NUMBER, // 3
Phone.DISPLAY_NAME, // 4
};
long index = -1;
String currentNumber = "";
String normalizedNumber = PhoneNumberUtils.normalizeNumber(phoneNumber);
/// M: Query CONTACT_ID by giving phone number
Cursor cursorNormalize = context.getContentResolver().query(
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, normalizedNumber), PHONE_LOOKUP_PROJECTION, null, null, null);
/// M: Return null if query result is empty
if (cursorNormalize == null) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] cursorNormalize is null"); /// M: MTK debug log
return null;
}
if (cursorNormalize.moveToFirst()) {
do {
index = cursorNormalize.getLong(1); /// M: Phone.CONTACT_ID
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] Query ID for " + phoneNumber
+ " RESULTS: "
+ " NAME : " + cursorNormalize.getString(4)
+ " CONTACT ID : " + cursorNormalize.getLong(1)
+ " ADDRESS :" + cursorNormalize.getString(2));
}
} while (cursorNormalize.moveToNext());
}
cursorNormalize.close();
/// M: No matched contact
if (index == -1) {
return null;
}
/// M: Query contact information by giving CONTACT_ID
RecipientEntry entry = null;
for (long i = index; i > 0; i--) {
Log.d(TAG, " getRecipientEntryByPhoneNumber i = "+ i);
Cursor cursor = context.getContentResolver().query(
Queries.PHONE.getContentUri(),
Queries.PHONE.getProjection(),
Queries.PHONE.getProjection()[Queries.Query.CONTACT_ID] + " IN (" + String.valueOf(i) + ")", null, null);
if (cursor.moveToFirst()) {
do {
if (cursor.getString(Queries.Query.DESTINATION).length() < currentNumber.length())
break;
if (true) {
Log.d(TAG, "[getRecipientEntryByPhoneNumber] Query detail for " + phoneNumber
+ " RESULTS: "
+ " NAME : " + cursor.getString(Queries.Query.NAME)
+ " CONTACT ID : " + cursor.getLong(Queries.Query.CONTACT_ID)
+ " ADDRESS :" + cursor.getString(Queries.Query.DESTINATION));
}
currentNumber = cursor.getString(1); /// M:Phone.NUMBER
if (PhoneNumberUtils.compare(PhoneNumberUtils.normalizeNumber(currentNumber), normalizedNumber)) {
entry = RecipientEntry.constructTopLevelEntry(
cursor.getString(Queries.Query.NAME),
cursor.getInt(Queries.Query.DISPLAY_NAME_SOURCE),
cursor.getString(Queries.Query.DESTINATION),
cursor.getInt(Queries.Query.DESTINATION_TYPE),
cursor.getString(Queries.Query.DESTINATION_LABEL),
cursor.getLong(Queries.Query.CONTACT_ID),
cursor.getLong(Queries.Query.DATA_ID),
cursor.getString(Queries.Query.PHOTO_THUMBNAIL_URI),
true, false);
break;
}
} while (cursor.moveToNext());
}
Log.d(TAG, "[getRecipientEntryByPhoneNumber] cursor count: " + (cursor != null ? cursor.getCount() : "null")); /// M: MTK debug log
cursor.close();
}
if (phoneNumber.length() - entry.getDestination().length() != 3 || entry.getDestination().length() < 11) {
Log.d(TAG, " the query do not meet the conditon, drop it");
entry = null;
}
return entry;
}
注意事項:


1. 先mm build frameworks/ex/chips
2. 然後 mm build packages/app/Mms
將產生的Mms push 到手機

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.