aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames.cf Lin <jamescflin@google.com>2021-05-27 03:12:11 +0800
committerJames.cf Lin <jamescflin@google.com>2021-05-28 10:11:23 +0800
commitec617e6c7bf785debbcfc39368b162a25999ce89 (patch)
tree58e050248f5dd6a5c2fb71b8e3b97b045355dcde
parent507db838e0a0e8cf742f6b5718712b7c7ea073e1 (diff)
downloadims-ec617e6c7bf785debbcfc39368b162a25999ce89.tar.gz
Get the IMS associated URI which is provided from ImsService to publish the device capabilities.
Bug: 185322224 Test: atest -c CtsTelephonyTestCases:android.telephony.ims.cts.ImsServiceTest Change-Id: Id2dd7e73a107de1dae4223a53fb90a25127ab355
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfo.java88
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityListener.java61
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishController.java18
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishControllerImpl.java5
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishUtils.java14
5 files changed, 174 insertions, 12 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 a7fd254d..16d6cea2 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
@@ -40,8 +40,12 @@ import com.android.ims.rcs.uce.util.FeatureTags;
import com.android.ims.rcs.uce.util.UceUtils;
import java.io.PrintWriter;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* Stores the device's capabilities information.
@@ -76,9 +80,15 @@ public class DeviceCapabilityInfo {
// The network type which ims mmtel registers on.
private int mMmtelNetworkRegType;
+ // The list of the mmtel associated uris
+ private List<Uri> mMmtelAssociatedUris = Collections.emptyList();
+
// The rcs feature is registered or not
private boolean mRcsRegistered;
+ // The list of the rcs associated uris
+ private List<Uri> mRcsAssociatedUris = Collections.emptyList();
+
// Whether or not presence is reported as capable
private boolean mPresenceCapable;
@@ -114,6 +124,8 @@ public class DeviceCapabilityInfo {
mMobileData = true;
mVtSetting = true;
mMmTelCapabilities = new MmTelCapabilities();
+ mMmtelAssociatedUris = Collections.EMPTY_LIST;
+ mRcsAssociatedUris = Collections.EMPTY_LIST;
}
/**
@@ -164,8 +176,31 @@ public class DeviceCapabilityInfo {
mMmtelNetworkRegType = AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
}
- public synchronized void updatePresenceCapable(boolean isCapable) {
- mPresenceCapable = isCapable;
+ /**
+ * Update the MMTel associated URIs which are provided by the IMS service.
+ */
+ public synchronized void updateMmTelAssociatedUri(Uri[] uris) {
+ int originalSize = mMmtelAssociatedUris.size();
+ if (uris != null) {
+ mMmtelAssociatedUris = Arrays.stream(uris)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ } else {
+ mMmtelAssociatedUris.clear();
+ }
+ int currentSize = mMmtelAssociatedUris.size();
+ logd("updateMmTelAssociatedUri: size from " + originalSize + " to " + currentSize);
+ }
+
+ /**
+ * Get the MMTEL associated URI. When there are multiple uris in the list, take the first uri.
+ * Return null if the list of the MMTEL associated uri is empty.
+ */
+ public synchronized Uri getMmtelAssociatedUri() {
+ if (!mMmtelAssociatedUris.isEmpty()) {
+ return mMmtelAssociatedUris.get(0);
+ }
+ return null;
}
/**
@@ -210,6 +245,47 @@ public class DeviceCapabilityInfo {
return changed;
}
+ /**
+ * Update the RCS associated URIs which is provided by the IMS service.
+ */
+ public synchronized void updateRcsAssociatedUri(Uri[] uris) {
+ int originalSize = mRcsAssociatedUris.size();
+ if (uris != null) {
+ mRcsAssociatedUris = Arrays.stream(uris)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ } else {
+ mRcsAssociatedUris.clear();
+ }
+ int currentSize = mRcsAssociatedUris.size();
+ logd("updateRcsAssociatedUri: size from " + originalSize + " to " + currentSize);
+ }
+
+ /**
+ * Get the RCS associated URI. When there are multiple uris in the list, take the first uri.
+ * Return null if the list of the RCS associated uri is empty.
+ */
+ public synchronized Uri getRcsAssociatedUri() {
+ if (!mRcsAssociatedUris.isEmpty()) {
+ return mRcsAssociatedUris.get(0);
+ }
+ return null;
+ }
+
+ /**
+ * 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.
+ */
+ public synchronized Uri getImsAssociatedUri() {
+ if (!mRcsAssociatedUris.isEmpty()) {
+ return mRcsAssociatedUris.get(0);
+ } else if (!mMmtelAssociatedUris.isEmpty()) {
+ return mMmtelAssociatedUris.get(0);
+ } else {
+ return null;
+ }
+ }
+
public synchronized boolean addRegistrationOverrideCapabilities(Set<String> featureTags) {
logd("override - add: " + featureTags);
mOverrideRemoveFeatureTags.removeAll(featureTags);
@@ -346,6 +422,10 @@ public class DeviceCapabilityInfo {
return false;
}
+ public synchronized void updatePresenceCapable(boolean isCapable) {
+ mPresenceCapable = isCapable;
+ }
+
public synchronized boolean isPresenceCapable() {
return mPresenceCapable;
}
@@ -393,7 +473,7 @@ public class DeviceCapabilityInfo {
// Get the device's capabilities with the PRESENCE mechanism.
private RcsContactUceCapability getPresenceCapabilities(Context context) {
- Uri uri = PublishUtils.getDeviceContactUri(context, mSubId);
+ Uri uri = PublishUtils.getDeviceContactUri(context, mSubId, this);
if (uri == null) {
logw("getPresenceCapabilities: uri is empty");
return null;
@@ -454,7 +534,7 @@ public class DeviceCapabilityInfo {
// Get the device's capabilities with the OPTIONS mechanism.
private RcsContactUceCapability getOptionsCapabilities(Context context) {
- Uri uri = PublishUtils.getDeviceContactUri(context, mSubId);
+ Uri uri = PublishUtils.getDeviceContactUri(context, mSubId, this);
if (uri == null) {
logw("getOptionsCapabilities: uri is empty");
return null;
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityListener.java b/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityListener.java
index 4d85779a..e881ae0c 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityListener.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityListener.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
+import android.net.Uri;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
@@ -52,6 +53,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.util.HandlerExecutor;
import java.io.PrintWriter;
+import java.util.Objects;
/**
* Listen to the device changes and notify the PublishController to publish the device's
@@ -457,6 +459,14 @@ public class DeviceCapabilityListener {
handleImsRcsUnregistered();
}
}
+
+ @Override
+ public void onSubscriberAssociatedUriChanged(Uri[] uris) {
+ synchronized (mLock) {
+ logi("onRcsSubscriberAssociatedUriChanged");
+ handleRcsSubscriberAssociatedUriChanged(uris, true);
+ }
+ }
};
@VisibleForTesting
@@ -480,6 +490,14 @@ public class DeviceCapabilityListener {
handleImsMmtelUnregistered();
}
}
+
+ @Override
+ public void onSubscriberAssociatedUriChanged(Uri[] uris) {
+ synchronized (mLock) {
+ logi("onMmTelSubscriberAssociatedUriChanged");
+ handleMmTelSubscriberAssociatedUriChanged(uris, true);
+ }
+ }
};
@VisibleForTesting
@@ -565,10 +583,30 @@ public class DeviceCapabilityListener {
*/
private void handleImsMmtelUnregistered() {
mCapabilityInfo.updateImsMmtelUnregistered();
+ // When the MMTEL is unregistered, the mmtel associated uri should be cleared.
+ handleMmTelSubscriberAssociatedUriChanged(null, false);
mHandler.sendTriggeringPublishMessage(
PublishController.PUBLISH_TRIGGER_MMTEL_UNREGISTERED);
}
+ /*
+ * This method is called when the MMTEL associated uri has changed.
+ */
+ private void handleMmTelSubscriberAssociatedUriChanged(Uri[] uris, boolean triggerPublish) {
+ Uri originalUri = mCapabilityInfo.getMmtelAssociatedUri();
+ mCapabilityInfo.updateMmTelAssociatedUri(uris);
+ Uri currentUri = mCapabilityInfo.getMmtelAssociatedUri();
+
+ boolean hasChanged = !(Objects.equals(originalUri, currentUri));
+ logi("handleMmTelSubscriberAssociatedUriChanged: triggerPublish=" + triggerPublish +
+ ", hasChanged=" + hasChanged);
+
+ if (triggerPublish && hasChanged) {
+ mHandler.sendTriggeringPublishMessage(
+ PublishController.PUBLISH_TRIGGER_MMTEL_URI_CHANGE);
+ }
+ }
+
private void handleMmtelCapabilitiesStatusChanged(MmTelCapabilities capabilities) {
boolean isChanged = mCapabilityInfo.updateMmtelCapabilitiesChanged(capabilities);
logi("MMTel capabilities status changed: isChanged=" + isChanged);
@@ -591,13 +629,34 @@ public class DeviceCapabilityListener {
* This method is called when RCS is unregistered.
*/
private void handleImsRcsUnregistered() {
- if (mCapabilityInfo.updateImsRcsUnregistered()) {
+ boolean hasChanged = mCapabilityInfo.updateImsRcsUnregistered();
+ // When the RCS is unregistered, the rcs associated uri should be cleared.
+ handleRcsSubscriberAssociatedUriChanged(null, false);
+ // Trigger publish if the state has changed.
+ if (hasChanged) {
mHandler.sendTriggeringPublishMessage(
PublishController.PUBLISH_TRIGGER_RCS_UNREGISTERED);
}
}
/*
+ * This method is called when the RCS associated uri has changed.
+ */
+ private void handleRcsSubscriberAssociatedUriChanged(Uri[] uris, boolean triggerPublish) {
+ Uri originalUri = mCapabilityInfo.getRcsAssociatedUri();
+ mCapabilityInfo.updateRcsAssociatedUri(uris);
+ Uri currentUri = mCapabilityInfo.getRcsAssociatedUri();
+
+ boolean hasChanged = !(Objects.equals(originalUri, currentUri));
+ logi("handleRcsSubscriberAssociatedUriChanged: triggerPublish=" + triggerPublish +
+ ", hasChanged=" + hasChanged);
+
+ if (triggerPublish && hasChanged) {
+ mHandler.sendTriggeringPublishMessage(PublishController.PUBLISH_TRIGGER_RCS_URI_CHANGE);
+ }
+ }
+
+ /*
* This method is called when the provisioning is changed
*/
private void handleProvisioningChanged() {
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/PublishController.java b/src/java/com/android/ims/rcs/uce/presence/publish/PublishController.java
index eac31a70..7ea90473 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/PublishController.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/PublishController.java
@@ -63,20 +63,26 @@ public interface PublishController extends ControllerBase {
/** Publish trigger type: MMTEL capability changes */
int PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE = 9;
+ /** Publish trigger type: MMTEL associated uri changes */
+ int PUBLISH_TRIGGER_MMTEL_URI_CHANGE = 10;
+
/** Publish trigger type: RCS registered */
- int PUBLISH_TRIGGER_RCS_REGISTERED = 10;
+ int PUBLISH_TRIGGER_RCS_REGISTERED = 11;
/** Publish trigger type: RCS unregistered */
- int PUBLISH_TRIGGER_RCS_UNREGISTERED = 11;
+ int PUBLISH_TRIGGER_RCS_UNREGISTERED = 12;
+
+ /** Publish trigger type: RCS associated uri changes */
+ int PUBLISH_TRIGGER_RCS_URI_CHANGE = 13;
/** Publish trigger type: provisioning changes */
- int PUBLISH_TRIGGER_PROVISIONING_CHANGE = 12;
+ int PUBLISH_TRIGGER_PROVISIONING_CHANGE = 14;
/**The caps have been overridden for a test*/
- int PUBLISH_TRIGGER_OVERRIDE_CAPS = 13;
+ int PUBLISH_TRIGGER_OVERRIDE_CAPS = 15;
/** The Carrier Config for the subscription has Changed **/
- int PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED = 14;
+ int PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED = 16;
@IntDef(value = {
PUBLISH_TRIGGER_SERVICE,
@@ -88,8 +94,10 @@ public interface PublishController extends ControllerBase {
PUBLISH_TRIGGER_MMTEL_REGISTERED,
PUBLISH_TRIGGER_MMTEL_UNREGISTERED,
PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE,
+ PUBLISH_TRIGGER_MMTEL_URI_CHANGE,
PUBLISH_TRIGGER_RCS_REGISTERED,
PUBLISH_TRIGGER_RCS_UNREGISTERED,
+ PUBLISH_TRIGGER_RCS_URI_CHANGE,
PUBLISH_TRIGGER_PROVISIONING_CHANGE,
PUBLISH_TRIGGER_OVERRIDE_CAPS,
PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/PublishControllerImpl.java b/src/java/com/android/ims/rcs/uce/presence/publish/PublishControllerImpl.java
index 17060d0f..9da4e4f8 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/PublishControllerImpl.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/PublishControllerImpl.java
@@ -469,7 +469,12 @@ public class PublishControllerImpl implements PublishController {
case MSG_RESET_DEVICE_STATE:
publishCtrl.handleResetDeviceStateMessage();
break;
+
+ default:
+ publishCtrl.logd("invalid message: " + message.what);
+ break;
}
+ publishCtrl.logd("handleMessage done: " + EVENT_DESCRIPTION.get(message.what));
}
/**
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 27bded8a..e412cc6d 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
@@ -25,6 +25,8 @@ import android.util.Log;
import com.android.ims.rcs.uce.util.UceUtils;
+import java.util.Arrays;
+
/**
* The util class of publishing device's capabilities.
*/
@@ -35,7 +37,15 @@ public class PublishUtils {
private static final String SCHEME_TEL = "tel";
private static final String DOMAIN_SEPARATOR = "@";
- public static Uri getDeviceContactUri(Context context, int subId) {
+ public static Uri getDeviceContactUri(Context context, int subId,
+ DeviceCapabilityInfo deviceCap) {
+ // Get the uri from the IMS associated URI which is provided by the IMS service.
+ Uri contactUri = deviceCap.getImsAssociatedUri();
+ if (contactUri != null) {
+ Log.d(LOG_TAG, "getDeviceContactUri: ims associated uri");
+ return contactUri;
+ }
+
TelephonyManager telephonyManager = getTelephonyManager(context, subId);
if (telephonyManager == null) {
Log.w(LOG_TAG, "getDeviceContactUri: TelephonyManager is null");
@@ -43,7 +53,7 @@ public class PublishUtils {
}
// Get the contact uri from ISIM.
- Uri contactUri = getContactUriFromIsim(telephonyManager);
+ contactUri = getContactUriFromIsim(telephonyManager);
if (contactUri != null) {
Log.d(LOG_TAG, "getDeviceContactUri: impu");
return contactUri;