aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/android/ims/rcs/uce/presence
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/android/ims/rcs/uce/presence')
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityInfo.java105
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/DeviceCapabilityListener.java56
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishController.java39
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishControllerImpl.java89
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishProcessor.java26
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishRequestResponse.java80
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/PublishServiceDescTracker.java10
-rw-r--r--src/java/com/android/ims/rcs/uce/presence/publish/ServiceDescription.java14
8 files changed, 258 insertions, 161 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 dc794331..49291484 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
@@ -39,10 +39,13 @@ import android.util.Log;
import com.android.ims.rcs.uce.util.FeatureTags;
import com.android.ims.rcs.uce.util.UceUtils;
+import com.android.internal.annotations.VisibleForTesting;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -101,10 +104,14 @@ public class DeviceCapabilityInfo {
// Whether the settings are changed or not
private int mTtyPreferredMode;
- private boolean mAirplaneMode;
private boolean mMobileData;
private boolean mVtSetting;
+ // The service description associated with the last publication update.
+ private final Set<ServiceDescription> mLastSuccessfulCapabilities = new ArraySet<>();
+ // The service description to temporarily store the presence capability being sent.
+ private Set<ServiceDescription> mPendingPublishCapabilities;
+
public DeviceCapabilityInfo(int subId, String[] capToRegistrationMap) {
mSubId = subId;
mServiceCapRegTracker = PublishServiceDescTracker.fromCarrierConfig(capToRegistrationMap);
@@ -121,12 +128,13 @@ public class DeviceCapabilityInfo {
mRcsRegistered = false;
mRcsNetworkRegType = AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
mTtyPreferredMode = TelecomManager.TTY_MODE_OFF;
- mAirplaneMode = false;
mMobileData = true;
mVtSetting = true;
mMmTelCapabilities = new MmTelCapabilities();
mMmtelAssociatedUris = Collections.EMPTY_LIST;
mRcsAssociatedUris = Collections.EMPTY_LIST;
+ mLastSuccessfulCapabilities.clear();
+ mPendingPublishCapabilities = null;
}
/**
@@ -169,12 +177,17 @@ public class DeviceCapabilityInfo {
/**
* Update the status that IMS MMTEL is unregistered.
*/
- public synchronized void updateImsMmtelUnregistered() {
+ public synchronized boolean updateImsMmtelUnregistered() {
logi("IMS MMTEL unregistered: original state=" + mMmtelRegistered);
+ boolean changed = false;
if (mMmtelRegistered) {
mMmtelRegistered = false;
+ changed = true;
}
mMmtelNetworkRegType = AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
+ mLastSuccessfulCapabilities.clear();
+ mPendingPublishCapabilities = null;
+ return changed;
}
/**
@@ -242,7 +255,12 @@ public class DeviceCapabilityInfo {
mRcsRegistered = false;
changed = true;
}
+
+ mLastRegistrationFeatureTags = Collections.emptySet();
+ updateRegistration(mLastRegistrationFeatureTags);
mRcsNetworkRegType = AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
+ mLastSuccessfulCapabilities.clear();
+ mPendingPublishCapabilities = null;
return changed;
}
@@ -373,19 +391,6 @@ public class DeviceCapabilityInfo {
}
/**
- * Update airplane mode state.
- * @return {@code true} if the airplane mode is changed, {@code false} otherwise.
- */
- public synchronized boolean updateAirplaneMode(boolean state) {
- if (mAirplaneMode != state) {
- logd("Airplane mode changes from " + mAirplaneMode + " to " + state);
- mAirplaneMode = state;
- return true;
- }
- return false;
- }
-
- /**
* Update mobile data setting.
* @return {@code true} if the mobile data setting is changed, {@code false} otherwise.
*/
@@ -454,6 +459,67 @@ public class DeviceCapabilityInfo {
return mPresenceCapable;
}
+ // Get the device's capabilities with the PRESENCE mechanism.
+ public RcsContactUceCapability getChangedPresenceCapability(Context context) {
+ if (context == null) {
+ return null;
+ }
+ Set<ServiceDescription> capableFromReg =
+ mServiceCapRegTracker.copyRegistrationCapabilities();
+ if (isPresenceCapabilityChanged(capableFromReg)) {
+ RcsContactUceCapability rcsContactUceCapability = getPresenceCapabilities(context);
+ if (rcsContactUceCapability != null) {
+ mPendingPublishCapabilities = mServiceCapRegTracker.copyRegistrationCapabilities();
+ }
+ return rcsContactUceCapability;
+ }
+ return null;
+ }
+
+ public void setPresencePublishResult(boolean isSuccess) {
+ if (isSuccess) {
+ mLastSuccessfulCapabilities.clear();
+ if (mPendingPublishCapabilities != null) {
+ mLastSuccessfulCapabilities.addAll(mPendingPublishCapabilities);
+ }
+ }
+ mPendingPublishCapabilities = null;
+ }
+
+ public void resetPresenceCapability() {
+ mLastSuccessfulCapabilities.clear();
+ mPendingPublishCapabilities = null;
+ }
+
+ public List<RcsContactPresenceTuple> getLastSuccessfulPresenceTuplesWithoutContactUri() {
+ List<RcsContactPresenceTuple> presenceTuples = new ArrayList<>();
+ if (mLastSuccessfulCapabilities.isEmpty()) {
+ return presenceTuples;
+ }
+
+ for (ServiceDescription capability : mLastSuccessfulCapabilities) {
+ presenceTuples.add(capability.getTupleBuilder().build());
+ }
+ return presenceTuples;
+ }
+
+ @VisibleForTesting
+ public void addLastSuccessfulServiceDescription(ServiceDescription capability) {
+ mLastSuccessfulCapabilities.add(capability);
+ }
+
+ @VisibleForTesting
+ public boolean isPresenceCapabilityChanged(Set<ServiceDescription> capableFromReg) {
+ if (mLastSuccessfulCapabilities.isEmpty()) {
+ return true;
+ }
+
+ if (capableFromReg.equals(mLastSuccessfulCapabilities)) {
+ return false;
+ }
+ return true;
+ }
+
private boolean isVolteAvailable(int networkRegType, MmTelCapabilities capabilities) {
return (networkRegType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
&& capabilities.isCapable(MmTelFeature.MmTelCapabilities.CAPABILITY_TYPE_VOICE);
@@ -486,7 +552,12 @@ public class DeviceCapabilityInfo {
@CapabilityMechanism int mechanism, Context context) {
switch (mechanism) {
case RcsContactUceCapability.CAPABILITY_MECHANISM_PRESENCE:
- return getPresenceCapabilities(context);
+ RcsContactUceCapability rcsContactUceCapability = getPresenceCapabilities(context);
+ if (rcsContactUceCapability != null) {
+ mPendingPublishCapabilities =
+ mServiceCapRegTracker.copyRegistrationCapabilities();
+ }
+ return rcsContactUceCapability;
case RcsContactUceCapability.CAPABILITY_MECHANISM_OPTIONS:
return getOptionsCapabilities(context);
default:
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 442cf7da..b58f7ec6 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
@@ -162,6 +162,8 @@ public class DeviceCapabilityListener {
public void sendImsUnregisteredMessage() {
logd("sendImsUnregisteredMessage");
+ // The IMS has been unregistered. Remove the existing message not processed.
+ removeMessages(EVENT_REQUEST_PUBLISH);
// Remove the existing message and resend a new message.
removeMessages(EVENT_IMS_UNREGISTERED);
Message msg = obtainMessage(EVENT_IMS_UNREGISTERED);
@@ -272,9 +274,9 @@ public class DeviceCapabilityListener {
private void registerReceivers() {
logd("registerReceivers");
IntentFilter filter = new IntentFilter();
- filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
filter.addAction(TelecomManager.ACTION_TTY_PREFERRED_MODE_CHANGED);
- mContext.registerReceiver(mReceiver, filter);
+ mContext.registerReceiver(mReceiver, filter, android.Manifest.permission.MODIFY_PHONE_STATE,
+ null, Context.RECEIVER_EXPORTED);
ContentResolver resolver = mContext.getContentResolver();
if (resolver != null) {
@@ -389,11 +391,6 @@ public class DeviceCapabilityListener {
TelecomManager.TTY_MODE_OFF);
handleTtyPreferredModeChanged(preferredMode);
break;
-
- case Intent.ACTION_AIRPLANE_MODE_CHANGED:
- boolean airplaneMode = intent.getBooleanExtra("state", false);
- handleAirplaneModeChanged(airplaneMode);
- break;
}
}
};
@@ -492,7 +489,7 @@ public class DeviceCapabilityListener {
public void onSubscriberAssociatedUriChanged(Uri[] uris) {
synchronized (mLock) {
logi("onRcsSubscriberAssociatedUriChanged");
- handleRcsSubscriberAssociatedUriChanged(uris, true);
+ handleRcsSubscriberAssociatedUriChanged(uris, false);
}
}
};
@@ -523,7 +520,7 @@ public class DeviceCapabilityListener {
public void onSubscriberAssociatedUriChanged(Uri[] uris) {
synchronized (mLock) {
logi("onMmTelSubscriberAssociatedUriChanged");
- handleMmTelSubscriberAssociatedUriChanged(uris, true);
+ handleMmTelSubscriberAssociatedUriChanged(uris, false);
}
}
};
@@ -571,15 +568,6 @@ public class DeviceCapabilityListener {
}
}
- private void handleAirplaneModeChanged(boolean state) {
- boolean isChanged = mCapabilityInfo.updateAirplaneMode(state);
- logi("Airplane mode changed: " + state + ", isChanged="+ isChanged);
- if (isChanged) {
- mHandler.sendTriggeringPublishMessage(
- PublishController.PUBLISH_TRIGGER_AIRPLANE_MODE_CHANGE);
- }
- }
-
private void handleMobileDataChanged(boolean isEnabled) {
boolean isChanged = mCapabilityInfo.updateMobileData(isEnabled);
logi("Mobile data changed: " + isEnabled + ", isChanged=" + isChanged);
@@ -602,18 +590,18 @@ public class DeviceCapabilityListener {
* This method is called when the MMTEL is registered.
*/
private void handleImsMmtelRegistered(int imsTransportType) {
+ // update capability, but not trigger PUBLISH message.
+ // PUBLISH message will be sent when the Capability status changed callback is called.
mCapabilityInfo.updateImsMmtelRegistered(imsTransportType);
- mHandler.sendTriggeringPublishMessage(
- PublishController.PUBLISH_TRIGGER_MMTEL_REGISTERED);
}
/*
* This method is called when the MMTEL is unregistered.
*/
private void handleImsMmtelUnregistered() {
- mCapabilityInfo.updateImsMmtelUnregistered();
+ boolean hasChanged = mCapabilityInfo.updateImsMmtelUnregistered();
// When the MMTEL is unregistered, the mmtel associated uri should be cleared.
- handleMmTelSubscriberAssociatedUriChanged(null, false);
+ handleMmTelSubscriberAssociatedUriChanged(null, hasChanged);
// If the RCS is already unregistered, it informs that the IMS is unregistered.
if (mCapabilityInfo.isImsRegistered() == false) {
@@ -624,16 +612,17 @@ public class DeviceCapabilityListener {
/*
* This method is called when the MMTEL associated uri has changed.
*/
- private void handleMmTelSubscriberAssociatedUriChanged(Uri[] uris, boolean triggerPublish) {
+ private void handleMmTelSubscriberAssociatedUriChanged(Uri[] uris, boolean regiChanged) {
Uri originalUri = mCapabilityInfo.getMmtelAssociatedUri();
mCapabilityInfo.updateMmTelAssociatedUri(uris);
Uri currentUri = mCapabilityInfo.getMmtelAssociatedUri();
- boolean hasChanged = !(Objects.equals(originalUri, currentUri));
- logi("handleMmTelSubscriberAssociatedUriChanged: triggerPublish=" + triggerPublish +
- ", hasChanged=" + hasChanged);
+ boolean hasChanged = regiChanged || !(Objects.equals(originalUri, currentUri));
- if (triggerPublish && hasChanged) {
+ logi("handleMmTelSubscriberAssociatedUriChanged: hasChanged=" + hasChanged);
+
+ // Send internal request to send a modification PUBLISH if the MMTEL or RCS is registered.
+ if (mCapabilityInfo.isImsRegistered() && hasChanged) {
mHandler.sendTriggeringPublishMessage(
PublishController.PUBLISH_TRIGGER_MMTEL_URI_CHANGE);
}
@@ -663,7 +652,7 @@ public class DeviceCapabilityListener {
private void handleImsRcsUnregistered() {
boolean hasChanged = mCapabilityInfo.updateImsRcsUnregistered();
// When the RCS is unregistered, the rcs associated uri should be cleared.
- handleRcsSubscriberAssociatedUriChanged(null, false);
+ handleRcsSubscriberAssociatedUriChanged(null, hasChanged);
// If the MMTEL is already unregistered, it informs that the IMS is unregistered.
if (mCapabilityInfo.isImsRegistered() == false) {
mHandler.sendImsUnregisteredMessage();
@@ -673,16 +662,17 @@ public class DeviceCapabilityListener {
/*
* This method is called when the RCS associated uri has changed.
*/
- private void handleRcsSubscriberAssociatedUriChanged(Uri[] uris, boolean triggerPublish) {
+ private void handleRcsSubscriberAssociatedUriChanged(Uri[] uris, boolean regiChanged) {
Uri originalUri = mCapabilityInfo.getRcsAssociatedUri();
mCapabilityInfo.updateRcsAssociatedUri(uris);
Uri currentUri = mCapabilityInfo.getRcsAssociatedUri();
- boolean hasChanged = !(Objects.equals(originalUri, currentUri));
- logi("handleRcsSubscriberAssociatedUriChanged: triggerPublish=" + triggerPublish +
- ", hasChanged=" + hasChanged);
+ boolean hasChanged = regiChanged || !(Objects.equals(originalUri, currentUri));
+
+ logi("handleRcsSubscriberAssociatedUriChanged: hasChanged=" + hasChanged);
- if (triggerPublish && hasChanged) {
+ // Send internal request to send a modification PUBLISH if the MMTEL or RCS is registered.
+ if (mCapabilityInfo.isImsRegistered() && hasChanged) {
mHandler.sendTriggeringPublishMessage(PublishController.PUBLISH_TRIGGER_RCS_URI_CHANGE);
}
}
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 b20f5ceb..732a558b 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
@@ -18,9 +18,11 @@ package com.android.ims.rcs.uce.presence.publish;
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.RcsContactUceCapability.CapabilityMechanism;
import android.telephony.ims.RcsUceAdapter.PublishState;
+import android.telephony.ims.SipDetails;
import android.telephony.ims.aidl.IRcsUcePublishStateCallback;
import com.android.ims.rcs.uce.ControllerBase;
@@ -45,53 +47,49 @@ public interface PublishController extends ControllerBase {
/** Publish trigger type: TTY preferred changes */
int PUBLISH_TRIGGER_TTY_PREFERRED_CHANGE = 3;
- /** Publish trigger type: Airplane mode changes */
- int PUBLISH_TRIGGER_AIRPLANE_MODE_CHANGE = 4;
-
/** Publish trigger type: Mobile data changes */
- int PUBLISH_TRIGGER_MOBILE_DATA_CHANGE = 5;
+ int PUBLISH_TRIGGER_MOBILE_DATA_CHANGE = 4;
/** Publish trigger type: VT setting changes */
- int PUBLISH_TRIGGER_VT_SETTING_CHANGE = 6;
+ int PUBLISH_TRIGGER_VT_SETTING_CHANGE = 5;
/** Publish trigger type: MMTEL registered */
- int PUBLISH_TRIGGER_MMTEL_REGISTERED = 7;
+ int PUBLISH_TRIGGER_MMTEL_REGISTERED = 6;
/** Publish trigger type: MMTEL unregistered */
- int PUBLISH_TRIGGER_MMTEL_UNREGISTERED = 8;
+ int PUBLISH_TRIGGER_MMTEL_UNREGISTERED = 7;
/** Publish trigger type: MMTEL capability changes */
- int PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE = 9;
+ int PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE = 8;
/** Publish trigger type: MMTEL associated uri changes */
- int PUBLISH_TRIGGER_MMTEL_URI_CHANGE = 10;
+ int PUBLISH_TRIGGER_MMTEL_URI_CHANGE = 9;
/** Publish trigger type: RCS registered */
- int PUBLISH_TRIGGER_RCS_REGISTERED = 11;
+ int PUBLISH_TRIGGER_RCS_REGISTERED = 10;
/** Publish trigger type: RCS unregistered */
- int PUBLISH_TRIGGER_RCS_UNREGISTERED = 12;
+ int PUBLISH_TRIGGER_RCS_UNREGISTERED = 11;
/** Publish trigger type: RCS associated uri changes */
- int PUBLISH_TRIGGER_RCS_URI_CHANGE = 13;
+ int PUBLISH_TRIGGER_RCS_URI_CHANGE = 12;
/** Publish trigger type: provisioning changes */
- int PUBLISH_TRIGGER_PROVISIONING_CHANGE = 14;
+ int PUBLISH_TRIGGER_PROVISIONING_CHANGE = 13;
/**The caps have been overridden for a test*/
- int PUBLISH_TRIGGER_OVERRIDE_CAPS = 15;
+ int PUBLISH_TRIGGER_OVERRIDE_CAPS = 14;
/** The Carrier Config for the subscription has Changed **/
- int PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED = 16;
+ int PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED = 15;
/** MMTEL and RCS are unregistered. **/
- int PUBLISH_TRIGGER_MMTEL_RCS_UNREGISTERED = 17;
+ int PUBLISH_TRIGGER_MMTEL_RCS_UNREGISTERED = 16;
@IntDef(value = {
PUBLISH_TRIGGER_SERVICE,
PUBLISH_TRIGGER_RETRY,
PUBLISH_TRIGGER_TTY_PREFERRED_CHANGE,
- PUBLISH_TRIGGER_AIRPLANE_MODE_CHANGE,
PUBLISH_TRIGGER_MOBILE_DATA_CHANGE,
PUBLISH_TRIGGER_VT_SETTING_CHANGE,
PUBLISH_TRIGGER_MMTEL_REGISTERED,
@@ -142,7 +140,8 @@ public interface PublishController extends ControllerBase {
/**
* Update the publish request result.
*/
- void updatePublishRequestResult(int publishState, Instant updatedTimestamp, String pidfXml);
+ void updatePublishRequestResult(int publishState, Instant updatedTimestamp, String pidfXml,
+ SipDetails details);
/**
* Update the value of the publish throttle.
@@ -212,9 +211,7 @@ public interface PublishController extends ControllerBase {
/**
* Notify that the device's publish status have been changed.
*/
- void onPublishUpdated(int reasonCode, String reasonPhrase,
- int reasonHeaderCause, String reasonHeaderText);
-
+ void onPublishUpdated(@NonNull SipDetails details);
/**
* Retrieve the device's capabilities.
*/
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 034d9ac2..101aa810 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
@@ -16,7 +16,10 @@
package com.android.ims.rcs.uce.presence.publish;
+import static android.telephony.ims.RcsUceAdapter.PUBLISH_STATE_OK;
+
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
@@ -27,10 +30,13 @@ import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.telephony.CarrierConfigManager;
import android.telephony.ims.ImsException;
+import android.telephony.ims.PublishAttributes;
+import android.telephony.ims.RcsContactPresenceTuple;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.RcsContactUceCapability.CapabilityMechanism;
import android.telephony.ims.RcsUceAdapter;
import android.telephony.ims.RcsUceAdapter.PublishState;
+import android.telephony.ims.SipDetails;
import android.telephony.ims.aidl.IImsCapabilityCallback;
import android.telephony.ims.aidl.IRcsUcePublishStateCallback;
import android.telephony.ims.feature.RcsFeature.RcsImsCapabilities;
@@ -53,6 +59,7 @@ import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.time.Instant;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -198,7 +205,7 @@ public class PublishControllerImpl implements PublishController {
if (capabilityType == RcsImsCapabilities.CAPABILITY_TYPE_PRESENCE_UCE) {
return RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED;
} else if (capabilityType == RcsImsCapabilities.CAPABILITY_TYPE_OPTIONS_UCE) {
- return RcsUceAdapter.PUBLISH_STATE_OK;
+ return PUBLISH_STATE_OK;
} else {
return RcsUceAdapter.PUBLISH_STATE_OTHER_ERROR;
}
@@ -303,7 +310,7 @@ public class PublishControllerImpl implements PublishController {
boolean supportPublishingState) {
synchronized (mPublishStateLock) {
if (mIsDestroyedFlag) return;
- mPublishStateCallbacks.register(c, new Boolean(supportPublishingState));
+ mPublishStateCallbacks.register(c, Boolean.valueOf(supportPublishingState));
logd("registerPublishStateCallback: size="
+ mPublishStateCallbacks.getRegisteredCallbackCount());
}
@@ -363,11 +370,9 @@ public class PublishControllerImpl implements PublishController {
* Notify that the device's publish status have been changed.
*/
@Override
- public void onPublishUpdated(int reasonCode, String reasonPhrase,
- int reasonHeaderCause, String reasonHeaderText) {
+ public void onPublishUpdated(@NonNull SipDetails details) {
if (mIsDestroyedFlag) return;
- mPublishHandler.sendPublishUpdatedMessage(reasonCode, reasonPhrase, reasonHeaderCause,
- reasonHeaderText);
+ mPublishHandler.sendPublishUpdatedMessage(details);
}
@Override
@@ -412,9 +417,10 @@ public class PublishControllerImpl implements PublishController {
@Override
public void updatePublishRequestResult(@PublishState int state,
- Instant updatedTime, String pidfXml) {
+ Instant updatedTime, String pidfXml, SipDetails details) {
logd("updatePublishRequestResult: " + state + ", time=" + updatedTime);
- mPublishHandler.sendPublishStateChangedMessage(state, updatedTime, pidfXml);
+ mPublishHandler.sendPublishStateChangedMessage(state, updatedTime, pidfXml,
+ details);
}
@Override
@@ -514,9 +520,10 @@ public class PublishControllerImpl implements PublishController {
int newPublishState = (Integer) args.arg1;
Instant updatedTimestamp = (Instant) args.arg2;
String pidfXml = (String) args.arg3;
+ SipDetails details = (SipDetails) args.arg4;
args.recycle();
publishCtrl.handlePublishStateChangedMessage(newPublishState, updatedTimestamp,
- pidfXml);
+ pidfXml, details);
break;
}
case MSG_NOTIFY_CURRENT_PUBLISH_STATE:
@@ -566,14 +573,8 @@ public class PublishControllerImpl implements PublishController {
break;
case MSG_PUBLISH_UPDATED: {
- SomeArgs args = (SomeArgs) message.obj;
- int reasonCode = (Integer) args.arg1;
- String reasonPhrase = (String) args.arg2;
- int reasonHeaderCause = (Integer) args.arg3;
- String reasonHeaderText = (String) args.arg4;
- args.recycle();
- publishCtrl.handlePublishUpdatedMessage(reasonCode, reasonPhrase,
- reasonHeaderCause, reasonHeaderText);
+ SipDetails details = (SipDetails) message.obj;
+ publishCtrl.handlePublishUpdatedMessage(details);
break;
}
@@ -654,7 +655,7 @@ public class PublishControllerImpl implements PublishController {
* Send the message to notify the publish state is changed.
*/
public void sendPublishStateChangedMessage(@PublishState int publishState,
- @NonNull Instant updatedTimestamp, String pidfXml) {
+ @NonNull Instant updatedTimestamp, String pidfXml, SipDetails details) {
PublishControllerImpl publishCtrl = mPublishControllerRef.get();
if (publishCtrl == null) return;
if (publishCtrl.mIsDestroyedFlag) return;
@@ -663,6 +664,7 @@ public class PublishControllerImpl implements PublishController {
args.arg1 = publishState;
args.arg2 = updatedTimestamp;
args.arg3 = pidfXml;
+ args.arg4 = details;
Message message = obtainMessage();
message.what = MSG_PUBLISH_STATE_CHANGED;
message.obj = args;
@@ -689,20 +691,14 @@ public class PublishControllerImpl implements PublishController {
/**
* Send the message to notify the publish state is changed.
*/
- public void sendPublishUpdatedMessage(int reasonCode, String reasonPhrase,
- int reasonHeaderCause, String reasonHeaderText) {
+ public void sendPublishUpdatedMessage(@NonNull SipDetails details) {
PublishControllerImpl publishCtrl = mPublishControllerRef.get();
if (publishCtrl == null) return;
if (publishCtrl.mIsDestroyedFlag) return;
- SomeArgs args = SomeArgs.obtain();
- args.arg1 = reasonCode;
- args.arg2 = reasonPhrase;
- args.arg3 = reasonHeaderCause;
- args.arg4 = reasonHeaderText;
Message message = obtainMessage();
message.what = MSG_PUBLISH_UPDATED;
- message.obj = args;
+ message.obj = details;
sendMessage(message);
}
@@ -924,7 +920,7 @@ public class PublishControllerImpl implements PublishController {
// PUBLISH is enabled.
if (isPresencePublishEnabled()) {
handlePublishStateChangedMessage(RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED,
- Instant.now(), null /*pidfXml*/);
+ Instant.now(), null /*pidfXml*/, null /*SipDetails*/);
}
}
@@ -1011,7 +1007,8 @@ public class PublishControllerImpl implements PublishController {
// Update the publish state directly. Because this method is called in the
// handler thread already, the process of updating publish state does not need to be
// sent to the looper again.
- handlePublishStateChangedMessage(updatedPublishState, Instant.now(), null /*pidfxml*/);
+ handlePublishStateChangedMessage(updatedPublishState, Instant.now(), null /*pidfxml*/,
+ null /*SipDetails*/);
}
}
@@ -1040,7 +1037,7 @@ public class PublishControllerImpl implements PublishController {
* from original state.
*/
private void handlePublishStateChangedMessage(@PublishState int newPublishState,
- Instant updatedTimestamp, String pidfXml) {
+ Instant updatedTimestamp, String pidfXml, SipDetails details) {
synchronized (mPublishStateLock) {
if (mIsDestroyedFlag) return;
// Check if the time of the given publish state is not earlier than existing time.
@@ -1067,7 +1064,7 @@ public class PublishControllerImpl implements PublishController {
logd("Notify publish state changed: " + mCurrentPublishState);
mPublishStateCallbacks.broadcast(c -> {
try {
- c.onPublishStateChanged(mCurrentPublishState);
+ c.onPublishUpdated(getPublishAttributes(mCurrentPublishState, details));
} catch (RemoteException e) {
logw("Notify publish state changed error: " + e);
}
@@ -1075,11 +1072,25 @@ public class PublishControllerImpl implements PublishController {
logd("Notify publish state changed: completed");
}
+ private PublishAttributes getPublishAttributes(@PublishState int mCurrentPublishState,
+ SipDetails details) {
+ List<RcsContactPresenceTuple> tuples = null;
+ if (mCurrentPublishState == PUBLISH_STATE_OK) {
+ tuples = mDeviceCapabilityInfo.getLastSuccessfulPresenceTuplesWithoutContactUri();
+ }
+ if (tuples != null && !tuples.isEmpty()) {
+ return new PublishAttributes.Builder(mCurrentPublishState).setSipDetails(details)
+ .setPresenceTuples(tuples).build();
+ }
+ return new PublishAttributes.Builder(mCurrentPublishState).setSipDetails(details).build();
+ }
+
private void handleNotifyCurrentPublishStateMessage(IRcsUcePublishStateCallback callback,
boolean supportPublishingState) {
if (mIsDestroyedFlag || callback == null) return;
try {
- callback.onPublishStateChanged(getUcePublishState(supportPublishingState));
+ int publishState = getUcePublishState(supportPublishingState);
+ callback.onPublishUpdated(getPublishAttributes(publishState, null /*SipDetails*/));
} catch (RemoteException e) {
logw("handleCurrentPublishStateUpdateMessage exception: " + e);
}
@@ -1146,7 +1157,8 @@ public class PublishControllerImpl implements PublishController {
Instant updatedTimestamp) {
if (mIsDestroyedFlag) return;
mPublishProcessor.resetState();
- handlePublishStateChangedMessage(newPublishState, updatedTimestamp, null);
+ handlePublishStateChangedMessage(newPublishState, updatedTimestamp,
+ null /*pidfXml*/, null /*SipDetails*/);
}
private void handlePublishSentMessage() {
@@ -1170,20 +1182,22 @@ public class PublishControllerImpl implements PublishController {
mCurrentPublishState = RcsUceAdapter.PUBLISH_STATE_PUBLISHING;
if (isSupportPublishingState) {
if (callback != null) {
- callback.onPublishStateChanged(mCurrentPublishState);
+ callback.onPublishUpdated(getPublishAttributes(mCurrentPublishState,
+ null /*SipDetails*/));
}
} else {
// If it is currently PUBLISH_STATE_OK, the state must not be changed to
// PUBLISH_STATE_NOT_PUBLISHED.
// And in the case of the current PUBLISH_STATE_NOT_PUBLISHED, it is
// necessary to avoid reporting the duplicate state.
- if (tempPublishState != RcsUceAdapter.PUBLISH_STATE_OK
+ if (tempPublishState != PUBLISH_STATE_OK
&& tempPublishState != RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED) {
// set the state to PUBLISH_STATE_NOT_PUBLISHED so that
// getUcePublishState is consistent with the callback
mLastPublishState = RcsUceAdapter.PUBLISH_STATE_NOT_PUBLISHED;
if (callback != null) {
- callback.onPublishStateChanged(mLastPublishState);
+ callback.onPublishUpdated(getPublishAttributes(mLastPublishState,
+ null /*SipDetails*/));
}
}
}
@@ -1194,11 +1208,10 @@ public class PublishControllerImpl implements PublishController {
}
}
- private void handlePublishUpdatedMessage(int reasonCode, String reasonPhrase,
- int reasonHeaderCause, String reasonHeaderText) {
+ private void handlePublishUpdatedMessage(@NonNull SipDetails details) {
if (mIsDestroyedFlag) return;
PublishRequestResponse updatedPublish = new PublishRequestResponse(getLastPidfXml(),
- reasonCode, reasonPhrase, reasonHeaderCause, reasonHeaderText);
+ details);
mPublishProcessor.publishUpdated(updatedPublish);
}
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/PublishProcessor.java b/src/java/com/android/ims/rcs/uce/presence/publish/PublishProcessor.java
index d87eea9e..c239dd5a 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/PublishProcessor.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/PublishProcessor.java
@@ -22,6 +22,7 @@ import android.annotation.NonNull;
import android.content.Context;
import android.os.RemoteException;
import android.telephony.ims.RcsContactUceCapability;
+import android.telephony.ims.SipDetails;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.telephony.ims.stub.RcsCapabilityExchangeImplBase;
import android.text.TextUtils;
@@ -112,6 +113,8 @@ public class PublishProcessor {
logi("onRcsDisconnected");
mRcsFeatureManager = null;
mProcessorState.onRcsDisconnected();
+ // reset the publish capabilities.
+ mDeviceCapabilities.resetPresenceCapability();
}
/**
@@ -152,10 +155,15 @@ public class PublishProcessor {
}
// Get the latest device's capabilities.
- RcsContactUceCapability deviceCapability =
- mDeviceCapabilities.getDeviceCapabilities(CAPABILITY_MECHANISM_PRESENCE, mContext);
+ RcsContactUceCapability deviceCapability;
+ if (triggerType == PublishController.PUBLISH_TRIGGER_SERVICE) {
+ deviceCapability = mDeviceCapabilities.getDeviceCapabilities(
+ CAPABILITY_MECHANISM_PRESENCE, mContext);
+ } else {
+ deviceCapability = mDeviceCapabilities.getChangedPresenceCapability(mContext);
+ }
if (deviceCapability == null) {
- logw("doPublishInternal: device capability is null");
+ logi("doPublishInternal: device capability hasn't changed or is null");
return false;
}
@@ -349,6 +357,8 @@ public class PublishProcessor {
// Increase the retry count
mProcessorState.increaseRetryCount();
+ // reset the last capabilities because of the request is failed
+ mDeviceCapabilities.setPresencePublishResult(false);
// Reset the pending flag because it is going to resend a request.
clearPendingRequest();
@@ -373,15 +383,21 @@ public class PublishProcessor {
Instant responseTime = response.getResponseTimestamp();
// Record the time when the request is successful and reset the retry count.
+ boolean publishSuccess = false;
if (response.isRequestSuccess()) {
mProcessorState.setLastPublishedTime(responseTime);
mProcessorState.resetRetryCount();
+ publishSuccess = true;
}
+ // set the last capabilities according to the result of request.
+ mDeviceCapabilities.setPresencePublishResult(publishSuccess);
// Update the publish state after the request has finished.
int publishState = response.getPublishState();
String pidfXml = response.getPidfXml();
- mPublishCtrlCallback.updatePublishRequestResult(publishState, responseTime, pidfXml);
+ SipDetails details = response.getSipDetails().orElse(null);
+ mPublishCtrlCallback.updatePublishRequestResult(publishState, responseTime, pidfXml,
+ details);
// Refresh the device state with the publish request result.
response.getResponseSipCode().ifPresent(sipCode -> {
@@ -492,6 +508,8 @@ public class PublishProcessor {
*/
public void resetState() {
mProcessorState.resetState();
+ // reset the publish capabilities.
+ mDeviceCapabilities.resetPresenceCapability();
}
/**
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/PublishRequestResponse.java b/src/java/com/android/ims/rcs/uce/presence/publish/PublishRequestResponse.java
index 47aa37c3..aa1b27c1 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/PublishRequestResponse.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/PublishRequestResponse.java
@@ -16,8 +16,10 @@
package com.android.ims.rcs.uce.presence.publish;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.telephony.ims.RcsUceAdapter;
+import android.telephony.ims.SipDetails;
import android.telephony.ims.aidl.IPublishResponseCallback;
import android.telephony.ims.stub.RcsCapabilityExchangeImplBase;
import android.text.TextUtils;
@@ -47,7 +49,7 @@ public class PublishRequestResponse {
private Optional<String> mReasonPhrase;
private Optional<Integer> mReasonHeaderCause;
private Optional<String> mReasonHeaderText;
-
+ private Optional<SipDetails> mSipDetails;
// The timestamp when receive the response from the network.
private Instant mResponseTimestamp;
@@ -61,29 +63,29 @@ public class PublishRequestResponse {
mReasonPhrase = Optional.empty();
mReasonHeaderCause = Optional.empty();
mReasonHeaderText = Optional.empty();
+ mSipDetails = Optional.empty();
}
- public PublishRequestResponse(String pidfXml, int sipCode, String reasonPhrase,
- int reasonHeaderCause, String reasonHeaderText) {
+ public PublishRequestResponse(String pidfXml, @Nullable SipDetails details) {
mTaskId = 0L;
mPublishCtrlCallback = null;
mCmdErrorCode = Optional.empty();
mPidfXml = pidfXml;
mResponseTimestamp = Instant.now();
- mNetworkRespSipCode = Optional.of(sipCode);
- mReasonPhrase = Optional.ofNullable(reasonPhrase);
- if (reasonHeaderCause != 0) {
- mReasonHeaderCause = Optional.of(reasonHeaderCause);
+ mNetworkRespSipCode = Optional.of(details.getResponseCode());
+ mReasonPhrase = Optional.ofNullable(details.getResponsePhrase());
+ if (details.getReasonHeaderCause() != 0) {
+ mReasonHeaderCause = Optional.of(details.getReasonHeaderCause());
} else {
mReasonHeaderCause = Optional.empty();
}
- if (TextUtils.isEmpty(reasonHeaderText)) {
+ if (TextUtils.isEmpty(details.getReasonHeaderText())) {
mReasonHeaderText = Optional.empty();
} else {
- mReasonHeaderText = Optional.ofNullable(reasonHeaderText);
+ mReasonHeaderText = Optional.ofNullable(details.getReasonHeaderText());
}
-
+ mSipDetails = Optional.ofNullable(details);
}
// The result callback of the publish capability request.
@@ -94,15 +96,8 @@ public class PublishRequestResponse {
}
@Override
- public void onNetworkResponse(int code, String reason) {
- PublishRequestResponse.this.onNetworkResponse(code, reason);
- }
-
- @Override
- public void onNetworkRespHeader(int code, String reasonPhrase, int reasonHeaderCause,
- String reasonHeaderText) {
- PublishRequestResponse.this.onNetworkResponse(code, reasonPhrase, reasonHeaderCause,
- reasonHeaderText);
+ public void onNetworkResponse(@NonNull SipDetails details) {
+ PublishRequestResponse.this.onNetworkResponse(details);
}
};
@@ -150,6 +145,12 @@ public class PublishRequestResponse {
}
/**
+ * Retrieve the sip information which received from the network.
+ */
+ public Optional<SipDetails> getSipDetails() {
+ return mSipDetails;
+ }
+ /**
* Retrieve the SIP code from the network response. It will get the value from the Reason
* Header first. If the ReasonHeader is not present, it will get the value from the Network
* response instead.
@@ -198,49 +199,34 @@ public class PublishRequestResponse {
}
}
- private void onNetworkResponse(int sipCode, String reason) {
+ private void onNetworkResponse(@NonNull SipDetails details) {
// When we send a request to PUBLISH and there is no change to the UCE capabilities, we
// expected onCommandError() with COMMAND_CODE_NO_CHANGE.
// But some of the vendor will instead send SIP code 999.
- if (sipCode == 999) {
+ if (details.getResponseCode() == 999) {
onCommandError(RcsCapabilityExchangeImplBase.COMMAND_CODE_NO_CHANGE);
return;
}
mResponseTimestamp = Instant.now();
- mNetworkRespSipCode = Optional.of(sipCode);
- mReasonPhrase = Optional.ofNullable(reason);
- updateRetryFlagByNetworkResponse();
-
- PublishControllerCallback ctrlCallback = mPublishCtrlCallback;
- if (ctrlCallback != null) {
- ctrlCallback.onRequestNetworkResp(this);
- } else {
- Log.d(LOG_TAG, "onNetworkResponse: already destroyed. sip code=" + sipCode);
+ mNetworkRespSipCode = Optional.of(details.getResponseCode());
+ mReasonPhrase = Optional.ofNullable(details.getResponsePhrase());
+ if (details.getReasonHeaderCause() != 0) {
+ mReasonHeaderCause = Optional.of(details.getReasonHeaderCause());
}
- }
-
- private void onNetworkResponse(int sipCode, String reasonPhrase, int reasonHeaderCause,
- String reasonHeaderText) {
- // When we send a request to PUBLISH and there is no change to the UCE capabilities, we
- // expected onCommandError() with COMMAND_CODE_NO_CHANGE.
- // But some of the vendor will instead send SIP code 999.
- if (sipCode == 999) {
- onCommandError(RcsCapabilityExchangeImplBase.COMMAND_CODE_NO_CHANGE);
- return;
+ if (TextUtils.isEmpty(details.getReasonHeaderText())) {
+ mReasonHeaderText = Optional.empty();
+ } else {
+ mReasonHeaderText = Optional.ofNullable(details.getReasonHeaderText());
}
- mResponseTimestamp = Instant.now();
- mNetworkRespSipCode = Optional.of(sipCode);
- mReasonPhrase = Optional.ofNullable(reasonPhrase);
- mReasonHeaderCause = Optional.of(reasonHeaderCause);
- mReasonHeaderText = Optional.ofNullable(reasonHeaderText);
+ mSipDetails = Optional.ofNullable(details);
updateRetryFlagByNetworkResponse();
PublishControllerCallback ctrlCallback = mPublishCtrlCallback;
if (ctrlCallback != null) {
ctrlCallback.onRequestNetworkResp(this);
} else {
- Log.d(LOG_TAG, "onNetworkResponse: already destroyed. sipCode=" + sipCode +
- ", reasonHeader=" + reasonHeaderCause);
+ Log.d(LOG_TAG, "onNetworkResponse: already destroyed. sip code="
+ + details.getResponseCode());
}
}
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/PublishServiceDescTracker.java b/src/java/com/android/ims/rcs/uce/presence/publish/PublishServiceDescTracker.java
index a107b1ad..7f7ea3e6 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/PublishServiceDescTracker.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/PublishServiceDescTracker.java
@@ -53,7 +53,7 @@ public class PublishServiceDescTracker {
*/
private static final Map<ServiceDescription, Set<String>> DEFAULT_SERVICE_DESCRIPTION_MAP;
static {
- ArrayMap<ServiceDescription, Set<String>> map = new ArrayMap<>(21);
+ ArrayMap<ServiceDescription, Set<String>> map = new ArrayMap<>(23);
map.put(ServiceDescription.SERVICE_DESCRIPTION_CHAT_IM,
Collections.singleton(FeatureTags.FEATURE_TAG_CHAT_IM));
map.put(ServiceDescription.SERVICE_DESCRIPTION_CHAT_SESSION,
@@ -111,6 +111,14 @@ public class PublishServiceDescTracker {
FeatureTags.FEATURE_TAG_CHATBOT_VERSION_V2_SUPPORTED)));
map.put(ServiceDescription.SERVICE_DESCRIPTION_CHATBOT_ROLE,
Collections.singleton(FeatureTags.FEATURE_TAG_CHATBOT_ROLE));
+ map.put(ServiceDescription.SERVICE_DESCRIPTION_SLM, new ArraySet<>(
+ Arrays.asList(FeatureTags.FEATURE_TAG_PAGER_MODE,
+ FeatureTags.FEATURE_TAG_LARGE_MODE,
+ FeatureTags.FEATURE_TAG_DEFERRED_MESSAGING,
+ FeatureTags.FEATURE_TAG_LARGE_PAGER_MODE)));
+ map.put(ServiceDescription.SERVICE_DESCRIPTION_SLM_PAGER_LARGE, new ArraySet<>(
+ Arrays.asList(FeatureTags.FEATURE_TAG_PAGER_MODE,
+ FeatureTags.FEATURE_TAG_LARGE_MODE)));
DEFAULT_SERVICE_DESCRIPTION_MAP = Collections.unmodifiableMap(map);
}
diff --git a/src/java/com/android/ims/rcs/uce/presence/publish/ServiceDescription.java b/src/java/com/android/ims/rcs/uce/presence/publish/ServiceDescription.java
index 0f271e1c..e175f2a4 100644
--- a/src/java/com/android/ims/rcs/uce/presence/publish/ServiceDescription.java
+++ b/src/java/com/android/ims/rcs/uce/presence/publish/ServiceDescription.java
@@ -169,6 +169,20 @@ public class ServiceDescription {
null /*description*/
);
+ public static final ServiceDescription SERVICE_DESCRIPTION_SLM =
+ new ServiceDescription(
+ RcsContactPresenceTuple.SERVICE_ID_SLM,
+ "2.0" /*version*/,
+ null /*description*/
+ );
+
+ public static final ServiceDescription SERVICE_DESCRIPTION_SLM_PAGER_LARGE =
+ new ServiceDescription(
+ RcsContactPresenceTuple.SERVICE_ID_SLM,
+ "2.0" /*version*/,
+ "Standalone Messaging" /*description*/
+ );
+
/** Mandatory "service-id" element */
public final @NonNull String serviceId;
/** Mandatory "version" element */