diff options
-rw-r--r-- | InCallUI/res/values/strings.xml | 4 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/Call.java | 25 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardPresenter.java | 13 |
3 files changed, 40 insertions, 2 deletions
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 @@ <!-- Description of the "camera off" icon displayed when the device's camera is disabled during a video call. [CHAR LIMIT=NONE] --> <string name="camera_off_description">Camera off</string> + + <!-- Used to inform the user that a call was received via a number other than the primary + phone number associated with their device. [CHAR LIMIT=16] --> + <string name="child_number">via <xliff:g id="child_number" example="650-555-1212">%s</xliff:g></string> </resources> 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 0fb5b2e7a..75aa78578 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -589,13 +589,22 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> 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, showContactPhoto); |