summaryrefslogtreecommitdiff
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
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
-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
-rw-r--r--tests/src/com/android/dialer/CallDetailActivityTest.java1
-rw-r--r--tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java60
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogFragmentTest.java74
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java40
-rw-r--r--tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java4
-rw-r--r--tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java1
16 files changed, 180 insertions, 130 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);
}
diff --git a/tests/src/com/android/dialer/CallDetailActivityTest.java b/tests/src/com/android/dialer/CallDetailActivityTest.java
index eebb681d9..1ad17c4f4 100644
--- a/tests/src/com/android/dialer/CallDetailActivityTest.java
+++ b/tests/src/com/android/dialer/CallDetailActivityTest.java
@@ -230,6 +230,7 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal
ContentResolver contentResolver = getContentResolver();
ContentValues values = new ContentValues();
values.put(CallLog.Calls.NUMBER, CONTACT_NUMBER);
+ values.put(CallLog.Calls.NUMBER_PRESENTATION, CallLog.Calls.PRESENTATION_ALLOWED);
values.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE);
mCallLogUri = contentResolver.insert(CallLog.Calls.CONTENT_URI, values);
setActivityIntent(new Intent(Intent.ACTION_VIEW, mCallLogUri));
diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
index 80bbf34db..9170a0b18 100644
--- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java
@@ -29,7 +29,6 @@ import com.android.dialer.calllog.CallTypeHelper;
import com.android.dialer.calllog.PhoneNumberHelper;
import com.android.dialer.calllog.TestPhoneNumberHelper;
import com.android.dialer.util.LocaleTestUtils;
-import com.android.internal.telephony.CallerInfo;
import java.util.GregorianCalendar;
import java.util.Locale;
@@ -89,27 +88,29 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
}
public void testSetPhoneCallDetails_Unknown() {
- setPhoneCallDetailsWithNumber(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER);
+ setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_UNKNOWN, "");
assertNameEqualsResource(R.string.unknown);
}
public void testSetPhoneCallDetails_Private() {
- setPhoneCallDetailsWithNumber(CallerInfo.PRIVATE_NUMBER, CallerInfo.PRIVATE_NUMBER);
+ setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_RESTRICTED, "");
assertNameEqualsResource(R.string.private_num);
}
public void testSetPhoneCallDetails_Payphone() {
- setPhoneCallDetailsWithNumber(CallerInfo.PAYPHONE_NUMBER, CallerInfo.PAYPHONE_NUMBER);
+ setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_PAYPHONE, "");
assertNameEqualsResource(R.string.payphone);
}
public void testSetPhoneCallDetails_Voicemail() {
- setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, TEST_VOICEMAIL_NUMBER);
+ setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER,
+ Calls.PRESENTATION_ALLOWED, TEST_VOICEMAIL_NUMBER);
assertNameEqualsResource(R.string.voicemail);
}
public void testSetPhoneCallDetails_Normal() {
- setPhoneCallDetailsWithNumber("14125551212", "1-412-555-1212");
+ setPhoneCallDetailsWithNumber("14125551212",
+ Calls.PRESENTATION_ALLOWED, "1-412-555-1212");
assertEquals("Yesterday", mViews.callTypeAndDate.getText().toString());
assertEqualsHtml("<font color='#33b5e5'><b>Yesterday</b></font>",
mViews.callTypeAndDate.getText());
@@ -199,35 +200,36 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
}
public void testSetPhoneCallDetails_Highlighted() {
- setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, "");
+ setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER,
+ Calls.PRESENTATION_ALLOWED, "");
}
public void testSetCallDetailsHeader_NumberOnly() {
- setCallDetailsHeaderWithNumberOnly(TEST_NUMBER);
+ setCallDetailsHeaderWithNumber(TEST_NUMBER, Calls.PRESENTATION_ALLOWED);
assertEquals(View.VISIBLE, mNameView.getVisibility());
assertEquals("Add to contacts", mNameView.getText().toString());
}
public void testSetCallDetailsHeader_UnknownNumber() {
- setCallDetailsHeaderWithNumberOnly(CallerInfo.UNKNOWN_NUMBER);
+ setCallDetailsHeaderWithNumber("", Calls.PRESENTATION_UNKNOWN);
assertEquals(View.VISIBLE, mNameView.getVisibility());
assertEquals("Unknown", mNameView.getText().toString());
}
public void testSetCallDetailsHeader_PrivateNumber() {
- setCallDetailsHeaderWithNumberOnly(CallerInfo.PRIVATE_NUMBER);
+ setCallDetailsHeaderWithNumber("", Calls.PRESENTATION_RESTRICTED);
assertEquals(View.VISIBLE, mNameView.getVisibility());
assertEquals("Private number", mNameView.getText().toString());
}
public void testSetCallDetailsHeader_PayphoneNumber() {
- setCallDetailsHeaderWithNumberOnly(CallerInfo.PAYPHONE_NUMBER);
+ setCallDetailsHeaderWithNumber("", Calls.PRESENTATION_PAYPHONE);
assertEquals(View.VISIBLE, mNameView.getVisibility());
assertEquals("Pay phone", mNameView.getText().toString());
}
public void testSetCallDetailsHeader_VoicemailNumber() {
- setCallDetailsHeaderWithNumberOnly(TEST_VOICEMAIL_NUMBER);
+ setCallDetailsHeaderWithNumber(TEST_VOICEMAIL_NUMBER, Calls.PRESENTATION_ALLOWED);
assertEquals(View.VISIBLE, mNameView.getVisibility());
assertEquals("Voicemail", mNameView.getText().toString());
}
@@ -284,15 +286,21 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
}
/** Sets the phone call details with default values and the given number. */
- private void setPhoneCallDetailsWithNumber(String number, String formattedNumber) {
- setPhoneCallDetailsWithNumberAndGeocode(number, formattedNumber, TEST_GEOCODE);
+ private void setPhoneCallDetailsWithNumber(String number, int presentation,
+ String formattedNumber) {
+ mHelper.setPhoneCallDetails(mViews,
+ new PhoneCallDetails(number, presentation, formattedNumber,
+ TEST_COUNTRY_ISO, TEST_GEOCODE,
+ new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION),
+ true);
}
/** Sets the phone call details with default values and the given number. */
private void setPhoneCallDetailsWithNumberAndGeocode(String number, String formattedNumber,
String geocodedLocation) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(number, formattedNumber, TEST_COUNTRY_ISO, geocodedLocation,
+ new PhoneCallDetails(number, Calls.PRESENTATION_ALLOWED,
+ formattedNumber, TEST_COUNTRY_ISO, geocodedLocation,
new int[]{ Calls.VOICEMAIL_TYPE }, TEST_DATE, TEST_DURATION),
true);
}
@@ -300,29 +308,33 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase {
/** Sets the phone call details with default values and the given date. */
private void setPhoneCallDetailsWithDate(long date) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
- TEST_GEOCODE, new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION),
+ new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
+ new int[]{ Calls.INCOMING_TYPE }, date, TEST_DURATION),
false);
}
/** Sets the phone call details with default values and the given call types using icons. */
private void setPhoneCallDetailsWithCallTypeIcons(int... callTypes) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
- TEST_GEOCODE, callTypes, TEST_DATE, TEST_DURATION),
+ new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
+ callTypes, TEST_DATE, TEST_DURATION),
false);
}
- private void setCallDetailsHeaderWithNumberOnly(String number) {
+ private void setCallDetailsHeaderWithNumber(String number, int presentation) {
mHelper.setCallDetailsHeader(mNameView,
- new PhoneCallDetails(number, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
- TEST_GEOCODE, new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION));
+ new PhoneCallDetails(number, presentation,
+ TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
+ new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION));
}
private void setCallDetailsHeader(String name) {
mHelper.setCallDetailsHeader(mNameView,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
- TEST_GEOCODE, new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION,
+ new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
+ new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION,
name, 0, "", null, null));
}
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
index 67132fd45..c94f8d9ac 100644
--- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java
@@ -40,7 +40,6 @@ import android.widget.FrameLayout;
import com.android.contacts.common.test.FragmentTestActivity;
import com.android.dialer.CallDetailActivity;
import com.android.dialer.R;
-import com.android.internal.telephony.CallerInfo;
import java.util.Date;
import java.util.Formatter;
@@ -165,9 +164,9 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testCallAndGroupViews_GroupView() {
mCursor.moveToFirst();
- insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
- insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
- insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
+ insertPrivate(NOW, 0);
+ insertPrivate(NOW, 0);
+ insertPrivate(NOW, 0);
View view = mAdapter.newGroupView(getActivity(), mParentView);
mAdapter.bindGroupView(view, getActivity(), mCursor, 3, false);
assertNotNull(view.findViewById(R.id.secondary_action_icon));
@@ -176,7 +175,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testCallAndGroupViews_StandAloneView() {
mCursor.moveToFirst();
- insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
+ insertPrivate(NOW, 0);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
assertNotNull(view.findViewById(R.id.secondary_action_icon));
@@ -185,7 +184,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testCallAndGroupViews_ChildView() {
mCursor.moveToFirst();
- insert(CallerInfo.PRIVATE_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
+ insertPrivate(NOW, 0);
View view = mAdapter.newChildView(getActivity(), mParentView);
mAdapter.bindChildView(view, getActivity(), mCursor);
assertNotNull(view.findViewById(R.id.secondary_action_icon));
@@ -194,7 +193,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testBindView_NumberOnlyNoCache() {
mCursor.moveToFirst();
- insert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
+ insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
@@ -205,7 +204,8 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testBindView_NumberOnlyDbCachedFormattedNumber() {
mCursor.moveToFirst();
- Object[] values = getValuesToInsert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
+ Object[] values = getValuesToInsert(TEST_NUMBER,
+ Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
values[CallLogQuery.CACHED_FORMATTED_NUMBER] = TEST_FORMATTED_NUMBER;
insertValues(values);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
@@ -296,7 +296,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testBindView_WithoutQuickContactBadge() {
mCursor.moveToFirst();
- insert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
+ insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
@@ -307,7 +307,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testBindView_CallButton() {
mCursor.moveToFirst();
- insert(TEST_NUMBER, NOW, 0, Calls.INCOMING_TYPE);
+ insert(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0, Calls.INCOMING_TYPE);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
@@ -323,7 +323,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
@MediumTest
public void testBindView_PlayButton() {
mCursor.moveToFirst();
- insertVoicemail(TEST_NUMBER, NOW, 0);
+ insertVoicemail(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, NOW, 0);
View view = mAdapter.newStandAloneView(getActivity(), mParentView);
mAdapter.bindStandAloneView(view, getActivity(), mCursor);
@@ -363,9 +363,9 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
break;
}
mItem = (CallLogListItemViews) mList[i].getTag();
- String number = getPhoneNumberForListEntry(i);
- if (CallerInfo.PRIVATE_NUMBER.equals(number) ||
- CallerInfo.UNKNOWN_NUMBER.equals(number)) {
+ int presentation = getPhoneNumberPresentationForListEntry(i);
+ if (presentation == Calls.PRESENTATION_RESTRICTED ||
+ presentation == Calls.PRESENTATION_UNKNOWN) {
assertFalse(View.VISIBLE == mItem.secondaryActionView.getVisibility());
} else {
assertEquals(View.VISIBLE, mItem.secondaryActionView.getVisibility());
@@ -422,11 +422,11 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
}
}
- /** Returns the number associated with the given entry in {{@link #mList}. */
- private String getPhoneNumberForListEntry(int index) {
+ /** Returns the number presentation associated with the given entry in {{@link #mList}. */
+ private int getPhoneNumberPresentationForListEntry(int index) {
// The entries are added backward, so count from the end of the cursor.
mCursor.moveToPosition(mCursor.getCount() - index - 1);
- return mCursor.getString(CallLogQuery.NUMBER);
+ return mCursor.getInt(CallLogQuery.NUMBER_PRESENTATION);
}
//
@@ -458,8 +458,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
*
* It includes the values for the cached contact associated with the number.
*
- * @param number The phone number. For unknown and private numbers,
- * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER.
+ * @param number The phone number.
* @param date In millisec since epoch. Use NOW to use the current time.
* @param duration In seconds of the call. Use RAND_DURATION to pick a random one.
* @param type Either Call.OUTGOING_TYPE or Call.INCOMING_TYPE or Call.MISSED_TYPE.
@@ -469,7 +468,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
*/
private void insertWithCachedValues(String number, long date, int duration, int type,
String cachedName, int cachedNumberType, String cachedNumberLabel) {
- insert(number, date, duration, type);
+ insert(number, Calls.PRESENTATION_ALLOWED, date, duration, type);
ContactInfo contactInfo = new ContactInfo();
contactInfo.lookupUri = TEST_LOOKUP_URI;
contactInfo.name = cachedName;
@@ -487,14 +486,15 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
/**
* Insert a new call entry in the test DB.
- * @param number The phone number. For unknown and private numbers,
- * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER.
+ * @param number The phone number.
+ * @param presentation Number representing display rules for "allowed",
+ * "payphone", "restricted", or "unknown".
* @param date In millisec since epoch. Use NOW to use the current time.
* @param duration In seconds of the call. Use RAND_DURATION to pick a random one.
* @param type Either Call.OUTGOING_TYPE or Call.INCOMING_TYPE or Call.MISSED_TYPE.
*/
- private void insert(String number, long date, int duration, int type) {
- insertValues(getValuesToInsert(number, date, duration, type));
+ private void insert(String number, int presentation, long date, int duration, int type) {
+ insertValues(getValuesToInsert(number, presentation, date, duration, type));
}
/** Inserts the given values in the cursor. */
@@ -506,16 +506,19 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
/**
* Returns the values for a new call entry.
*
- * @param number The phone number. For unknown and private numbers,
- * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER.
+ * @param number The phone number.
+ * @param presentation Number representing display rules for "allowed",
+ * "payphone", "restricted", or "unknown".
* @param date In millisec since epoch. Use NOW to use the current time.
* @param duration In seconds of the call. Use RAND_DURATION to pick a random one.
* @param type Either Call.OUTGOING_TYPE or Call.INCOMING_TYPE or Call.MISSED_TYPE.
*/
- private Object[] getValuesToInsert(String number, long date, int duration, int type) {
+ private Object[] getValuesToInsert(String number, int presentation,
+ long date, int duration, int type) {
Object[] values = CallLogQueryTestUtils.createTestExtendedValues();
values[CallLogQuery.ID] = mIndex;
values[CallLogQuery.NUMBER] = number;
+ values[CallLogQuery.NUMBER_PRESENTATION] = presentation;
values[CallLogQuery.DATE] = date == NOW ? new Date().getTime() : date;
values[CallLogQuery.DURATION] = duration < 0 ? mRnd.nextInt(10 * 60) : duration;
if (mVoicemail != null && mVoicemail.equals(number)) {
@@ -529,13 +532,14 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
/**
* Insert a new voicemail entry in the test DB.
- * @param number The phone number. For unknown and private numbers,
- * use CallerInfo.UNKNOWN_NUMBER or CallerInfo.PRIVATE_NUMBER.
+ * @param number The phone number.
+ * @param presentation Number representing display rules for "allowed",
+ * "payphone", "restricted", or "unknown".
* @param date In millisec since epoch. Use NOW to use the current time.
* @param duration In seconds of the call. Use RAND_DURATION to pick a random one.
*/
- private void insertVoicemail(String number, long date, int duration) {
- Object[] values = getValuesToInsert(number, date, duration, Calls.VOICEMAIL_TYPE);
+ private void insertVoicemail(String number, int presentation, long date, int duration) {
+ Object[] values = getValuesToInsert(number, presentation, date, duration, Calls.VOICEMAIL_TYPE);
// Must have the same index as the row.
values[CallLogQuery.VOICEMAIL_URI] =
ContentUris.withAppendedId(VoicemailContract.Voicemails.CONTENT_URI, mIndex);
@@ -548,7 +552,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
* @param duration In seconds of the call. Use RAND_DURATION to pick a random one.
*/
private void insertPrivate(long date, int duration) {
- insert(CallerInfo.PRIVATE_NUMBER, date, duration, Calls.INCOMING_TYPE);
+ insert("", Calls.PRESENTATION_RESTRICTED, date, duration, Calls.INCOMING_TYPE);
}
/**
@@ -557,7 +561,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
* @param duration In seconds of the call. Use RAND_DURATION to pick a random one.
*/
private void insertUnknown(long date, int duration) {
- insert(CallerInfo.UNKNOWN_NUMBER, date, duration, Calls.INCOMING_TYPE);
+ insert("", Calls.PRESENTATION_UNKNOWN, date, duration, Calls.INCOMING_TYPE);
}
/**
@@ -568,7 +572,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
private void insertCalltoVoicemail(long date, int duration) {
// mVoicemail may be null
if (mVoicemail != null) {
- insert(mVoicemail, date, duration, Calls.OUTGOING_TYPE);
+ insert(mVoicemail, Calls.PRESENTATION_ALLOWED, date, duration, Calls.OUTGOING_TYPE);
}
}
@@ -605,7 +609,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme
} else {
int inout = mRnd.nextBoolean() ? Calls.OUTGOING_TYPE : Calls.INCOMING_TYPE;
String number = new Formatter().format("1800123%04d", i).toString();
- insert(number, NOW, RAND_DURATION, inout);
+ insert(number, Calls.PRESENTATION_ALLOWED, NOW, RAND_DURATION, inout);
}
}
return privateOrUnknownOrVm;
diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
index 3ad5abe0a..73c33ae6d 100644
--- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
+++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java
@@ -24,7 +24,6 @@ import android.view.View;
import com.android.dialer.PhoneCallDetails;
import com.android.dialer.PhoneCallDetailsHelper;
-import com.android.internal.telephony.CallerInfo;
/**
* Unit tests for {@link CallLogListItemHelper}.
@@ -73,27 +72,29 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
}
public void testSetPhoneCallDetails() {
- setPhoneCallDetailsWithNumber("12125551234", "1-212-555-1234");
+ setPhoneCallDetailsWithNumber("12125551234", Calls.PRESENTATION_ALLOWED,
+ "1-212-555-1234");
assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
}
public void testSetPhoneCallDetails_Unknown() {
- setPhoneCallDetailsWithNumber(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER);
+ setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_UNKNOWN, "");
assertNoCallButton();
}
public void testSetPhoneCallDetails_Private() {
- setPhoneCallDetailsWithNumber(CallerInfo.PRIVATE_NUMBER, CallerInfo.PRIVATE_NUMBER);
+ setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_RESTRICTED, "");
assertNoCallButton();
}
public void testSetPhoneCallDetails_Payphone() {
- setPhoneCallDetailsWithNumber(CallerInfo.PAYPHONE_NUMBER, CallerInfo.PAYPHONE_NUMBER);
+ setPhoneCallDetailsWithNumber("", Calls.PRESENTATION_PAYPHONE, "");
assertNoCallButton();
}
public void testSetPhoneCallDetails_VoicemailNumber() {
- setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, TEST_VOICEMAIL_NUMBER);
+ setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER,
+ Calls.PRESENTATION_ALLOWED, TEST_VOICEMAIL_NUMBER);
assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
}
@@ -108,8 +109,8 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
}
public void testSetPhoneCallDetails_VoicemailFromUnknown() {
- setPhoneCallDetailsWithNumberAndType(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER,
- Calls.VOICEMAIL_TYPE);
+ setPhoneCallDetailsWithNumberAndType("", Calls.PRESENTATION_UNKNOWN,
+ "", Calls.VOICEMAIL_TYPE);
assertEquals(View.VISIBLE, mViews.secondaryActionView.getVisibility());
}
@@ -120,15 +121,18 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
}
/** Sets the details of a phone call using the specified phone number. */
- private void setPhoneCallDetailsWithNumber(String number, String formattedNumber) {
- setPhoneCallDetailsWithNumberAndType(number, formattedNumber, Calls.INCOMING_TYPE);
+ private void setPhoneCallDetailsWithNumber(String number,
+ int presentation, String formattedNumber) {
+ setPhoneCallDetailsWithNumberAndType(number, presentation,
+ formattedNumber, Calls.INCOMING_TYPE);
}
/** Sets the details of a phone call using the specified phone number. */
- private void setPhoneCallDetailsWithNumberAndType(String number, String formattedNumber,
- int callType) {
+ private void setPhoneCallDetailsWithNumberAndType(String number,
+ int presentation, String formattedNumber, int callType) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(number, formattedNumber, TEST_COUNTRY_ISO, TEST_GEOCODE,
+ new PhoneCallDetails(number, presentation, formattedNumber,
+ TEST_COUNTRY_ISO, TEST_GEOCODE,
new int[]{ callType }, TEST_DATE, TEST_DURATION),
false);
}
@@ -136,16 +140,18 @@ public class CallLogListItemHelperTest extends AndroidTestCase {
/** Sets the details of a phone call using the specified call type. */
private void setPhoneCallDetailsWithTypes(int... types) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
- TEST_GEOCODE, types, TEST_DATE, TEST_DURATION),
+ new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
+ types, TEST_DATE, TEST_DURATION),
false);
}
/** Sets the details of a phone call using the specified call type. */
private void setUnreadPhoneCallDetailsWithTypes(int... types) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO,
- TEST_GEOCODE, types, TEST_DATE, TEST_DURATION),
+ new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED,
+ TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE,
+ types, TEST_DATE, TEST_DURATION),
true);
}
}
diff --git a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java
index 4be84aede..52b3b5d4f 100644
--- a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java
+++ b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java
@@ -29,7 +29,7 @@ public class CallLogQueryTestUtils {
public static Object[] createTestValues() {
Object[] values = new Object[]{
0L, "", 0L, 0L, Calls.INCOMING_TYPE, "", "", "", null, 0, null, null, null, null,
- 0L, null, 0,
+ 0L, null, 0, Calls.PRESENTATION_ALLOWED,
};
assertEquals(CallLogQuery._PROJECTION.length, values.length);
return values;
@@ -38,7 +38,7 @@ public class CallLogQueryTestUtils {
public static Object[] createTestExtendedValues() {
Object[] values = new Object[]{
0L, "", 0L, 0L, Calls.INCOMING_TYPE, "", "", "", null, 0, null, null, null, null,
- 0L, null, 1, CallLogQuery.SECTION_OLD_ITEM
+ 0L, null, 1, Calls.PRESENTATION_ALLOWED, CallLogQuery.SECTION_OLD_ITEM
};
Assert.assertEquals(CallLogQuery.EXTENDED_PROJECTION.length, values.length);
return values;
diff --git a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
index ed492205c..b1b8e2f05 100644
--- a/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
+++ b/tests/src/com/android/dialer/tests/calllog/FillCallLogTestActivity.java
@@ -161,6 +161,7 @@ public class FillCallLogTestActivity extends Activity {
for (int i = 0; i < count; i++) {
values[i] = new ContentValues();
values[i].put(Calls.NUMBER, generateRandomNumber());
+ values[i].put(Calls.NUMBER_PRESENTATION, Calls.PRESENTATION_ALLOWED);
values[i].put(Calls.DATE, System.currentTimeMillis()); // Will be randomized later
values[i].put(Calls.DURATION, 1); // Will be overwritten later
}