summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSailesh Nepal <sail@google.com>2014-04-01 14:25:00 -0700
committerSailesh Nepal <sail@google.com>2014-04-01 14:42:42 -0700
commit07a822b2ea92dc5b68cd43139be7efe4c6640cd4 (patch)
tree099b543bd2c5769eb395e16ba5a182be47bc1cf2
parent6af0c61c32da6cfb400168ae3b0cf9f802abfed4 (diff)
downloadpackages_apps_InCallUI-07a822b2ea92dc5b68cd43139be7efe4c6640cd4.tar.gz
packages_apps_InCallUI-07a822b2ea92dc5b68cd43139be7efe4c6640cd4.tar.bz2
packages_apps_InCallUI-07a822b2ea92dc5b68cd43139be7efe4c6640cd4.zip
InCallUI: Use telecomm presentation and gateway info
Switch to use Telecomm's CallNumberPresentation and GatewayInfo. Change-Id: I962836c5f4b36c0b1f31d0dd6852fdf8a3a12736
-rw-r--r--src/com/android/incallui/Call.java42
-rw-r--r--src/com/android/incallui/CallCardPresenter.java11
-rw-r--r--src/com/android/incallui/CallerInfo.java5
-rw-r--r--src/com/android/incallui/CallerInfoUtils.java60
-rw-r--r--src/com/android/incallui/ContactInfoCache.java23
-rw-r--r--src/com/android/incallui/InCallServiceImpl.java7
6 files changed, 55 insertions, 93 deletions
diff --git a/src/com/android/incallui/Call.java b/src/com/android/incallui/Call.java
index f0d18777..7dd35791 100644
--- a/src/com/android/incallui/Call.java
+++ b/src/com/android/incallui/Call.java
@@ -16,6 +16,8 @@
package com.android.incallui;
+import android.telecomm.CallNumberPresentation;
+import android.telecomm.GatewayInfo;
import android.telephony.DisconnectCause;
import com.android.internal.telephony.PhoneConstants;
@@ -121,16 +123,6 @@ public final class Call {
| RESPOND_VIA_TEXT | MUTE | GENERIC_CONFERENCE | VIDEO_HANDOFF | CONNECTION_HANDOFF;
}
- // Number presentation type for caller id display
- // normal
- public static int PRESENTATION_ALLOWED = PhoneConstants.PRESENTATION_ALLOWED;
- // block by user
- public static int PRESENTATION_RESTRICTED = PhoneConstants.PRESENTATION_RESTRICTED;
- // no specified or unknown by network
- public static int PRESENTATION_UNKNOWN = PhoneConstants.PRESENTATION_UNKNOWN;
- // show pay phone info
- public static int PRESENTATION_PAYPHONE = PhoneConstants.PRESENTATION_PAYPHONE;
-
// Unique identifier for the call
private String mCallId;
@@ -155,11 +147,7 @@ public final class Call {
private String mNumber;
- // Gateway number used to dial this call
- private String mGatewayNumber;
-
- // Gateway service package name
- private String mGatewayPackage;
+ private GatewayInfo mGatewayInfo;
public Call(String callId, String number) {
mCallId = callId;
@@ -186,12 +174,12 @@ public final class Call {
return mIsWifiCall;
}
- public int getNumberPresentation() {
- return PRESENTATION_ALLOWED;
+ public CallNumberPresentation getNumberPresentation() {
+ return CallNumberPresentation.ALLOWED;
}
- public int getCnapNamePresentation() {
- return PRESENTATION_ALLOWED;
+ public CallNumberPresentation getCnapNamePresentation() {
+ return CallNumberPresentation.ALLOWED;
}
public String getCnapName() {
@@ -240,20 +228,12 @@ public final class Call {
return false;
}
- public String getGatewayNumber() {
- return mGatewayNumber;
- }
-
- public void setGatewayNumber(String number) {
- mGatewayNumber = number;
- }
-
- public String getGatewayPackage() {
- return mGatewayPackage;
+ public GatewayInfo getGatewayInfo() {
+ return mGatewayInfo;
}
- public void setGatewayPackage(String packageName) {
- mGatewayPackage = packageName;
+ public void setGatewayInfo(GatewayInfo gatewayInfo) {
+ mGatewayInfo = gatewayInfo;
}
@Override
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 272c6c12..996cff91 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -402,9 +402,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
*/
private String getGatewayNumber() {
if (hasOutgoingGatewayCall()) {
- return mPrimary.getGatewayNumber();
+ return mPrimary.getGatewayInfo().getGatewayHandle().getSchemeSpecificPart();
}
-
return null;
}
@@ -415,7 +414,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
if (hasOutgoingGatewayCall() && getUi() != null) {
final PackageManager pm = mContext.getPackageManager();
try {
- final ApplicationInfo info = pm.getApplicationInfo(mPrimary.getGatewayPackage(), 0);
+ ApplicationInfo info = pm.getApplicationInfo(
+ mPrimary.getGatewayInfo().getGatewayProviderPackageName(), 0);
return mContext.getString(R.string.calling_via_template,
pm.getApplicationLabel(info).toString());
} catch (PackageManager.NameNotFoundException e) {
@@ -433,9 +433,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
if (mPrimary == null) {
return false;
}
- return (Call.State.isDialing(mPrimary.getState()) &&
- !TextUtils.isEmpty(mPrimary.getGatewayNumber()) &&
- !TextUtils.isEmpty(mPrimary.getGatewayPackage()));
+ return Call.State.isDialing(mPrimary.getState()) && mPrimary.getGatewayInfo() != null &&
+ !mPrimary.getGatewayInfo().isEmpty();
}
/**
diff --git a/src/com/android/incallui/CallerInfo.java b/src/com/android/incallui/CallerInfo.java
index 2e89e48d..4f3898a2 100644
--- a/src/com/android/incallui/CallerInfo.java
+++ b/src/com/android/incallui/CallerInfo.java
@@ -27,6 +27,7 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.ContactsContract.RawContacts;
+import android.telecomm.CallNumberPresentation;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
@@ -79,8 +80,8 @@ public class CallerInfo {
public String geoDescription;
public String cnapName;
- public int numberPresentation;
- public int namePresentation;
+ public CallNumberPresentation numberPresentation;
+ public CallNumberPresentation namePresentation;
public boolean contactExists;
public String phoneLabel;
diff --git a/src/com/android/incallui/CallerInfoUtils.java b/src/com/android/incallui/CallerInfoUtils.java
index d1238a37..857f71ff 100644
--- a/src/com/android/incallui/CallerInfoUtils.java
+++ b/src/com/android/incallui/CallerInfoUtils.java
@@ -3,6 +3,7 @@ package com.android.incallui;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
+import android.telecomm.CallNumberPresentation;
import android.text.TextUtils;
import java.util.Arrays;
@@ -41,7 +42,7 @@ public class CallerInfoUtils {
// TODO: Have phoneapp send a Uri when it knows the contact that triggered this call.
- if (info.numberPresentation == Call.PRESENTATION_ALLOWED) {
+ if (info.numberPresentation == CallNumberPresentation.ALLOWED) {
// Start the query with the number provided from the call.
Log.d(TAG, "==> Actually starting CallerInfoAsyncQuery.startQuery()...");
CallerInfoAsyncQuery.startQuery(QUERY_TOKEN, context, number, listener, call);
@@ -82,7 +83,7 @@ public class CallerInfoUtils {
* @return the new String that should be used for the phone number
*/
/* package */static String modifyForSpecialCnapCases(Context context, CallerInfo ci,
- String number, int presentation) {
+ String number, CallNumberPresentation presentation) {
// Obviously we return number if ci == null, but still return number if
// number == null, because in these cases the correct string will still be
// displayed/logged after this function returns based on the presentation value.
@@ -98,9 +99,9 @@ public class CallerInfoUtils {
final String[] absentNumberValues =
context.getResources().getStringArray(R.array.absent_num);
if (Arrays.asList(absentNumberValues).contains(number)
- && presentation == Call.PRESENTATION_ALLOWED) {
+ && presentation == CallNumberPresentation.ALLOWED) {
number = context.getString(R.string.unknown);
- ci.numberPresentation = Call.PRESENTATION_UNKNOWN;
+ ci.numberPresentation = CallNumberPresentation.UNKNOWN;
}
// Check for other special "corner cases" for CNAP and fix them similarly. Corner
@@ -108,48 +109,31 @@ public class CallerInfoUtils {
// if we think we have an allowed presentation, or if the CallerInfo presentation doesn't
// match the presentation passed in for verification (meaning we changed it previously
// because it's a corner case and we're being called from a different entry point).
- if (ci.numberPresentation == Call.PRESENTATION_ALLOWED
+ if (ci.numberPresentation == CallNumberPresentation.ALLOWED
|| (ci.numberPresentation != presentation
- && presentation == Call.PRESENTATION_ALLOWED)) {
- int cnapSpecialCase = checkCnapSpecialCases(number);
- if (cnapSpecialCase != CNAP_SPECIAL_CASE_NO) {
- // For all special strings, change number & numberPresentation.
- if (cnapSpecialCase == Call.PRESENTATION_RESTRICTED) {
- number = context.getString(R.string.private_num);
- } else if (cnapSpecialCase == Call.PRESENTATION_UNKNOWN) {
- number = context.getString(R.string.unknown);
- }
- Log.d(TAG, "SpecialCnap: number=" + toLogSafePhoneNumber(number)
- + "; presentation now=" + cnapSpecialCase);
- ci.numberPresentation = cnapSpecialCase;
+ && presentation == CallNumberPresentation.ALLOWED)) {
+ // For all special strings, change number & numberPrentation.
+ if (isCnapSpecialCaseRestricted(number)) {
+ number = context.getString(R.string.private_num);
+ ci.numberPresentation = CallNumberPresentation.RESTRICTED;
+ } else if (isCnapSpecialCaseUnknown(number)) {
+ number = context.getString(R.string.unknown);
+ ci.numberPresentation = CallNumberPresentation.UNKNOWN;
}
+ Log.d(TAG, "SpecialCnap: number=" + toLogSafePhoneNumber(number)
+ + "; presentation now=" + ci.numberPresentation);
}
Log.d(TAG, "modifyForSpecialCnapCases: returning number string="
+ toLogSafePhoneNumber(number));
return number;
}
- /**
- * Based on the input CNAP number string,
- * @return _RESTRICTED or _UNKNOWN for all the special CNAP strings.
- * Otherwise, return CNAP_SPECIAL_CASE_NO.
- */
- private static int checkCnapSpecialCases(String n) {
- if (n.equals("PRIVATE") ||
- n.equals("P") ||
- n.equals("RES")) {
- Log.d(TAG, "checkCnapSpecialCases, PRIVATE string: " + n);
- return Call.PRESENTATION_RESTRICTED;
- } else if (n.equals("UNAVAILABLE") ||
- n.equals("UNKNOWN") ||
- n.equals("UNA") ||
- n.equals("U")) {
- Log.d(TAG, "checkCnapSpecialCases, UNKNOWN string: " + n);
- return Call.PRESENTATION_UNKNOWN;
- } else {
- Log.d(TAG, "checkCnapSpecialCases, normal str. number: " + n);
- return CNAP_SPECIAL_CASE_NO;
- }
+ private static boolean isCnapSpecialCaseRestricted(String n) {
+ return n.equals("PRIVATE") || n.equals("P") || n.equals("RES");
+ }
+
+ private static boolean isCnapSpecialCaseUnknown(String n) {
+ return n.equals("UNAVAILABLE") || n.equals("UNKNOWN") || n.equals("UNA") || n.equals("U");
}
/* package */static String toLogSafePhoneNumber(String number) {
diff --git a/src/com/android/incallui/ContactInfoCache.java b/src/com/android/incallui/ContactInfoCache.java
index 8efa7917..99c46834 100644
--- a/src/com/android/incallui/ContactInfoCache.java
+++ b/src/com/android/incallui/ContactInfoCache.java
@@ -25,6 +25,7 @@ import android.net.Uri;
import android.os.Looper;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.telecomm.CallNumberPresentation;
import android.text.TextUtils;
import com.android.contacts.common.util.PhoneNumberHelper;
@@ -152,9 +153,10 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
private void findInfoQueryComplete(Call call, CallerInfo callerInfo, boolean isIncoming,
boolean didLocalLookup) {
final String callId = call.getCallId();
- int presentationMode = call.getNumberPresentation();
- if (callerInfo.contactExists || callerInfo.isEmergencyNumber() || callerInfo.isVoiceMailNumber()) {
- presentationMode = Call.PRESENTATION_ALLOWED;
+ CallNumberPresentation presentationMode = call.getNumberPresentation();
+ if (callerInfo.contactExists || callerInfo.isEmergencyNumber() ||
+ callerInfo.isVoiceMailNumber()) {
+ presentationMode = CallNumberPresentation.ALLOWED;
}
final ContactCacheEntry cacheEntry = buildEntry(mContext, callId,
@@ -299,7 +301,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
}
private ContactCacheEntry buildEntry(Context context, String callId,
- CallerInfo info, int presentation, boolean isIncoming) {
+ CallerInfo info, CallNumberPresentation presentation, boolean isIncoming) {
// The actual strings we're going to display onscreen:
Drawable photo = null;
@@ -338,7 +340,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
* Populate a cache entry from a call (which got converted into a caller info).
*/
public static void populateCacheEntry(Context context, CallerInfo info, ContactCacheEntry cce,
- int presentation, boolean isIncoming) {
+ CallNumberPresentation presentation, boolean isIncoming) {
Preconditions.checkNotNull(info);
String displayName = null;
String displayNumber = null;
@@ -388,7 +390,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
// (or potentially some other default based on the presentation.)
displayName = getPresentationString(context, presentation);
Log.d(TAG, " ==> no name *or* number! displayName = " + displayName);
- } else if (presentation != Call.PRESENTATION_ALLOWED) {
+ } else if (presentation != CallNumberPresentation.ALLOWED) {
// This case should never happen since the network should never send a phone #
// AND a restricted presentation. However we leave it here in case of weird
// network behavior
@@ -425,7 +427,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
} else {
// We do have a valid "name" in the CallerInfo. Display that
// in the "name" slot, and the phone number in the "number" slot.
- if (presentation != Call.PRESENTATION_ALLOWED) {
+ if (presentation != CallNumberPresentation.ALLOWED) {
// This case should never happen since the network should never send a name
// AND a restricted presentation. However we leave it here in case of weird
// network behavior
@@ -476,11 +478,12 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
/**
* Gets name strings based on some special presentation modes.
*/
- private static String getPresentationString(Context context, int presentation) {
+ private static String getPresentationString(Context context,
+ CallNumberPresentation presentation) {
String name = context.getString(R.string.unknown);
- if (presentation == Call.PRESENTATION_RESTRICTED) {
+ if (presentation == CallNumberPresentation.RESTRICTED) {
name = context.getString(R.string.private_num);
- } else if (presentation == Call.PRESENTATION_PAYPHONE) {
+ } else if (presentation == CallNumberPresentation.PAYPHONE) {
name = context.getString(R.string.payphone);
}
return name;
diff --git a/src/com/android/incallui/InCallServiceImpl.java b/src/com/android/incallui/InCallServiceImpl.java
index e2e377cb..6b9d9b15 100644
--- a/src/com/android/incallui/InCallServiceImpl.java
+++ b/src/com/android/incallui/InCallServiceImpl.java
@@ -82,12 +82,7 @@ public class InCallServiceImpl extends android.telecomm.InCallService {
break;
}
- GatewayInfo gatewayInfo = callInfo.getGatewayInfo();
- if (gatewayInfo != null) {
- call.setGatewayNumber(gatewayInfo.getGatewayHandle().getSchemeSpecificPart());
- call.setGatewayPackage(gatewayInfo.getGatewayProviderPackageName());
- }
-
+ call.setGatewayInfo(callInfo.getGatewayInfo());
call.addCapabilities(Call.Capabilities.HOLD | Call.Capabilities.MUTE);
if (call.getState() == Call.State.INCOMING) {