Loading java/com/android/dialer/phonenumbercache/ContactInfoHelper.java +14 −16 Original line number Diff line number Diff line Loading @@ -337,30 +337,28 @@ public class ContactInfoHelper { return ContactInfo.EMPTY; } Cursor phoneLookupCursor = null; try { String[] projection = PhoneQuery.getPhoneLookupProjection(uri); phoneLookupCursor = mContext.getContentResolver().query(uri, projection, null, null, null); } catch (NullPointerException e) { LogUtil.e("ContactInfoHelper.lookupContactFromUri", "phone lookup", e); // Trap NPE from pre-N CP2 return null; } try (Cursor phoneLookupCursor = mContext .getContentResolver() .query( uri, PhoneQuery.getPhoneLookupProjection(uri), null /* selection */, null /* selectionArgs */, null /* sortOrder */)) { if (phoneLookupCursor == null) { LogUtil.d("ContactInfoHelper.lookupContactFromUri", "phoneLookupCursor is null"); return null; } try { if (!phoneLookupCursor.moveToFirst()) { return ContactInfo.EMPTY; } String lookupKey = phoneLookupCursor.getString(PhoneQuery.LOOKUP_KEY); ContactInfo contactInfo = createPhoneLookupContactInfo(phoneLookupCursor, lookupKey); fillAdditionalContactInfo(mContext, contactInfo); return contactInfo; } finally { phoneLookupCursor.close(); } } Loading java/com/android/incallui/util/TelecomCallUtil.java→java/com/android/dialer/telecom/TelecomCallUtil.java +106 −0 Original line number Diff line number Diff line Loading @@ -14,11 +14,22 @@ * limitations under the License. */ package com.android.incallui.util; package com.android.dialer.telecom; import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.telecom.Call; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import android.telephony.SubscriptionInfo; import android.text.TextUtils; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.google.common.base.Optional; import java.util.Locale; /** * Class to provide a standard interface for obtaining information from the underlying Loading @@ -28,13 +39,19 @@ import android.telephony.PhoneNumberUtils; */ public class TelecomCallUtil { // Whether the call handle is an emergency number. public static boolean isEmergencyCall(Call call) { /** Returns Whether the call handle is an emergency number. */ public static boolean isEmergencyCall(@NonNull Call call) { Assert.isNotNull(call); Uri handle = call.getDetails().getHandle(); return PhoneNumberUtils.isEmergencyNumber(handle == null ? "" : handle.getSchemeSpecificPart()); } public static String getNumber(Call call) { /** * Returns The phone number which the {@code Call} is currently connected, or {@code null} if the * number is not available. */ @Nullable public static String getNumber(@Nullable Call call) { if (call == null) { return null; } Loading @@ -45,7 +62,45 @@ public class TelecomCallUtil { return handle == null ? null : handle.getSchemeSpecificPart(); } public static Uri getHandle(Call call) { /** * Returns The handle (e.g., phone number) to which the {@code Call} is currently connected, or * {@code null} if the number is not available. */ @Nullable public static Uri getHandle(@Nullable Call call) { return call == null ? null : call.getDetails().getHandle(); } /** * Normalizes the number of the {@code call} to E.164. If the country code is missing in the * number the SIM's country will be used. Only removes non-dialable digits if the country code is * missing. */ @WorkerThread public static Optional<String> getNormalizedNumber(Context appContext, Call call) { Assert.isWorkerThread(); PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle(); Optional<SubscriptionInfo> subscriptionInfo = TelecomUtil.getSubscriptionInfo(appContext, phoneAccountHandle); String rawNumber = getNumber(call); if (TextUtils.isEmpty(rawNumber)) { return Optional.absent(); } String normalizedNumber = PhoneNumberUtils.normalizeNumber(rawNumber); if (TextUtils.isEmpty(normalizedNumber)) { return Optional.absent(); } String countryCode = subscriptionInfo.isPresent() ? subscriptionInfo.get().getCountryIso() : null; if (countryCode == null) { LogUtil.w( "PhoneLookupHistoryRecorder.getNormalizedNumber", "couldn't find a country code for call"); return Optional.of(normalizedNumber); } String e164Number = PhoneNumberUtils.formatNumberToE164(rawNumber, countryCode.toUpperCase(Locale.US)); return e164Number == null ? Optional.of(normalizedNumber) : Optional.of(e164Number); } } java/com/android/incallui/CallerInfo.java +118 −120 Original line number Diff line number Diff line Loading @@ -198,19 +198,24 @@ public class CallerInfo { */ public static CallerInfo getCallerInfo(Context context, Uri contactRef, Cursor cursor) { CallerInfo info = new CallerInfo(); info.photoResource = 0; info.phoneLabel = null; info.numberType = 0; info.numberLabel = null; info.cachedPhoto = null; info.isCachedPhotoCurrent = false; info.contactExists = false; info.contactRefUri = contactRef; info.isCachedPhotoCurrent = false; info.name = null; info.needUpdate = false; info.numberLabel = null; info.numberType = 0; info.phoneLabel = null; info.photoResource = 0; info.userType = ContactsUtils.USER_TYPE_CURRENT; Log.v(TAG, "getCallerInfo() based on cursor..."); if (cursor != null) { if (cursor.moveToFirst()) { if (cursor == null || !cursor.moveToFirst()) { return info; } // TODO: photo_id is always available but not taken // care of here. Maybe we should store it in the // CallerInfo object as well. Loading @@ -221,7 +226,7 @@ public class CallerInfo { // Look for the name columnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME); if (columnIndex != -1) { info.name = cursor.getString(columnIndex); info.name = normalize(cursor.getString(columnIndex)); } // Look for the number Loading Loading @@ -261,8 +266,7 @@ public class CallerInfo { contactId = cursor.getLong(columnIndex); // QuickContacts in M doesn't support enterprise contact id if (contactId != 0 && (VERSION.SDK_INT >= VERSION_CODES.N || !Contacts.isEnterpriseContactId(contactId))) { && (VERSION.SDK_INT >= VERSION_CODES.N || !Contacts.isEnterpriseContactId(contactId))) { info.contactIdOrZero = contactId; Log.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero); } Loading Loading @@ -320,13 +324,7 @@ public class CallerInfo { info.nameAlternative = ContactInfoHelper.lookUpDisplayNameAlternative( context, info.lookupKeyOrNull, info.userType, directoryId); } cursor.close(); } info.needUpdate = false; info.name = normalize(info.name); info.contactRefUri = contactRef; return info; } Loading java/com/android/incallui/ExternalCallNotifier.java +1 −1 Original line number Diff line number Diff line Loading @@ -44,11 +44,11 @@ import com.android.dialer.common.Assert; import com.android.dialer.contactphoto.BitmapUtil; import com.android.dialer.notification.DialerNotificationManager; import com.android.dialer.notification.NotificationChannelId; import com.android.dialer.telecom.TelecomCallUtil; import com.android.incallui.call.DialerCall; import com.android.incallui.call.DialerCallDelegate; import com.android.incallui.call.ExternalCallList; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.util.TelecomCallUtil; import java.util.Map; /** Loading java/com/android/incallui/InCallPresenter.java +2 −2 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.postcall.PostCall; import com.android.dialer.telecom.TelecomCallUtil; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.TouchPointManager; import com.android.incallui.InCallOrientationEventListener.ScreenOrientation; Loading @@ -66,7 +67,6 @@ import com.android.incallui.incalluilock.InCallUiLock; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.legacyblocking.BlockedNumberContentObserver; import com.android.incallui.spam.SpamCallListListener; import com.android.incallui.util.TelecomCallUtil; import com.android.incallui.videosurface.bindings.VideoSurfaceBindings; import com.android.incallui.videosurface.protocol.VideoSurfaceTexture; import com.android.incallui.videotech.utils.VideoUtils; Loading Loading
java/com/android/dialer/phonenumbercache/ContactInfoHelper.java +14 −16 Original line number Diff line number Diff line Loading @@ -337,30 +337,28 @@ public class ContactInfoHelper { return ContactInfo.EMPTY; } Cursor phoneLookupCursor = null; try { String[] projection = PhoneQuery.getPhoneLookupProjection(uri); phoneLookupCursor = mContext.getContentResolver().query(uri, projection, null, null, null); } catch (NullPointerException e) { LogUtil.e("ContactInfoHelper.lookupContactFromUri", "phone lookup", e); // Trap NPE from pre-N CP2 return null; } try (Cursor phoneLookupCursor = mContext .getContentResolver() .query( uri, PhoneQuery.getPhoneLookupProjection(uri), null /* selection */, null /* selectionArgs */, null /* sortOrder */)) { if (phoneLookupCursor == null) { LogUtil.d("ContactInfoHelper.lookupContactFromUri", "phoneLookupCursor is null"); return null; } try { if (!phoneLookupCursor.moveToFirst()) { return ContactInfo.EMPTY; } String lookupKey = phoneLookupCursor.getString(PhoneQuery.LOOKUP_KEY); ContactInfo contactInfo = createPhoneLookupContactInfo(phoneLookupCursor, lookupKey); fillAdditionalContactInfo(mContext, contactInfo); return contactInfo; } finally { phoneLookupCursor.close(); } } Loading
java/com/android/incallui/util/TelecomCallUtil.java→java/com/android/dialer/telecom/TelecomCallUtil.java +106 −0 Original line number Diff line number Diff line Loading @@ -14,11 +14,22 @@ * limitations under the License. */ package com.android.incallui.util; package com.android.dialer.telecom; import android.content.Context; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; import android.telecom.Call; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import android.telephony.SubscriptionInfo; import android.text.TextUtils; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.google.common.base.Optional; import java.util.Locale; /** * Class to provide a standard interface for obtaining information from the underlying Loading @@ -28,13 +39,19 @@ import android.telephony.PhoneNumberUtils; */ public class TelecomCallUtil { // Whether the call handle is an emergency number. public static boolean isEmergencyCall(Call call) { /** Returns Whether the call handle is an emergency number. */ public static boolean isEmergencyCall(@NonNull Call call) { Assert.isNotNull(call); Uri handle = call.getDetails().getHandle(); return PhoneNumberUtils.isEmergencyNumber(handle == null ? "" : handle.getSchemeSpecificPart()); } public static String getNumber(Call call) { /** * Returns The phone number which the {@code Call} is currently connected, or {@code null} if the * number is not available. */ @Nullable public static String getNumber(@Nullable Call call) { if (call == null) { return null; } Loading @@ -45,7 +62,45 @@ public class TelecomCallUtil { return handle == null ? null : handle.getSchemeSpecificPart(); } public static Uri getHandle(Call call) { /** * Returns The handle (e.g., phone number) to which the {@code Call} is currently connected, or * {@code null} if the number is not available. */ @Nullable public static Uri getHandle(@Nullable Call call) { return call == null ? null : call.getDetails().getHandle(); } /** * Normalizes the number of the {@code call} to E.164. If the country code is missing in the * number the SIM's country will be used. Only removes non-dialable digits if the country code is * missing. */ @WorkerThread public static Optional<String> getNormalizedNumber(Context appContext, Call call) { Assert.isWorkerThread(); PhoneAccountHandle phoneAccountHandle = call.getDetails().getAccountHandle(); Optional<SubscriptionInfo> subscriptionInfo = TelecomUtil.getSubscriptionInfo(appContext, phoneAccountHandle); String rawNumber = getNumber(call); if (TextUtils.isEmpty(rawNumber)) { return Optional.absent(); } String normalizedNumber = PhoneNumberUtils.normalizeNumber(rawNumber); if (TextUtils.isEmpty(normalizedNumber)) { return Optional.absent(); } String countryCode = subscriptionInfo.isPresent() ? subscriptionInfo.get().getCountryIso() : null; if (countryCode == null) { LogUtil.w( "PhoneLookupHistoryRecorder.getNormalizedNumber", "couldn't find a country code for call"); return Optional.of(normalizedNumber); } String e164Number = PhoneNumberUtils.formatNumberToE164(rawNumber, countryCode.toUpperCase(Locale.US)); return e164Number == null ? Optional.of(normalizedNumber) : Optional.of(e164Number); } }
java/com/android/incallui/CallerInfo.java +118 −120 Original line number Diff line number Diff line Loading @@ -198,19 +198,24 @@ public class CallerInfo { */ public static CallerInfo getCallerInfo(Context context, Uri contactRef, Cursor cursor) { CallerInfo info = new CallerInfo(); info.photoResource = 0; info.phoneLabel = null; info.numberType = 0; info.numberLabel = null; info.cachedPhoto = null; info.isCachedPhotoCurrent = false; info.contactExists = false; info.contactRefUri = contactRef; info.isCachedPhotoCurrent = false; info.name = null; info.needUpdate = false; info.numberLabel = null; info.numberType = 0; info.phoneLabel = null; info.photoResource = 0; info.userType = ContactsUtils.USER_TYPE_CURRENT; Log.v(TAG, "getCallerInfo() based on cursor..."); if (cursor != null) { if (cursor.moveToFirst()) { if (cursor == null || !cursor.moveToFirst()) { return info; } // TODO: photo_id is always available but not taken // care of here. Maybe we should store it in the // CallerInfo object as well. Loading @@ -221,7 +226,7 @@ public class CallerInfo { // Look for the name columnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME); if (columnIndex != -1) { info.name = cursor.getString(columnIndex); info.name = normalize(cursor.getString(columnIndex)); } // Look for the number Loading Loading @@ -261,8 +266,7 @@ public class CallerInfo { contactId = cursor.getLong(columnIndex); // QuickContacts in M doesn't support enterprise contact id if (contactId != 0 && (VERSION.SDK_INT >= VERSION_CODES.N || !Contacts.isEnterpriseContactId(contactId))) { && (VERSION.SDK_INT >= VERSION_CODES.N || !Contacts.isEnterpriseContactId(contactId))) { info.contactIdOrZero = contactId; Log.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero); } Loading Loading @@ -320,13 +324,7 @@ public class CallerInfo { info.nameAlternative = ContactInfoHelper.lookUpDisplayNameAlternative( context, info.lookupKeyOrNull, info.userType, directoryId); } cursor.close(); } info.needUpdate = false; info.name = normalize(info.name); info.contactRefUri = contactRef; return info; } Loading
java/com/android/incallui/ExternalCallNotifier.java +1 −1 Original line number Diff line number Diff line Loading @@ -44,11 +44,11 @@ import com.android.dialer.common.Assert; import com.android.dialer.contactphoto.BitmapUtil; import com.android.dialer.notification.DialerNotificationManager; import com.android.dialer.notification.NotificationChannelId; import com.android.dialer.telecom.TelecomCallUtil; import com.android.incallui.call.DialerCall; import com.android.incallui.call.DialerCallDelegate; import com.android.incallui.call.ExternalCallList; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.util.TelecomCallUtil; import java.util.Map; /** Loading
java/com/android/incallui/InCallPresenter.java +2 −2 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.postcall.PostCall; import com.android.dialer.telecom.TelecomCallUtil; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.TouchPointManager; import com.android.incallui.InCallOrientationEventListener.ScreenOrientation; Loading @@ -66,7 +67,6 @@ import com.android.incallui.incalluilock.InCallUiLock; import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.legacyblocking.BlockedNumberContentObserver; import com.android.incallui.spam.SpamCallListListener; import com.android.incallui.util.TelecomCallUtil; import com.android.incallui.videosurface.bindings.VideoSurfaceBindings; import com.android.incallui.videosurface.protocol.VideoSurfaceTexture; import com.android.incallui.videotech.utils.VideoUtils; Loading