From 460ac2da6d15bd94fe31c1a30d12418d01d8976a Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Thu, 23 Jul 2015 16:44:00 -0700 Subject: Add support for showing child number in incall ui. Bug: 22685113 Change-Id: I4cf8f92820fcc028d26b5edcbf9bbc02a4d7a6d5 --- InCallUI/res/values/strings.xml | 4 ++++ InCallUI/src/com/android/incallui/Call.java | 25 ++++++++++++++++++++++ .../com/android/incallui/CallCardPresenter.java | 13 +++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/res/values/strings.xml b/InCallUI/res/values/strings.xml index cadef732b..15cba1f32 100644 --- a/InCallUI/res/values/strings.xml +++ b/InCallUI/res/values/strings.xml @@ -456,4 +456,8 @@ Camera off + + + via %s diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index ee73db2b5..807d43a13 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -28,6 +28,7 @@ import android.os.Trace; import android.telecom.DisconnectCause; import android.telecom.GatewayInfo; import android.telecom.InCallService.VideoCall; +import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.VideoProfile; import android.text.TextUtils; @@ -35,12 +36,20 @@ import android.text.TextUtils; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Objects; /** * Describes a single call and its state. */ @NeededForTesting public class Call { + /** + * Call extras key used to store a child number associated with the current call. + * Used to communicate that the connection was received via a child phone number associated with + * the {@link PhoneAccount}'s primary number. + */ + public static final String EXTRA_CHILD_ADDRESS = "android.telecom.EXTRA_CHILD_ADDRESS"; + /* Defines different states of this call */ public static class State { public static final int INVALID = 0; @@ -254,6 +263,7 @@ public class Call { private int mModifyToVideoState = VideoProfile.STATE_AUDIO_ONLY; private InCallVideoCallCallback mVideoCallCallback; + private String mChildNumber; /** * Used only to create mock calls for testing @@ -314,6 +324,14 @@ public class Call { CallList.getInstance().getCallByTelecommCall( mTelecommCall.getChildren().get(i)).getId()); } + + Bundle callExtras = mTelecommCall.getDetails().getExtras(); + if (callExtras != null && callExtras.containsKey(EXTRA_CHILD_ADDRESS)) { + String childNumber = callExtras.getString(EXTRA_CHILD_ADDRESS); + if (!Objects.equals(childNumber, mChildNumber)) { + mChildNumber = childNumber; + } + } } private static int translateState(int state) { @@ -393,6 +411,13 @@ public class Call { return mTelecommCall == null ? null : mTelecommCall.getDetails().getExtras(); } + /** + * @return The child number for the call, or {@code null} if none specified. + */ + public String getChildNumber() { + return mChildNumber; + } + /** Returns call disconnect cause, defined by {@link DisconnectCause}. */ public DisconnectCause getDisconnectCause() { if (mState == State.DISCONNECTED || mState == State.IDLE) { diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 3f9c567d6..c39d79278 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -582,13 +582,22 @@ public class CallCardPresenter extends Presenter Log.d(TAG, "Update primary display info for " + mPrimaryContactInfo); String name = getNameForCall(mPrimaryContactInfo); - String number = getNumberForCall(mPrimaryContactInfo); + String number; + + // If a child number is present, use it instead of the 2nd line. + boolean isChildNumberShown = !TextUtils.isEmpty(mPrimary.getChildNumber()); + if (isChildNumberShown) { + number = mContext.getString(R.string.child_number, mPrimary.getChildNumber()); + } else { + number = getNumberForCall(mPrimaryContactInfo); + } + boolean nameIsNumber = name != null && name.equals(mPrimaryContactInfo.number); ui.setPrimary( number, name, nameIsNumber, - mPrimaryContactInfo.label, + isChildNumberShown ? null : mPrimaryContactInfo.label, mPrimaryContactInfo.photo, mPrimaryContactInfo.isSipCall); } else { -- cgit v1.2.3