diff options
Diffstat (limited to 'src/com/android')
11 files changed, 122 insertions, 34 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index d9e3088fa..0509fca6f 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -42,6 +42,7 @@ import android.widget.Toast; import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; +import com.android.contacts.common.util.ContactDisplayUtils; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.CallUtil; import com.android.contacts.common.activity.fragment.BlockContactDialogFragment; @@ -196,8 +197,18 @@ public class CallDetailActivity extends Activity */ private CharSequence getNumberTypeOrLocation(PhoneCallDetails details) { if (!TextUtils.isEmpty(details.name)) { - return Phone.getTypeLabel(mResources, details.numberType, - details.numberLabel); + String callMethodName = null; + if (details.inCallComponentName != null) { + CallMethodInfo cmi = DialerDataSubscription.get(mContext) + .getPluginIfExists(details.inCallComponentName); + if (cmi != null) { + callMethodName = cmi.mName; + } + } + + return ContactDisplayUtils.getLabelForCall(getApplicationContext(), + details.number.toString(), details.numberType, + details.numberLabel, callMethodName); } else { return details.geocode; } diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index d9e2744b6..8fee28875 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -23,7 +23,6 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.database.Cursor; import android.net.Uri; -import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.v7.widget.RecyclerView; import android.os.Bundle; import android.os.Trace; @@ -46,6 +45,7 @@ import android.view.accessibility.AccessibilityEvent; import com.android.contacts.common.CallUtil; import com.android.contacts.common.ClipboardUtils; +import com.android.contacts.common.util.ContactDisplayUtils; import com.android.contacts.common.util.PermissionsUtil; import com.android.dialer.DialtactsActivity; import com.android.dialer.PhoneCallDetails; @@ -58,6 +58,8 @@ import com.android.dialer.deeplink.DeepLinkRequest; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.PhoneNumberUtil; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; +import com.android.phone.common.incall.CallMethodInfo; +import com.android.phone.common.incall.DialerDataSubscription; import com.cyanogen.ambient.deeplink.DeepLink; import com.cyanogen.ambient.incall.extension.OriginCodes; @@ -502,7 +504,7 @@ public class CallLogAdapter extends GroupingListAdapter c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME), c.getString(CallLogQuery.ACCOUNT_ID)); final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO); - final ContactInfo cachedContactInfo = mContactInfoHelper.getContactInfo(c); + final ContactInfo cachedContactInfo = mContactInfoHelper.getContactInfo(mContext, c); final boolean isVoicemailNumber = mTelecomCallLogCache.isVoicemailNumber(accountHandle, number); @@ -558,8 +560,6 @@ public class CallLogAdapter extends GroupingListAdapter // Stash away the Ids of the calls so that we can support deleting a row in the call log. views.callIds = getCallIds(c, count); views.isBusiness = mContactInfoHelper.isBusiness(info.sourceType); - views.numberType = (String) Phone.getTypeLabel(mContext.getResources(), details.numberType, - details.numberLabel); String component = c.getString(CallLogQuery.PLUGIN_PACKAGE_NAME); if (!TextUtils.isEmpty(component)) { views.inCallComponentName = ComponentName.unflattenFromString(component); @@ -577,7 +577,23 @@ public class CallLogAdapter extends GroupingListAdapter views.phoneCallDetailsViews.noteIconView.setVisibility(View.GONE); } - views.mDeepLinkPresenter.prepareUi(number); + String callMethodName = null; + if (views.inCallComponentName != null) { + CallMethodInfo cmi = DialerDataSubscription.get(mContext) + .getPluginIfExists(views.inCallComponentName); + if (cmi != null) { + callMethodName = cmi.mName; + } + } + + final String label = ContactDisplayUtils.getLabelForCall(mContext, number, + details.numberType, details.numberLabel, callMethodName); + + views.numberType = label; + details.numberLabel = label; + + views.mDeepLinkPresenter.prepareUi(number); + // Check if the day group has changed and display a header if necessary. int currentGroup = getDayGroupForCall(views.rowId); int previousGroup = getPreviousDayGroup(c); diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java index 5b066c2a6..63f79be0b 100644 --- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java +++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java @@ -30,6 +30,7 @@ import android.text.TextUtils; import android.util.Log; import com.android.contacts.common.GeoUtil; +import com.android.contacts.common.util.PhoneNumberHelper; import com.android.dialer.PhoneCallDetails; import com.android.dialer.util.AsyncTaskExecutor; import com.android.dialer.util.AsyncTaskExecutors; @@ -156,6 +157,10 @@ public class CallLogAsyncTaskUtil { cursor.getString(CallDetailQuery.ACCOUNT_COMPONENT_NAME), cursor.getString(CallDetailQuery.ACCOUNT_ID)); + final boolean isInCallPluginContactId = + ContactInfoHelper.isInCallPluginContactId(context, accountHandle, number, + countryIso, cursor.getString(CallDetailQuery.PLUGIN_PACKAGE_NAME)); + // If this is not a regular number, there is no point in looking it up in the contacts. ContactInfoHelper contactInfoHelper = new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)); @@ -165,7 +170,8 @@ public class CallLogAsyncTaskUtil { ContactInfo info = ContactInfo.EMPTY; if (shouldLookupNumber) { - ContactInfo lookupInfo = contactInfoHelper.lookupNumber(number, countryIso); + ContactInfo lookupInfo = + contactInfoHelper.lookupNumber(number, countryIso, isInCallPluginContactId); info = lookupInfo != null ? lookupInfo : ContactInfo.EMPTY; } diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java index bbcf1b482..1f44c6f45 100644 --- a/src/com/android/dialer/calllog/ContactInfo.java +++ b/src/com/android/dialer/calllog/ContactInfo.java @@ -58,6 +58,8 @@ public class ContactInfo { public String lookupProviderName; public Drawable attributionDrawable; + public boolean isInCallPluginContactId; + public static ContactInfo EMPTY = new ContactInfo(); public int sourceType = 0; diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 0bfe92bca..3442df0af 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -25,6 +25,8 @@ import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.DisplayNameSources; import android.provider.ContactsContract.PhoneLookup; +import android.telecom.PhoneAccount; +import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.Log; @@ -56,6 +58,14 @@ import org.json.JSONObject; public class ContactInfoHelper { private static final String TAG = ContactInfoHelper.class.getSimpleName(); + /** + * If this boolean parameter is set to true, then the appended query is treated as a + * InCallApi plugin contact ID and the lookup will be performed against InCallApi contacts in + * the user's contacts. + */ + // TODO: Move this to a more central place + private static final String QUERY_PARAMETER_INCALLAPI_ID = "incallapi_contactid"; + private final Context mContext; private final String mCurrentCountryIso; private final LookupProvider mLookupProvider; @@ -84,8 +94,10 @@ public class ContactInfoHelper { * * @param number the number to look up * @param countryIso the country associated with this number + * @param isInCallPluginContactId true if number is an InCallApi plugin contact id */ - public ContactInfo lookupNumber(String number, String countryIso) { + public ContactInfo lookupNumber(String number, String countryIso, + boolean isInCallPluginContactId) { if (TextUtils.isEmpty(number)) { return null; } @@ -100,13 +112,14 @@ public class ContactInfoHelper { // actually the phone number of a contact. String username = PhoneNumberHelper.getUsernameFromUriNumber(number); if (PhoneNumberUtils.isGlobalPhoneNumber(username)) { - sipInfo = queryContactInfoForPhoneNumber(username, countryIso); + sipInfo = queryContactInfoForPhoneNumber(username, countryIso, false); } } info = sipInfo; } else { // Look for a contact that has the given phone number. - ContactInfo phoneInfo = queryContactInfoForPhoneNumber(number, countryIso); + ContactInfo phoneInfo = + queryContactInfoForPhoneNumber(number, countryIso, isInCallPluginContactId); if (phoneInfo == null || phoneInfo == ContactInfo.EMPTY) { // Check whether the phone number has been saved as an "Internet call" number. @@ -264,7 +277,8 @@ public class ContactInfoHelper { * <p> * If the lookup fails for some other reason, it returns null. */ - private ContactInfo queryContactInfoForPhoneNumber(String number, String countryIso) { + private ContactInfo queryContactInfoForPhoneNumber(String number, String countryIso, + boolean isInCallPluginContactId) { if (TextUtils.isEmpty(number)) { return null; } @@ -280,9 +294,11 @@ public class ContactInfoHelper { } // The "contactNumber" is a regular phone number, so use the PhoneLookup table. - Uri uri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, - Uri.encode(contactNumber)); - ContactInfo info = lookupContactFromUri(uri); + Uri.Builder uriBuilder = PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI.buildUpon(); + uriBuilder.appendPath(Uri.encode(contactNumber)); + uriBuilder.appendQueryParameter(QUERY_PARAMETER_INCALLAPI_ID, + String.valueOf(isInCallPluginContactId)); + ContactInfo info = lookupContactFromUri(uriBuilder.build()); boolean isLocalContact = info != null && info != ContactInfo.EMPTY; if (info != null && info != ContactInfo.EMPTY) { info.formattedNumber = formatPhoneNumber(number, null, countryIso); @@ -467,7 +483,7 @@ public class ContactInfoHelper { * * @param c A cursor pointing to an entry in the call log. */ - public static ContactInfo getContactInfo(Cursor c) { + public static ContactInfo getContactInfo(Context context, Cursor c) { ContactInfo info = new ContactInfo(); info.lookupUri = UriUtils.parseUriOrNull(c.getString(CallLogQuery.CACHED_LOOKUP_URI)); @@ -482,6 +498,15 @@ public class ContactInfoHelper { UriUtils.parseUriOrNull(c.getString(CallLogQuery.CACHED_PHOTO_URI))); info.formattedNumber = c.getString(CallLogQuery.CACHED_FORMATTED_NUMBER); + final String componentString = c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); + final String accountId = c.getString(CallLogQuery.ACCOUNT_ID); + final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO); + info.isInCallPluginContactId = isInCallPluginContactId(context, + PhoneAccountUtils.getAccount(componentString, accountId), + info.number, + countryIso, + c.getString(CallLogQuery.PLUGIN_PACKAGE_NAME)); + return info; } @@ -520,4 +545,12 @@ public class ContactInfoHelper { field); } + public static boolean isInCallPluginContactId(Context context, + PhoneAccountHandle accountHandle, String number, String countryIso, String pluginName) { + boolean isInCallPluginContactId = accountHandle == null && + !PhoneNumberHelper.isValidNumber(context, number, countryIso) && + !TextUtils.isEmpty(pluginName); + + return isInCallPluginContactId; + } } diff --git a/src/com/android/dialer/callstats/CallStatsDetailActivity.java b/src/com/android/dialer/callstats/CallStatsDetailActivity.java index 4d9c36c6c..1be6294b4 100644 --- a/src/com/android/dialer/callstats/CallStatsDetailActivity.java +++ b/src/com/android/dialer/callstats/CallStatsDetailActivity.java @@ -90,7 +90,8 @@ public class CallStatsDetailActivity extends Activity implements private class UpdateContactTask extends AsyncTask<String, Void, ContactInfo> { @Override protected ContactInfo doInBackground(String... strings) { - ContactInfo info = mContactInfoHelper.lookupNumber(strings[0], strings[1]); + ContactInfo info = mContactInfoHelper.lookupNumber(strings[0], strings[1], + Boolean.valueOf(strings[2])); return info; } @@ -178,7 +179,8 @@ public class CallStatsDetailActivity extends Activity implements @Override public void onResume() { super.onResume(); - new UpdateContactTask().execute(mData.number.toString(), mData.countryIso); + new UpdateContactTask().execute(mData.number.toString(), mData.countryIso, + String.valueOf(mData.isInCallPluginContactId)); } @Override diff --git a/src/com/android/dialer/callstats/CallStatsDetails.java b/src/com/android/dialer/callstats/CallStatsDetails.java index c07209fb5..a5082b459 100644 --- a/src/com/android/dialer/callstats/CallStatsDetails.java +++ b/src/com/android/dialer/callstats/CallStatsDetails.java @@ -58,6 +58,8 @@ public class CallStatsDetails implements Parcelable { public boolean isVoicemailNumber; public String displayNumber; + public boolean isInCallPluginContactId; + public CallStatsDetails(CharSequence number, int numberPresentation, PhoneAccountHandle accountHandle, ContactInfo info, String countryIso, String geocode, long date) { @@ -86,6 +88,7 @@ public class CallStatsDetails implements Parcelable { this.photoId = info.photoId; this.sourceType = info.sourceType; this.displayNumber = null; + this.isInCallPluginContactId = info.isInCallPluginContactId; } public void updateDisplayPropertiesIfNeeded(Context context) { diff --git a/src/com/android/dialer/contactinfo/ContactInfoCache.java b/src/com/android/dialer/contactinfo/ContactInfoCache.java index 568f48886..b2f862335 100644 --- a/src/com/android/dialer/contactinfo/ContactInfoCache.java +++ b/src/com/android/dialer/contactinfo/ContactInfoCache.java @@ -20,6 +20,7 @@ import android.os.Handler; import android.os.Message; import android.text.TextUtils; +import com.android.dialer.calllog.CallLogAsyncTaskUtil; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.util.ExpirableCache; @@ -190,7 +191,8 @@ public class ContactInfoCache { * view to update its content. */ private boolean queryContactInfo(String number, String countryIso, ContactInfo callLogInfo) { - final ContactInfo info = mContactInfoHelper.lookupNumber(number, countryIso); + final ContactInfo info = mContactInfoHelper.lookupNumber(number, countryIso, + callLogInfo.isInCallPluginContactId); if (info == null) { // The lookup failed, just return without requesting to update the view. diff --git a/src/com/android/dialer/database/DialerDatabaseHelper.java b/src/com/android/dialer/database/DialerDatabaseHelper.java index 400b2b2cf..35caf84c5 100644 --- a/src/com/android/dialer/database/DialerDatabaseHelper.java +++ b/src/com/android/dialer/database/DialerDatabaseHelper.java @@ -80,7 +80,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { * 0-98 KitKat * </pre> */ - public static final int DATABASE_VERSION = 70006; + public static final int DATABASE_VERSION = 70007; public static final String DATABASE_NAME = "dialer.db"; /** @@ -121,6 +121,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { static final String LAST_SMARTDIAL_UPDATE_TIME = "last_smartdial_update_time"; static final String MIMETYPE = "mimetype"; static final String PHONE_TYPE = "phone_type"; + static final String PHONE_LABEL = "phone_label"; } public static interface PrefixColumns extends BaseColumns { @@ -267,9 +268,10 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { public final long photoId; public final String mimeType; public final int phoneType; + public final String phoneLabel; public ContactNumber(long id, long dataID, String displayName, String phoneNumber, - String lookupKey, long photoId, String mimeType, int phoneType) { + String lookupKey, long photoId, String mimeType, int phoneType, String phoneLabel) { this.dataId = dataID; this.id = id; this.displayName = displayName; @@ -278,12 +280,13 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { this.photoId = photoId; this.mimeType = mimeType; this.phoneType = phoneType; + this.phoneLabel = phoneLabel; } @Override public int hashCode() { return Objects.hashCode(id, dataId, displayName, phoneNumber, lookupKey, photoId, - mimeType, phoneType); + mimeType, phoneType, phoneLabel); } @Override @@ -300,7 +303,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { && Objects.equal(this.lookupKey, that.lookupKey) && Objects.equal(this.photoId, that.photoId) && Objects.equal(this.mimeType, that.mimeType) - && Objects.equal(this.phoneType, that.phoneType); + && Objects.equal(this.phoneType, that.phoneType) + && Objects.equal(this.phoneLabel, that.phoneLabel); } return false; @@ -427,7 +431,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { SmartDialDbColumns.IN_VISIBLE_GROUP + " INTEGER, " + SmartDialDbColumns.IS_PRIMARY + " INTEGER, " + SmartDialDbColumns.MIMETYPE + " TEXT, " + - SmartDialDbColumns.PHONE_TYPE + " INTEGER" + + SmartDialDbColumns.PHONE_TYPE + " INTEGER, " + + SmartDialDbColumns.PHONE_LABEL + " Text" + ");"); db.execSQL("CREATE TABLE " + Tables.PREFIX_TABLE + " (" + @@ -750,8 +755,9 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { SmartDialDbColumns.IS_PRIMARY + ", " + SmartDialDbColumns.LAST_SMARTDIAL_UPDATE_TIME + ", " + SmartDialDbColumns.MIMETYPE + ", " + - SmartDialDbColumns.PHONE_TYPE + ") " + - " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + SmartDialDbColumns.PHONE_TYPE + ", " + + SmartDialDbColumns.PHONE_LABEL + ") " + + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; final SQLiteStatement insert = db.compileStatement(sqlInsert); final String numberSqlInsert = "INSERT INTO " + Tables.PREFIX_TABLE + " (" + @@ -805,6 +811,11 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER_MIMETYPE); insert.bindString(14, mimetype); + final String label = updatedContactCursor.getString(PhoneQuery.PHONE_LABEL); + if (label != null) { + insert.bindString(16, label); + } + insert.executeInsert(); final String contactPhoneNumber = updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER); @@ -1114,7 +1125,8 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { SmartDialDbColumns.CONTACT_ID + ", " + SmartDialDbColumns.LOOKUP_KEY + ", " + SmartDialDbColumns.PHONE_TYPE + ", " + - SmartDialDbColumns.MIMETYPE + + SmartDialDbColumns.MIMETYPE + ", " + + SmartDialDbColumns.PHONE_LABEL + " FROM " + Tables.SMARTDIAL_TABLE + " WHERE " + where.toString() + " ORDER BY " + SmartDialSortingOrder.SORT_ORDER, @@ -1136,6 +1148,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { final int columnLookupKey = 5; final int columnPhoneType = 6; final int columnMimetype = 7; + final int columnPhoneLabel = 8; if (DEBUG) { stopWatch.lap("Found column IDs"); @@ -1155,6 +1168,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { final String lookupKey = cursor.getString(columnLookupKey); final int phoneType = cursor.getInt(columnPhoneType); final String mimeType = cursor.getString(columnMimetype); + final String phoneLabel = cursor.getString(columnPhoneLabel); /** * If the contact has either the name or number OR a username @@ -1167,7 +1181,7 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { if (nameMatches || numberMatches) { /** If a contact has not been added, add it to the result and the hash set.*/ result.add(new ContactNumber(id, dataID, displayName, phoneNumber, lookupKey, - photoId, mimeType, phoneType)); + photoId, mimeType, phoneType, phoneLabel)); counter++; if (DEBUG) { stopWatch.lap("Added one result: Name: " + displayName); diff --git a/src/com/android/dialer/dialpad/SmartDialCursorLoader.java b/src/com/android/dialer/dialpad/SmartDialCursorLoader.java index 1cc56f1c3..a5ecfe5f6 100644 --- a/src/com/android/dialer/dialpad/SmartDialCursorLoader.java +++ b/src/com/android/dialer/dialpad/SmartDialCursorLoader.java @@ -116,6 +116,7 @@ public class SmartDialCursorLoader extends AsyncTaskLoader<Cursor> { row[PhoneQuery.PHONE_NUMBER] = contact.phoneNumber; row[PhoneQuery.PHONE_MIME_TYPE] = contact.mimeType; row[PhoneQuery.PHONE_TYPE] = contact.phoneType; + row[PhoneQuery.PHONE_LABEL] = contact.phoneLabel; cursor.addRow(row); } } diff --git a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java index 53d95e351..6d2784e3b 100644 --- a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java +++ b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java @@ -202,17 +202,15 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { @Override public String getLabelType(Cursor c, int type) { if (type == ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM) { - final String providerLabel = c.getString(PhoneNumberListAdapter.PhoneQuery.PHONE_MIME_TYPE); - CallMethodInfo cmi = CallMethodFilters.getMethodForMimeType(providerLabel, false, + final String mimetype = c.getString(PhoneNumberListAdapter.PhoneQuery.PHONE_MIME_TYPE); + CallMethodInfo cmi = CallMethodFilters.getMethodForMimeType(mimetype, false, DialerDataSubscription.get(getContext())); + if (cmi != null) { return cmi.mName; - } else { - return null; } - } else { - return null; } + return null; } private void assignShortcutToView(ContactListItemView v, int shortcutType, int position) { |
