summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2013-05-30 15:41:13 -0700
committerJay Shrauner <shrauner@google.com>2013-06-13 10:56:06 -0700
commit719a7adde25e0a717816b00668c16c3a1e3c5518 (patch)
tree14037f2530a9c987950cc64485408578197d7a93 /src
parent72635ed4edfd76baf78a81afa047b612a2f4d58f (diff)
Use new CallLog number presentation column
Switch to using new number presentation column in the CallLog table and discontinue using special phone number strings in CallerInfo. Needed for unbundling. Bug:6948882 Change-Id: Ibf27ea55cee783c4530101e4e228198e245e6684
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/CallDetailActivity.java30
-rw-r--r--src/com/android/dialer/PhoneCallDetails.java19
-rw-r--r--src/com/android/dialer/PhoneCallDetailsHelper.java5
-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
10 files changed, 78 insertions, 52 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index d716de0f3..b23392378 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -208,6 +208,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
CallLog.Calls.TYPE,
CallLog.Calls.COUNTRY_ISO,
CallLog.Calls.GEOCODED_LOCATION,
+ CallLog.Calls.NUMBER_PRESENTATION,
};
static final int DATE_COLUMN_INDEX = 0;
@@ -216,6 +217,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
static final int CALL_TYPE_COLUMN_INDEX = 3;
static final int COUNTRY_ISO_COLUMN_INDEX = 4;
static final int GEOCODED_LOCATION_COLUMN_INDEX = 5;
+ static final int NUMBER_PRESENTATION_COLUMN_INDEX = 6;
private final View.OnClickListener mPrimaryActionListener = new View.OnClickListener() {
@Override
@@ -421,6 +423,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
// first.
PhoneCallDetails firstDetails = details[0];
mNumber = firstDetails.number.toString();
+ final int numberPresentation = firstDetails.numberPresentation;
final Uri contactUri = firstDetails.contactUri;
final Uri photoUri = firstDetails.photoUri;
@@ -428,7 +431,8 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
mPhoneCallDetailsHelper.setCallDetailsHeader(mHeaderTextView, firstDetails);
// Cache the details about the phone number.
- final boolean canPlaceCallsTo = mPhoneNumberHelper.canPlaceCallsTo(mNumber);
+ final boolean canPlaceCallsTo =
+ PhoneNumberHelper.canPlaceCallsTo(mNumber, numberPresentation);
final boolean isVoicemailNumber = mPhoneNumberHelper.isVoicemailNumber(mNumber);
final boolean isSipNumber = mPhoneNumberHelper.isSipNumber(mNumber);
@@ -509,7 +513,9 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
if (canPlaceCallsTo) {
final CharSequence displayNumber =
mPhoneNumberHelper.getDisplayNumber(
- firstDetails.number, firstDetails.formattedNumber);
+ firstDetails.number,
+ firstDetails.numberPresentation,
+ firstDetails.formattedNumber);
ViewEntry entry = new ViewEntry(
getString(R.string.menu_callNumber,
@@ -527,7 +533,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
// The secondary action allows to send an SMS to the number that placed the
// call.
- if (mPhoneNumberHelper.canSendSmsTo(mNumber)) {
+ if (mPhoneNumberHelper.canSendSmsTo(mNumber, numberPresentation)) {
entry.setSecondaryAction(
R.drawable.ic_text_holo_dark,
new Intent(Intent.ACTION_SENDTO,
@@ -598,10 +604,12 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
}
// Read call log specifics.
- String number = callCursor.getString(NUMBER_COLUMN_INDEX);
- long date = callCursor.getLong(DATE_COLUMN_INDEX);
- long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
- int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
+ final String number = callCursor.getString(NUMBER_COLUMN_INDEX);
+ final int numberPresentation = callCursor.getInt(
+ NUMBER_PRESENTATION_COLUMN_INDEX);
+ final long date = callCursor.getLong(DATE_COLUMN_INDEX);
+ final long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
+ final int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX);
final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX);
@@ -619,12 +627,13 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
final Uri lookupUri;
// If this is not a regular number, there is no point in looking it up in the contacts.
ContactInfo info =
- mPhoneNumberHelper.canPlaceCallsTo(number)
+ PhoneNumberHelper.canPlaceCallsTo(number, numberPresentation)
&& !mPhoneNumberHelper.isVoicemailNumber(number)
? mContactInfoHelper.lookupNumber(number, countryIso)
: null;
if (info == null) {
- formattedNumber = mPhoneNumberHelper.getDisplayNumber(number, null);
+ formattedNumber = mPhoneNumberHelper.getDisplayNumber(number,
+ numberPresentation, null);
nameText = "";
numberType = 0;
numberLabel = "";
@@ -638,7 +647,8 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
photoUri = info.photoUri;
lookupUri = info.lookupUri;
}
- return new PhoneCallDetails(number, formattedNumber, countryIso, geocode,
+ return new PhoneCallDetails(number, numberPresentation,
+ formattedNumber, countryIso, geocode,
new int[]{ callType }, date, duration,
nameText, numberType, numberLabel, lookupUri, photoUri);
} finally {
diff --git a/src/com/android/dialer/PhoneCallDetails.java b/src/com/android/dialer/PhoneCallDetails.java
index 45c29e461..c380b6554 100644
--- a/src/com/android/dialer/PhoneCallDetails.java
+++ b/src/com/android/dialer/PhoneCallDetails.java
@@ -26,6 +26,8 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
public class PhoneCallDetails {
/** The number of the other party involved in the call. */
public final CharSequence number;
+ /** The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} */
+ public final int numberPresentation;
/** The formatted version of {@link #number}. */
public final CharSequence formattedNumber;
/** The country corresponding with the phone number. */
@@ -59,18 +61,21 @@ public class PhoneCallDetails {
public final Uri photoUri;
/** Create the details for a call with a number not associated with a contact. */
- public PhoneCallDetails(CharSequence number, CharSequence formattedNumber,
- String countryIso, String geocode, int[] callTypes, long date, long duration) {
- this(number, formattedNumber, countryIso, geocode, callTypes, date, duration, "", 0, "",
- null, null);
+ public PhoneCallDetails(CharSequence number, int numberPresentation,
+ CharSequence formattedNumber, String countryIso, String geocode,
+ int[] callTypes, long date, long duration) {
+ this(number, numberPresentation, formattedNumber, countryIso, geocode,
+ callTypes, date, duration, "", 0, "", null, null);
}
/** Create the details for a call with a number associated with a contact. */
- public PhoneCallDetails(CharSequence number, CharSequence formattedNumber,
- String countryIso, String geocode, int[] callTypes, long date, long duration,
- CharSequence name, int numberType, CharSequence numberLabel, Uri contactUri,
+ public PhoneCallDetails(CharSequence number, int numberPresentation,
+ CharSequence formattedNumber, String countryIso, String geocode,
+ int[] callTypes, long date, long duration, CharSequence name,
+ int numberType, CharSequence numberLabel, Uri contactUri,
Uri photoUri) {
this.number = number;
+ this.numberPresentation = numberPresentation;
this.formattedNumber = formattedNumber;
this.countryIso = countryIso;
this.geocode = geocode;
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index 51b110910..37394c30f 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -105,7 +105,8 @@ public class PhoneCallDetailsHelper {
final CharSequence numberText;
final CharSequence labelText;
final CharSequence displayNumber =
- mPhoneNumberHelper.getDisplayNumber(details.number, details.formattedNumber);
+ mPhoneNumberHelper.getDisplayNumber(details.number,
+ details.numberPresentation, details.formattedNumber);
if (TextUtils.isEmpty(details.name)) {
nameText = displayNumber;
if (TextUtils.isEmpty(details.geocode)
@@ -135,7 +136,7 @@ public class PhoneCallDetailsHelper {
public void setCallDetailsHeader(TextView nameView, PhoneCallDetails details) {
final CharSequence nameText;
final CharSequence displayNumber =
- mPhoneNumberHelper.getDisplayNumber(details.number,
+ mPhoneNumberHelper.getDisplayNumber(details.number, details.numberPresentation,
mResources.getString(R.string.recentCalls_addToContact));
if (TextUtils.isEmpty(details.name)) {
nameText = displayNumber;
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);
}