Merge "Pass call direction for existing connections created in Telephony." into qt-dev
diff --git a/src/com/android/services/telephony/ConferenceParticipantConnection.java b/src/com/android/services/telephony/ConferenceParticipantConnection.java
index 651ace5..61dc039 100644
--- a/src/com/android/services/telephony/ConferenceParticipantConnection.java
+++ b/src/com/android/services/telephony/ConferenceParticipantConnection.java
@@ -69,7 +69,8 @@
address = null;
} else {
String countryIso = getCountryIso(parentConnection.getCall().getPhone());
- address = getParticipantAddress(participant.getHandle(), countryIso);
+ address = ConferenceParticipant.getParticipantAddress(participant.getHandle(),
+ countryIso);
}
setAddress(address, presentation);
setVideoState(parentConnection.getVideoState());
@@ -165,64 +166,6 @@
}
}
-
-
- /**
- * Attempts to build a tel: style URI from a conference participant.
- * Conference event package data contains SIP URIs, so we try to extract the phone number and
- * format into a typical tel: style URI.
- *
- * @param address The conference participant's address.
- * @param countryIso The country ISO of the current subscription; used when formatting the
- * participant phone number to E.164 format.
- * @return The participant's address URI.
- */
- @VisibleForTesting
- public static Uri getParticipantAddress(Uri address, String countryIso) {
- if (address == null) {
- return address;
- }
- // Even if address is already in tel: format, still parse it and rebuild.
- // This is to recognize tel URIs such as:
- // tel:6505551212;phone-context=ims.mnc012.mcc034.3gppnetwork.org
-
- // Conference event package participants are identified using SIP URIs (see RFC3261).
- // A valid SIP uri has the format: sip:user:password@host:port;uri-parameters?headers
- // Per RFC3261, the "user" can be a telephone number.
- // For example: sip:1650555121;phone-context=blah.com@host.com
- // In this case, the phone number is in the user field of the URI, and the parameters can be
- // ignored.
- //
- // A SIP URI can also specify a phone number in a format similar to:
- // sip:+1-212-555-1212@something.com;user=phone
- // In this case, the phone number is again in user field and the parameters can be ignored.
- // We can get the user field in these instances by splitting the string on the @, ;, or :
- // and looking at the first found item.
- String number = address.getSchemeSpecificPart();
- if (TextUtils.isEmpty(number)) {
- return address;
- }
-
- String numberParts[] = number.split("[@;:]");
- if (numberParts.length == 0) {
- return address;
- }
- number = numberParts[0];
-
- // Attempt to format the number in E.164 format and use that as part of the TEL URI.
- // RFC2806 recommends to format telephone numbers using E.164 since it is independent of
- // how the dialing of said numbers takes place.
- // If conversion to E.164 fails, the returned value is null. In that case, fallback to the
- // number which was in the CEP data.
- String formattedNumber = null;
- if (!TextUtils.isEmpty(countryIso)) {
- formattedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso);
- }
-
- return Uri.fromParts(PhoneAccount.SCHEME_TEL,
- formattedNumber != null ? formattedNumber : number, null);
- }
-
/**
* Given a {@link Phone} instance, determines the country ISO associated with the phone's
* subscription.
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index 9b66487..245f2e8 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -975,6 +975,10 @@
connection.setConnectTimeMillis(participant.getConnectTime());
connection.setConnectionStartElapsedRealTime(participant.getConnectElapsedTime());
}
+ // Indicate whether this is an MT or MO call to Telecom; the participant has the cached
+ // data from the time of merge.
+ connection.setCallDirection(participant.getCallDirection());
+
Log.i(this, "createConferenceParticipantConnection: participant=%s, connection=%s",
participant, connection);
diff --git a/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java b/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java
index f404945..4336a20 100644
--- a/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java
+++ b/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java
@@ -16,7 +16,7 @@
package com.android.services.telephony;
-import static com.android.services.telephony.ConferenceParticipantConnection.getParticipantAddress;
+import static android.telecom.ConferenceParticipant.getParticipantAddress;
import static org.junit.Assert.assertEquals;
diff --git a/tests/src/com/android/services/telephony/ImsConferenceTest.java b/tests/src/com/android/services/telephony/ImsConferenceTest.java
index 8d67973..68b5b3b 100644
--- a/tests/src/com/android/services/telephony/ImsConferenceTest.java
+++ b/tests/src/com/android/services/telephony/ImsConferenceTest.java
@@ -32,6 +32,7 @@
import android.net.Uri;
import android.os.Looper;
+import android.telecom.Call;
import android.telecom.Conference;
import android.telecom.ConferenceParticipant;
import android.telecom.Connection;
@@ -85,12 +86,14 @@
Uri.parse("tel:6505551212"),
"A",
Uri.parse("sip:6505551212@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
ConferenceParticipant participant2 = new ConferenceParticipant(
Uri.parse("tel:6505551213"),
"A",
Uri.parse("sip:6505551213@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
imsConference.handleConferenceParticipantsUpdate(mConferenceHost,
Arrays.asList(participant1, participant2));
assertEquals(2, imsConference.getNumberOfParticipants());
@@ -145,12 +148,14 @@
Uri.parse("tel:6505551212"),
"A",
Uri.parse("sip:6505551212@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
ConferenceParticipant participant2 = new ConferenceParticipant(
Uri.parse("tel:6505551213"),
"A",
Uri.parse("sip:6505551213@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
imsConference.handleConferenceParticipantsUpdate(mConferenceHost,
Arrays.asList(participant1, participant2));
assertEquals(2, imsConference.getNumberOfParticipants());
@@ -191,12 +196,14 @@
Uri.parse("tel:6505551212"),
"A",
Uri.parse("sip:6505551212@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
ConferenceParticipant participant2 = new ConferenceParticipant(
Uri.parse("tel:6505551213"),
"A",
Uri.parse("sip:6505551213@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
imsConference.handleConferenceParticipantsUpdate(mConferenceHost,
Arrays.asList(participant1, participant2));
assertEquals(2, imsConference.getNumberOfParticipants());
@@ -226,12 +233,14 @@
Uri.parse("tel:6505551212"),
"A",
Uri.parse("sip:6505551212@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
ConferenceParticipant participant2 = new ConferenceParticipant(
Uri.parse("tel:6505551213"),
"A",
Uri.parse("sip:6505551213@testims.com"),
- Connection.STATE_ACTIVE);
+ Connection.STATE_ACTIVE,
+ Call.Details.DIRECTION_INCOMING);
imsConference.handleConferenceParticipantsUpdate(mConferenceHost,
Arrays.asList(participant1, participant2));
assertEquals(2, imsConference.getNumberOfParticipants());