diff options
author | Tyler Gunn <tgunn@google.com> | 2015-07-28 15:34:48 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-28 15:34:48 +0000 |
commit | 95c75e069d6bcc0577a6c26bbe54f39b4e5bd2ea (patch) | |
tree | a6386c485b6afcf5548d9e4013bd766c0a7dbb06 | |
parent | 5053e7ba1df53a25379d8a62be4e58ee43d8c691 (diff) | |
parent | 5818d2ba74e2d6ef5bdfb4df5c63db2e0763ce85 (diff) |
am 4db859b7: am e182bb44: Merge "Add support for showing child number in incall ui." into mnc-dr-dev
* commit '4db859b708911ec47c6488dc5cfa8cef65aee029':
Add support for showing child number in incall ui.
-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 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<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); } else { |