aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Ebinger <breadley@google.com>2022-05-07 00:20:24 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-05-07 00:20:24 +0000
commite313c4bdc01472b8797242d0de32a436c550af11 (patch)
tree69b7396411f5e69e690910c73bf9c0d3c64c4676
parentc5a4591082880492513f13a1ee581ebc60e57ba3 (diff)
parent6f7c9bb60a9f80673649044c18863d8ce155ff61 (diff)
downloadims-e313c4bdc01472b8797242d0de32a436c550af11.tar.gz
Fix a minor logic issue in ag/18176102 am: 6f7c9bb60a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/ims/+/18203222 Change-Id: I66945139426c26833ab62b9c4b6b819c1b827792 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfo.java29
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishUtils.java20
-rw-r--r--tests/src/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfoTest.java10
3 files changed, 41 insertions, 18 deletions
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfo.java b/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfo.java
index 16e905d9..dc794331 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfo.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfo.java
@@ -274,19 +274,15 @@ public class DeviceCapabilityInfo {
}
/**
- * Get the IMS associated URI. It will first get the uri of MMTEL if it is not empty, otherwise
- * it will try to get the uri of RCS. The null will be returned if both MMTEL and RCS are empty.
+ * Get the first URI from the "p-associated-uri" header included in the IMS registration
+ * response.
+ * @param preferTelUri If {@code true}, prefer returning the first TEL URI. If no TEL
+ * URIs exist, this method will still return the preferred (first) SIP URI
+ * in the header. If {@code false}, we will return the first URI
+ * in the "p-associated-uri" header, independent of the URI scheme.
*/
- public synchronized Uri getImsAssociatedUri(boolean perferTelUri) {
- if (perferTelUri == false) {
- if (!mRcsAssociatedUris.isEmpty()) {
- return mRcsAssociatedUris.get(0);
- } else if (!mMmtelAssociatedUris.isEmpty()) {
- return mMmtelAssociatedUris.get(0);
- } else {
- return null;
- }
- } else {
+ public synchronized Uri getImsAssociatedUri(boolean preferTelUri) {
+ if (preferTelUri) {
if (!mRcsAssociatedUris.isEmpty()) {
for (Uri rcsAssociatedUri : mRcsAssociatedUris) {
if (PhoneAccount.SCHEME_TEL.equalsIgnoreCase(rcsAssociatedUri.getScheme())) {
@@ -301,6 +297,15 @@ public class DeviceCapabilityInfo {
}
}
}
+ }
+
+ // Either we have not found a TEL URI or we do not prefer TEL URIs. Get the first URI from
+ // p-associated-uri list.
+ if (!mRcsAssociatedUris.isEmpty()) {
+ return mRcsAssociatedUris.get(0);
+ } else if (!mMmtelAssociatedUris.isEmpty()) {
+ return mMmtelAssociatedUris.get(0);
+ } else {
return null;
}
}
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/PublishUtils.java b/src/java/com/android/ims/rcs/uce/presence/publish/PublishUtils.java
index 7df6bde5..1a67a40a 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/PublishUtils.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/PublishUtils.java
@@ -43,26 +43,34 @@ public class PublishUtils {
private static final String SCHEME_TEL = "tel";
private static final String DOMAIN_SEPARATOR = "@";
+ /**
+ * @return the contact URI of this device for either a PRESENCE or OPTIONS capabilities request.
+ * We will first try to use the IMS service associated URIs from the p-associated-uri header
+ * in the IMS registration response. If this is not available, we will fall back to using the
+ * SIM card information to generate the URI.
+ */
public static Uri getDeviceContactUri(Context context, int subId,
DeviceCapabilityInfo deviceCap, boolean isForPresence) {
boolean preferTelUri = false;
if (isForPresence) {
preferTelUri = UceUtils.isTelUriForPidfXmlEnabled(context, subId);
}
- // Get the uri from the IMS associated URI which is provided by the IMS service.
+ // Get the uri from the IMS p-associated-uri header which is provided by the IMS service.
Uri contactUri = deviceCap.getImsAssociatedUri(preferTelUri);
if (contactUri != null) {
- Log.d(LOG_TAG, "getDeviceContactUri: ims associated uri");
+ Uri convertedUri = preferTelUri ? getConvertedTelUri(context, contactUri) : contactUri;
+ Log.d(LOG_TAG, "getDeviceContactUri: returning "
+ + (contactUri.equals(convertedUri) ? "found" : "converted")
+ + " ims associated uri");
return contactUri;
}
+ // No IMS service provided URIs, so generate the contact uri from ISIM.
TelephonyManager telephonyManager = getTelephonyManager(context, subId);
if (telephonyManager == null) {
Log.w(LOG_TAG, "getDeviceContactUri: TelephonyManager is null");
return null;
}
-
- // Get the contact uri from ISIM.
contactUri = getContactUriFromIsim(telephonyManager);
if (contactUri != null) {
Log.d(LOG_TAG, "getDeviceContactUri: impu");
@@ -152,6 +160,10 @@ public class PublishUtils {
}
}
+ /**
+ * @return a TEL URI version of the contact URI if given a SIP URI. If given a TEL URI, this
+ * method will return the same value given.
+ */
private static Uri getConvertedTelUri(Context context, Uri contactUri) {
if (contactUri == null) {
return null;
diff --git a/tests/src/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfoTest.java b/tests/src/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfoTest.java
index 72cd26f4..c977a080 100644
--- a/tests/src/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfoTest.java
+++ b/tests/src/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfoTest.java
@@ -123,7 +123,8 @@ public class DeviceCapabilityInfoTest extends ImsTestBase {
assertEquals(number, telNumber);
- //If there is only SIP URI, check the return uri is null if preferTelUir is true.
+ // If there is only SIP URI, this method will still return a SIP URI, since there are no TEL
+ // URIs found in the list.
deviceCapInfo = createDeviceCapabilityInfo();
uris[0] = Uri.fromParts(PhoneAccount.SCHEME_SIP, telNumber, null);
@@ -132,7 +133,12 @@ public class DeviceCapabilityInfoTest extends ImsTestBase {
deviceCapInfo.updateRcsAssociatedUri(uris);
outUri = deviceCapInfo.getImsAssociatedUri(true);
- assertNull(outUri);
+ numbers = outUri.getSchemeSpecificPart();
+ numberParts = numbers.split("[@;:]");
+ number = numberParts[0];
+
+ assertEquals(number, telNumber);
+
}
private DeviceCapabilityInfo createDeviceCapabilityInfo() {