summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/calllog
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/dialer/calllog')
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java13
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java7
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemHelper.java5
-rw-r--r--src/com/android/dialer/calllog/CallLogQuery.java4
-rw-r--r--src/com/android/dialer/calllog/CallLogQueryHandler.java2
-rw-r--r--src/com/android/dialer/calllog/DefaultVoicemailNotifier.java15
-rw-r--r--src/com/android/dialer/calllog/PhoneNumberHelper.java30
7 files changed, 43 insertions, 33 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index b0af99a38..c78aa5352 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -521,6 +521,7 @@ import java.util.LinkedList;
views.listHeaderTextView.setVisibility(View.GONE);
final String number = c.getString(CallLogQuery.NUMBER);
+ final int numberPresentation = c.getInt(CallLogQuery.NUMBER_PRESENTATION);
final long date = c.getLong(CallLogQuery.DATE);
final long duration = c.getLong(CallLogQuery.DURATION);
final int callType = c.getInt(CallLogQuery.CALL_TYPE);
@@ -551,7 +552,7 @@ import java.util.LinkedList;
ExpirableCache.CachedValue<ContactInfo> cachedInfo =
mContactInfoCache.getCachedValue(numberCountryIso);
ContactInfo info = cachedInfo == null ? null : cachedInfo.getValue();
- if (!mPhoneNumberHelper.canPlaceCallsTo(number)
+ if (!PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation)
|| mPhoneNumberHelper.isVoicemailNumber(number)) {
// If this is a number that cannot be dialed, there is no point in looking up a contact
// for it.
@@ -593,12 +594,14 @@ import java.util.LinkedList;
final String geocode = c.getString(CallLogQuery.GEOCODED_LOCATION);
final PhoneCallDetails details;
if (TextUtils.isEmpty(name)) {
- details = new PhoneCallDetails(number, formattedNumber, countryIso, geocode,
- callTypes, date, duration);
+ details = new PhoneCallDetails(number, numberPresentation,
+ formattedNumber, countryIso, geocode, callTypes, date,
+ duration);
} else {
// We do not pass a photo id since we do not need the high-res picture.
- details = new PhoneCallDetails(number, formattedNumber, countryIso, geocode,
- callTypes, date, duration, name, ntype, label, lookupUri, null);
+ details = new PhoneCallDetails(number, numberPresentation,
+ formattedNumber, countryIso, geocode, callTypes, date,
+ duration, name, ntype, label, lookupUri, null);
}
final boolean isNew = c.getInt(CallLogQuery.IS_READ) == 0;
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index 86a383aa9..bc0856f75 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -53,7 +53,6 @@ import com.android.dialer.util.EmptyLoader;
import com.android.dialer.voicemail.VoicemailStatusHelper;
import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage;
import com.android.dialer.voicemail.VoicemailStatusHelperImpl;
-import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.ITelephony;
import com.google.common.annotations.VisibleForTesting;
@@ -460,10 +459,8 @@ public class CallLogFragment extends ListFragment
final Cursor cursor = (Cursor)mAdapter.getItem(position);
if (cursor != null) {
String number = cursor.getString(CallLogQuery.NUMBER);
- if (TextUtils.isEmpty(number)
- || number.equals(CallerInfo.UNKNOWN_NUMBER)
- || number.equals(CallerInfo.PRIVATE_NUMBER)
- || number.equals(CallerInfo.PAYPHONE_NUMBER)) {
+ int numberPresentation = cursor.getInt(CallLogQuery.NUMBER_PRESENTATION);
+ if (!PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation)) {
// This number can't be called, do nothing
return;
}
diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java
index 20b30b1ee..bccd4f45b 100644
--- a/src/com/android/dialer/calllog/CallLogListItemHelper.java
+++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java
@@ -60,7 +60,8 @@ import com.android.dialer.R;
boolean isHighlighted) {
mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details,
isHighlighted);
- boolean canCall = mPhoneNumberHelper.canPlaceCallsTo(details.number);
+ boolean canCall = PhoneNumberHelper.canPlaceCallsTo(details.number,
+ details.numberPresentation);
boolean canPlay = details.callTypes[0] == Calls.VOICEMAIL_TYPE;
if (canPlay) {
@@ -93,7 +94,7 @@ import com.android.dialer.R;
recipient = details.name;
} else {
recipient = mPhoneNumberHelper.getDisplayNumber(
- details.number, details.formattedNumber);
+ details.number, details.numberPresentation, details.formattedNumber);
}
return mResources.getString(R.string.description_call, recipient);
}
diff --git a/src/com/android/dialer/calllog/CallLogQuery.java b/src/com/android/dialer/calllog/CallLogQuery.java
index 5f7b27b93..01949e09f 100644
--- a/src/com/android/dialer/calllog/CallLogQuery.java
+++ b/src/com/android/dialer/calllog/CallLogQuery.java
@@ -43,6 +43,7 @@ public final class CallLogQuery {
Calls.CACHED_PHOTO_ID, // 14
Calls.CACHED_FORMATTED_NUMBER, // 15
Calls.IS_READ, // 16
+ Calls.NUMBER_PRESENTATION, // 17
};
public static final int ID = 0;
@@ -62,8 +63,9 @@ public final class CallLogQuery {
public static final int CACHED_PHOTO_ID = 14;
public static final int CACHED_FORMATTED_NUMBER = 15;
public static final int IS_READ = 16;
+ public static final int NUMBER_PRESENTATION = 17;
/** The index of the synthetic "section" column in the extended projection. */
- public static final int SECTION = 17;
+ public static final int SECTION = 18;
/**
* The name of the synthetic "section" column.
diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java
index 43b8d21ca..750b41697 100644
--- a/src/com/android/dialer/calllog/CallLogQueryHandler.java
+++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java
@@ -145,7 +145,7 @@ import javax.annotation.concurrent.GuardedBy;
// plus the section value.
matrixCursor.addRow(new Object[]{
0L, "", 0L, 0L, 0, "", "", "", null, 0, null, null, null, null, 0L, null, 0,
- section
+ Calls.PRESENTATION_ALLOWED, section
});
return matrixCursor;
}
diff --git a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
index e551e6044..8bac657a2 100644
--- a/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
+++ b/src/com/android/dialer/calllog/DefaultVoicemailNotifier.java
@@ -122,7 +122,8 @@ public class DefaultVoicemailNotifier implements VoicemailNotifier {
name = mNameLookupQuery.query(newCall.number);
// If we cannot lookup the contact, use the number instead.
if (name == null) {
- name = mPhoneNumberHelper.getDisplayNumber(newCall.number, "").toString();
+ name = mPhoneNumberHelper.getDisplayNumber(newCall.number,
+ newCall.numberPresentation, "").toString();
if (TextUtils.isEmpty(name)) {
name = newCall.number;
}
@@ -210,11 +211,14 @@ public class DefaultVoicemailNotifier implements VoicemailNotifier {
public final Uri callsUri;
public final Uri voicemailUri;
public final String number;
+ public final int numberPresentation;
- public NewCall(Uri callsUri, Uri voicemailUri, String number) {
+ public NewCall(Uri callsUri, Uri voicemailUri, String number,
+ int numberPresentation) {
this.callsUri = callsUri;
this.voicemailUri = voicemailUri;
this.number = number;
+ this.numberPresentation = numberPresentation;
}
}
@@ -237,11 +241,13 @@ public class DefaultVoicemailNotifier implements VoicemailNotifier {
*/
private static final class DefaultNewCallsQuery implements NewCallsQuery {
private static final String[] PROJECTION = {
- Calls._ID, Calls.NUMBER, Calls.VOICEMAIL_URI
+ Calls._ID, Calls.NUMBER, Calls.NUMBER_PRESENTATION,
+ Calls.VOICEMAIL_URI
};
private static final int ID_COLUMN_INDEX = 0;
private static final int NUMBER_COLUMN_INDEX = 1;
private static final int VOICEMAIL_URI_COLUMN_INDEX = 2;
+ private static final int NUMBER_PRESENTATION_COLUMN_INDEX = 3;
private final ContentResolver mContentResolver;
@@ -276,7 +282,8 @@ public class DefaultVoicemailNotifier implements VoicemailNotifier {
Uri callsUri = ContentUris.withAppendedId(
Calls.CONTENT_URI_WITH_VOICEMAIL, cursor.getLong(ID_COLUMN_INDEX));
Uri voicemailUri = voicemailUriString == null ? null : Uri.parse(voicemailUriString);
- return new NewCall(callsUri, voicemailUri, cursor.getString(NUMBER_COLUMN_INDEX));
+ return new NewCall(callsUri, voicemailUri, cursor.getString(NUMBER_COLUMN_INDEX),
+ cursor.getInt(NUMBER_PRESENTATION_COLUMN_INDEX));
}
}
diff --git a/src/com/android/dialer/calllog/PhoneNumberHelper.java b/src/com/android/dialer/calllog/PhoneNumberHelper.java
index f0b3701e3..7d46f40c9 100644
--- a/src/com/android/dialer/calllog/PhoneNumberHelper.java
+++ b/src/com/android/dialer/calllog/PhoneNumberHelper.java
@@ -17,11 +17,11 @@
package com.android.dialer.calllog;
import android.content.res.Resources;
+import android.provider.CallLog.Calls;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import com.android.dialer.R;
-import com.android.internal.telephony.CallerInfo;
/**
* Helper for formatting and managing phone numbers.
@@ -34,16 +34,15 @@ public class PhoneNumberHelper {
}
/** Returns true if it is possible to place a call to the given number. */
- public boolean canPlaceCallsTo(CharSequence number) {
- return !(TextUtils.isEmpty(number)
- || number.equals(CallerInfo.UNKNOWN_NUMBER)
- || number.equals(CallerInfo.PRIVATE_NUMBER)
- || number.equals(CallerInfo.PAYPHONE_NUMBER));
+ public static boolean canPlaceCallsTo(CharSequence number, int presentation) {
+ return presentation == Calls.PRESENTATION_ALLOWED
+ && !TextUtils.isEmpty(number);
}
/** Returns true if it is possible to send an SMS to the given number. */
- public boolean canSendSmsTo(CharSequence number) {
- return canPlaceCallsTo(number) && !isVoicemailNumber(number) && !isSipNumber(number);
+ public boolean canSendSmsTo(CharSequence number, int presentation) {
+ return canPlaceCallsTo(number, presentation)
+ && !isVoicemailNumber(number) && !isSipNumber(number);
}
/**
@@ -52,19 +51,20 @@ public class PhoneNumberHelper {
* @param number the number to display
* @param formattedNumber the formatted number if available, may be null
*/
- public CharSequence getDisplayNumber(CharSequence number, CharSequence formattedNumber) {
- if (TextUtils.isEmpty(number)) {
- return "";
- }
- if (number.equals(CallerInfo.UNKNOWN_NUMBER)) {
+ public CharSequence getDisplayNumber(CharSequence number,
+ int presentation, CharSequence formattedNumber) {
+ if (presentation == Calls.PRESENTATION_UNKNOWN) {
return mResources.getString(R.string.unknown);
}
- if (number.equals(CallerInfo.PRIVATE_NUMBER)) {
+ if (presentation == Calls.PRESENTATION_RESTRICTED) {
return mResources.getString(R.string.private_num);
}
- if (number.equals(CallerInfo.PAYPHONE_NUMBER)) {
+ if (presentation == Calls.PRESENTATION_PAYPHONE) {
return mResources.getString(R.string.payphone);
}
+ if (TextUtils.isEmpty(number)) {
+ return "";
+ }
if (isVoicemailNumber(number)) {
return mResources.getString(R.string.voicemail);
}