diff options
author | Chiao Cheng <chiaocheng@google.com> | 2013-09-13 17:14:38 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-13 17:14:38 -0700 |
commit | a6a4c14352e8a20eae223ef3943adcd3b65cf787 (patch) | |
tree | 01206785ab27f50dcbc7df39a752438b14abcdfa | |
parent | 4700e128111604cc6483f9471c32aacf8e7264f5 (diff) | |
parent | b424b61ce72dcf553a3f3f0c850fe8eba163c524 (diff) |
am b424b61c: Merge "Changes to detect whether a call is voicemail." into klp-dev
* commit 'b424b61ce72dcf553a3f3f0c850fe8eba163c524':
Changes to detect whether a call is voicemail.
5 files changed, 36 insertions, 7 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index e26d2f020..24b59fb3e 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -436,7 +436,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware // Cache the details about the phone number. final boolean canPlaceCallsTo = PhoneNumberHelper.canPlaceCallsTo(mNumber, numberPresentation); - final boolean isVoicemailNumber = mPhoneNumberHelper.isVoicemailNumber(mNumber); + final boolean isVoicemailNumber = PhoneNumberHelper.isVoicemailNumber(mNumber); final boolean isSipNumber = mPhoneNumberHelper.isSipNumber(mNumber); // Let user view contact details if they exist, otherwise add option to create new @@ -631,7 +631,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware // If this is not a regular number, there is no point in looking it up in the contacts. ContactInfo info = PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation) - && !mPhoneNumberHelper.isVoicemailNumber(number) + && !PhoneNumberHelper.isVoicemailNumber(number) ? mContactInfoHelper.lookupNumber(number, countryIso) : null; if (info == null) { diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java index be9cb660f..d882eb686 100644 --- a/src/com/android/dialer/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/PhoneCallDetailsHelper.java @@ -117,7 +117,7 @@ public class PhoneCallDetailsHelper { if (TextUtils.isEmpty(details.name)) { nameText = displayNumber; if (TextUtils.isEmpty(details.geocode) - || mPhoneNumberHelper.isVoicemailNumber(details.number)) { + || PhoneNumberHelper.isVoicemailNumber(details.number)) { numberText = mResources.getString(R.string.call_log_empty_gecode); } else { numberText = details.geocode; diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index c0054ba79..136899eaf 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -542,7 +542,7 @@ public class CallLogAdapter extends GroupingListAdapter mContactInfoCache.getCachedValue(numberCountryIso); ContactInfo info = cachedInfo == null ? null : cachedInfo.getValue(); if (!PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation) - || mPhoneNumberHelper.isVoicemailNumber(number)) { + || PhoneNumberHelper.isVoicemailNumber(number)) { // If this is a number that cannot be dialed, there is no point in looking up a contact // for it. info = ContactInfo.EMPTY; @@ -615,10 +615,11 @@ public class CallLogAdapter extends GroupingListAdapter mViewTreeObserver.addOnPreDrawListener(this); } - postBindView(views, info); + postBindView(views, info, details); } - protected void postBindView(CallLogListItemViews views, ContactInfo info) { + protected void postBindView(CallLogListItemViews views, ContactInfo info, + PhoneCallDetails details) { // no-op } diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java index ac858df87..2006744d3 100644 --- a/src/com/android/dialer/calllog/ContactInfo.java +++ b/src/com/android/dialer/calllog/ContactInfo.java @@ -20,6 +20,7 @@ import android.net.Uri; import android.text.TextUtils; import com.android.contacts.common.util.UriUtils; +import com.google.common.base.Objects; /** * Information for a contact as needed by the Call Log. @@ -70,4 +71,12 @@ public class ContactInfo { if (!UriUtils.areEqual(photoUri, other.photoUri)) return false; return true; } + + @Override + public String toString() { + return Objects.toStringHelper(this).add("lookupUri", lookupUri).add("name", name).add( + "type", type).add("label", label).add("number", number).add("formattedNumber", + formattedNumber).add("normalizedNumber", normalizedNumber).add("photoId", photoId) + .add("photoUri", photoUri).toString(); + } } diff --git a/src/com/android/dialer/calllog/PhoneNumberHelper.java b/src/com/android/dialer/calllog/PhoneNumberHelper.java index 7d46f40c9..b89c727a7 100644 --- a/src/com/android/dialer/calllog/PhoneNumberHelper.java +++ b/src/com/android/dialer/calllog/PhoneNumberHelper.java @@ -75,11 +75,30 @@ public class PhoneNumberHelper { } } + public static boolean isUnknownNumberThatCanBeLookedUp(CharSequence number, int presentation) { + if (presentation == Calls.PRESENTATION_UNKNOWN) { + return false; + } + if (presentation == Calls.PRESENTATION_RESTRICTED) { + return false; + } + if (presentation == Calls.PRESENTATION_PAYPHONE) { + return false; + } + if (TextUtils.isEmpty(number)) { + return false; + } + if (isVoicemailNumber(number)) { + return false; + } + return true; + } + /** * Returns true if the given number is the number of the configured voicemail. * To be able to mock-out this, it is not a static method. */ - public boolean isVoicemailNumber(CharSequence number) { + public static boolean isVoicemailNumber(CharSequence number) { return PhoneNumberUtils.isVoiceMailNumber(number.toString()); } |