summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2015-07-28 15:07:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-28 15:07:02 +0000
commite182bb448356d4836eea424f17024e7d726d33a2 (patch)
tree56a57876b8b6669678e1e7e8723470b26781310c
parent610c654b5b7961d35969dcea7918be4d5a4b5043 (diff)
parent6a6951cd95276386ac93902cd7b91ee463adc864 (diff)
downloadInCallUI-e182bb448356d4836eea424f17024e7d726d33a2.tar.gz
Merge "Add support for showing child number in incall ui." into mnc-dr-dev
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/com/android/incallui/Call.java25
-rw-r--r--src/com/android/incallui/CallCardPresenter.java13
3 files changed, 40 insertions, 2 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index cadef732..15cba1f3 100644
--- a/res/values/strings.xml
+++ b/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/src/com/android/incallui/Call.java b/src/com/android/incallui/Call.java
index ee73db2b..807d43a1 100644
--- a/src/com/android/incallui/Call.java
+++ b/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/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 3f9c567d..c39d7927 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/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 {