diff options
author | Sailesh Nepal <sail@google.com> | 2014-07-11 19:32:22 -0700 |
---|---|---|
committer | Sailesh Nepal <sail@google.com> | 2014-07-11 19:32:22 -0700 |
commit | d073d72017fd652f84071fecd73456160cd4daeb (patch) | |
tree | 1c14284baf0a60d054a8c0fe6f2274882cd0584e | |
parent | 875f3500a284420f00455fe7adf2a9df07f272f0 (diff) |
Misc Telecomm API changes: InCallUI
This CL hooks up the new APIs introduced in ag/501321 to the
InCallUI.
Change-Id: Iaffe0b84cea6003f2a9b9d8b30676743d2b236d4
8 files changed, 55 insertions, 57 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index d844d8eab..c8a21e968 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -19,7 +19,7 @@ package com.android.incallui; import android.net.Uri; import android.os.RemoteException; import android.telecomm.CallCapabilities; -import android.telecomm.CallNumberPresentation; +import android.telecomm.CallPropertyPresentation; import android.telecomm.CallServiceDescriptor; import android.telecomm.PhoneAccount; import android.telecomm.RemoteCallVideoProvider; @@ -107,13 +107,15 @@ public final class Call { private int mCapabilities; private long mConnectTimeMillis = 0; private Uri mHandle; + private int mNumberPresentation; + private String mCnapName; + private int mCnapNamePresentation; private GatewayInfo mGatewayInfo; private PhoneAccount mAccount; private CallServiceDescriptor mCurrentCallServiceDescriptor; private RemoteCallVideoProvider mCallVideoProvider; private String mParentCallId; private List<String> mChildCallIds; - private int mFeatures; private InCallVideoClient mCallVideoClient; @@ -140,6 +142,18 @@ public final class Call { mHandle = handle; } + public void setNumberPresentation(int presentation) { + mNumberPresentation = presentation; + } + + public void setCnapName(String cnapName) { + mCnapName = cnapName; + } + + public void setCnapNamePresentation(int presentation) { + mCnapNamePresentation = presentation; + } + public int getState() { if (mParentCallId != null) { return State.CONFERENCED; @@ -152,16 +166,16 @@ public final class Call { mState = state; } - public CallNumberPresentation getNumberPresentation() { - return CallNumberPresentation.ALLOWED; + public int getNumberPresentation() { + return mNumberPresentation; } - public CallNumberPresentation getCnapNamePresentation() { - return CallNumberPresentation.ALLOWED; + public int getCnapNamePresentation() { + return mCnapNamePresentation; } public String getCnapName() { - return ""; + return mCnapName; } /** Returns call disconnect cause; values are defined in {@link DisconnectCause}. */ @@ -271,14 +285,6 @@ public final class Call { return mParentCallId; } - public int getFeatures() { - return mFeatures; - } - - public void setFeatures(int features) { - mFeatures = features; - } - @Override public String toString() { return String.format(Locale.US, "[%s, %s, %s, children:%s, parent:%s]", diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index f0775e86d..d9fee5f44 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -225,7 +225,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto } public void swapClicked() { - TelecommAdapter.getInstance().swap(); + TelecommAdapter.getInstance().swap(mCall.getCallId()); } public void showDialpadClicked(boolean checked) { diff --git a/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java index 2029ca6f5..8f68cf807 100644 --- a/InCallUI/src/com/android/incallui/CallerInfo.java +++ b/InCallUI/src/com/android/incallui/CallerInfo.java @@ -28,7 +28,7 @@ import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.PhoneLookup; import android.provider.ContactsContract.RawContacts; -import android.telecomm.CallNumberPresentation; +import android.telecomm.CallPropertyPresentation; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; @@ -81,8 +81,8 @@ public class CallerInfo { public String geoDescription; public String cnapName; - public CallNumberPresentation numberPresentation; - public CallNumberPresentation namePresentation; + public int numberPresentation; + public int namePresentation; public boolean contactExists; public String phoneLabel; diff --git a/InCallUI/src/com/android/incallui/CallerInfoUtils.java b/InCallUI/src/com/android/incallui/CallerInfoUtils.java index 857f71fff..bc0ea78b4 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoUtils.java +++ b/InCallUI/src/com/android/incallui/CallerInfoUtils.java @@ -3,7 +3,7 @@ package com.android.incallui; import android.content.Context; import android.content.Intent; import android.net.Uri; -import android.telecomm.CallNumberPresentation; +import android.telecomm.CallPropertyPresentation; import android.text.TextUtils; import java.util.Arrays; @@ -42,7 +42,7 @@ public class CallerInfoUtils { // TODO: Have phoneapp send a Uri when it knows the contact that triggered this call. - if (info.numberPresentation == CallNumberPresentation.ALLOWED) { + if (info.numberPresentation == CallPropertyPresentation.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); @@ -83,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, CallNumberPresentation presentation) { + String number, int 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. @@ -99,9 +99,9 @@ public class CallerInfoUtils { final String[] absentNumberValues = context.getResources().getStringArray(R.array.absent_num); if (Arrays.asList(absentNumberValues).contains(number) - && presentation == CallNumberPresentation.ALLOWED) { + && presentation == CallPropertyPresentation.ALLOWED) { number = context.getString(R.string.unknown); - ci.numberPresentation = CallNumberPresentation.UNKNOWN; + ci.numberPresentation = CallPropertyPresentation.UNKNOWN; } // Check for other special "corner cases" for CNAP and fix them similarly. Corner @@ -109,16 +109,16 @@ 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 == CallNumberPresentation.ALLOWED + if (ci.numberPresentation == CallPropertyPresentation.ALLOWED || (ci.numberPresentation != presentation - && presentation == CallNumberPresentation.ALLOWED)) { + && presentation == CallPropertyPresentation.ALLOWED)) { // For all special strings, change number & numberPrentation. if (isCnapSpecialCaseRestricted(number)) { number = context.getString(R.string.private_num); - ci.numberPresentation = CallNumberPresentation.RESTRICTED; + ci.numberPresentation = CallPropertyPresentation.RESTRICTED; } else if (isCnapSpecialCaseUnknown(number)) { number = context.getString(R.string.unknown); - ci.numberPresentation = CallNumberPresentation.UNKNOWN; + ci.numberPresentation = CallPropertyPresentation.UNKNOWN; } Log.d(TAG, "SpecialCnap: number=" + toLogSafePhoneNumber(number) + "; presentation now=" + ci.numberPresentation); diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index 22ca88e4e..19b026787 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java @@ -24,7 +24,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.telecomm.CallPropertyPresentation; import android.text.TextUtils; import com.android.contacts.common.util.PhoneNumberHelper; @@ -150,10 +150,10 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete private void findInfoQueryComplete(Call call, CallerInfo callerInfo, boolean isIncoming, boolean didLocalLookup) { final String callId = call.getCallId(); - CallNumberPresentation presentationMode = call.getNumberPresentation(); + int presentationMode = call.getNumberPresentation(); if (callerInfo.contactExists || callerInfo.isEmergencyNumber() || callerInfo.isVoiceMailNumber()) { - presentationMode = CallNumberPresentation.ALLOWED; + presentationMode = CallPropertyPresentation.ALLOWED; } final ContactCacheEntry cacheEntry = buildEntry(mContext, callId, @@ -298,7 +298,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete } private ContactCacheEntry buildEntry(Context context, String callId, - CallerInfo info, CallNumberPresentation presentation, boolean isIncoming) { + CallerInfo info, int presentation, boolean isIncoming) { // The actual strings we're going to display onscreen: Drawable photo = null; @@ -335,7 +335,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, - CallNumberPresentation presentation, boolean isIncoming) { + int presentation, boolean isIncoming) { Preconditions.checkNotNull(info); String displayName = null; String displayNumber = null; @@ -385,7 +385,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 != CallNumberPresentation.ALLOWED) { + } else if (presentation != CallPropertyPresentation.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 @@ -422,7 +422,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 != CallNumberPresentation.ALLOWED) { + if (presentation != CallPropertyPresentation.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 @@ -473,12 +473,11 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete /** * Gets name strings based on some special presentation modes. */ - private static String getPresentationString(Context context, - CallNumberPresentation presentation) { + private static String getPresentationString(Context context, int presentation) { String name = context.getString(R.string.unknown); - if (presentation == CallNumberPresentation.RESTRICTED) { + if (presentation == CallPropertyPresentation.RESTRICTED) { name = context.getString(R.string.private_num); - } else if (presentation == CallNumberPresentation.PAYPHONE) { + } else if (presentation == CallPropertyPresentation.PAYPHONE) { name = context.getString(R.string.payphone); } return name; diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 29d0b191f..5ef7c5a52 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -223,12 +223,6 @@ public class InCallPresenter implements CallList.Listener { InCallState newState = getPotentialStateFromCallList(callList); newState = startOrFinishUi(newState); - // Renable notification shade and soft navigation buttons, if we are no longer in the - // incoming call screen - if (!newState.isIncoming()) { - TelecommAdapter.getInstance().setSystemBarNavigationEnabled(true); - } - // Set the new state before announcing it to the world Log.i(this, "Phone switching state: " + mInCallState + " -> " + newState); mInCallState = newState; @@ -427,9 +421,6 @@ public class InCallPresenter implements CallList.Listener { if (showing) { mIsActivityPreviouslyStarted = true; } - - final boolean shouldLockBars = showing && mInCallState.isIncoming(); - TelecommAdapter.getInstance().setSystemBarNavigationEnabled(!shouldLockBars); } /** @@ -496,14 +487,14 @@ public class InCallPresenter implements CallList.Listener { TelecommAdapter.getInstance().merge(activeCall.getCallId()); return true; } else if (canSwap) { - TelecommAdapter.getInstance().swap(); + TelecommAdapter.getInstance().swap(activeCall.getCallId()); return true; } } // (3) Swap calls if (canSwap) { - TelecommAdapter.getInstance().swap(); + TelecommAdapter.getInstance().swap(activeCall.getCallId()); return true; } } diff --git a/InCallUI/src/com/android/incallui/InCallServiceImpl.java b/InCallUI/src/com/android/incallui/InCallServiceImpl.java index 123e981b1..9fed90cb4 100644 --- a/InCallUI/src/com/android/incallui/InCallServiceImpl.java +++ b/InCallUI/src/com/android/incallui/InCallServiceImpl.java @@ -119,6 +119,9 @@ public class InCallServiceImpl extends InCallService { private void updateCall(Call call, InCallCall telecommCall) { call.setHandle(telecommCall.getHandle()); + call.setNumberPresentation(telecommCall.getHandlePresentation()); + call.setCnapName(telecommCall.getCallerDisplayName()); + call.setCnapNamePresentation(telecommCall.getCallerDisplayNamePresentation()); call.setDisconnectCause(telecommCall.getDisconnectCauseCode()); call.setCannedSmsResponses(telecommCall.getCannedSmsResponses()); call.setCapabilities(telecommCall.getCapabilities()); @@ -129,7 +132,6 @@ public class InCallServiceImpl extends InCallService { call.setState(translateState(telecommCall.getState())); call.setParentId(telecommCall.getParentCallId()); call.setChildCallIds(telecommCall.getChildCallIds()); - call.setFeatures(telecommCall.getFeatures()); try { call.setCallVideoProvider(telecommCall.getCallVideoProvider()); diff --git a/InCallUI/src/com/android/incallui/TelecommAdapter.java b/InCallUI/src/com/android/incallui/TelecommAdapter.java index 620a9bd99..d22cb1577 100644 --- a/InCallUI/src/com/android/incallui/TelecommAdapter.java +++ b/InCallUI/src/com/android/incallui/TelecommAdapter.java @@ -123,8 +123,12 @@ final class TelecommAdapter { } } - void swap() { - Log.wtf(this, "swap not implemented"); + void swap(String callId) { + if (mAdapter != null) { + mAdapter.swapWithBackgroundCall(callId); + } else { + Log.e(this, "error swapWithBackgroundCall, mAdapter is null."); + } } void addCall() { @@ -179,8 +183,4 @@ final class TelecommAdapter { Log.e(this, "error phoneAccountClicked, mAdapter is null"); } } - - void setSystemBarNavigationEnabled(boolean enable) { - // TODO(sail): Implement this. - } } |