Skip to content

Commit

Permalink
[RCS UCE] Support the capabilities request with OPTIONS mechanism.
Browse files Browse the repository at this point in the history
Bug: 174166957
Test: atest CtsTelephonyTestCases
Change-Id: I8663e8f7d686eb75fc2605282c8378185b5bda45
  • Loading branch information
James.cf Lin authored and Brad Ebinger committed Feb 16, 2021
1 parent 093382b commit 14b6caa
Show file tree
Hide file tree
Showing 23 changed files with 998 additions and 100 deletions.
10 changes: 10 additions & 0 deletions src/java/com/android/ims/RcsFeatureConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.telephony.ims.aidl.IImsRegistration;
import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IPublishResponseCallback;
import android.telephony.ims.aidl.IOptionsResponseCallback;
import android.telephony.ims.aidl.ISipTransport;
import android.telephony.ims.aidl.ISubscribeResponseCallback;
import android.telephony.ims.feature.CapabilityChangeRequest;
Expand Down Expand Up @@ -242,6 +243,15 @@ public void requestCapabilities(List<Uri> uris, ISubscribeResponseCallback c)
}
}

public void sendOptionsCapabilityRequest(Uri contactUri, List<String> myCapabilities,
IOptionsResponseCallback callback) throws RemoteException {
synchronized (mLock) {
checkServiceIsReady();
getServiceInterface(mBinder).sendOptionsCapabilityRequest(contactUri, myCapabilities,
callback);
}
}

@Override
@VisibleForTesting
public Integer retrieveFeatureState() {
Expand Down
6 changes: 6 additions & 0 deletions src/java/com/android/ims/RcsFeatureManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import android.telephony.ims.aidl.IImsRegistration;
import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IOptionsRequestCallback;
import android.telephony.ims.aidl.IOptionsResponseCallback;
import android.telephony.ims.aidl.IPublishResponseCallback;
import android.telephony.ims.aidl.ISipTransport;
import android.telephony.ims.aidl.ISubscribeResponseCallback;
Expand Down Expand Up @@ -426,6 +427,11 @@ public void requestCapabilities(List<Uri> uris, ISubscribeResponseCallback c)
mRcsFeatureConnection.requestCapabilities(uris, c);
}

public void sendOptionsCapabilityRequest(Uri contactUri, List<String> myCapabilities,
IOptionsResponseCallback callback) throws RemoteException {
mRcsFeatureConnection.sendOptionsCapabilityRequest(contactUri, myCapabilities, callback);
}

/**
* Disable all of the UCE capabilities.
*/
Expand Down
35 changes: 10 additions & 25 deletions src/java/com/android/ims/rcs/uce/UceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.os.Looper;
import android.os.RemoteException;
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.RcsUceAdapter.StackPublishTriggerType;
Expand Down Expand Up @@ -86,7 +87,7 @@ public interface UceControllerCallback {
/**
* Retrieve the device's capabilities.
*/
RcsContactUceCapability getDeviceCapabilities();
RcsContactUceCapability getDeviceCapabilities(@CapabilityMechanism int mechanism);

/**
* The network reply that the request is forbidden.
Expand All @@ -109,13 +110,6 @@ void updateRequestForbidden(boolean isForbidden, @Nullable Integer errorCode,
*/
boolean isRequestForbiddenByNetwork();

/**
* Trigger the capabilities request with OPTIONS
*/
void requestCapabilitiesByOptions(@NonNull Uri contactUri,
@NonNull RcsContactUceCapability ownCapabilities,
@NonNull IOptionsResponseCallback callback);

/**
* The method is called when the given contacts' capabilities are expired and need to be
* refreshed.
Expand Down Expand Up @@ -172,8 +166,7 @@ PublishController createPublishController(Context context, int subId,
/**
* @return an {@link OptionsController} associated with the subscription id specified.
*/
OptionsController createOptionsController(Context context, int subId,
UceControllerCallback c, Looper looper);
OptionsController createOptionsController(Context context, int subId);
}

private ControllerFactory mControllerFactory = new ControllerFactory() {
Expand All @@ -195,9 +188,8 @@ public SubscribeController createSubscribeController(Context context, int subId)
}

@Override
public OptionsController createOptionsController(Context context, int subId,
UceControllerCallback c, Looper looper) {
return new OptionsControllerImpl(context, subId, c, looper);
public OptionsController createOptionsController(Context context, int subId) {
return new OptionsControllerImpl(context, subId);
}
};

Expand Down Expand Up @@ -254,14 +246,14 @@ private void initControllers() {
mPublishController = mControllerFactory.createPublishController(mContext, mSubId,
mCtrlCallback, mLooper);
mSubscribeController = mControllerFactory.createSubscribeController(mContext, mSubId);
mOptionsController = mControllerFactory.createOptionsController(mContext, mSubId,
mCtrlCallback, mLooper);
mOptionsController = mControllerFactory.createOptionsController(mContext, mSubId);
}

private void initRequestManager() {
mRequestManager = mRequestManagerFactory.createRequestManager(mContext, mSubId, mLooper,
mCtrlCallback);
mRequestManager.setSubscribeController(mSubscribeController);
mRequestManager.setOptionsController(mOptionsController);
}

/**
Expand Down Expand Up @@ -339,8 +331,8 @@ public void saveCapabilities(List<RcsContactUceCapability> contactCapabilities)
}

@Override
public RcsContactUceCapability getDeviceCapabilities() {
return mPublishController.getDeviceCapabilities();
public RcsContactUceCapability getDeviceCapabilities(@CapabilityMechanism int mechanism) {
return mPublishController.getDeviceCapabilities(mechanism);
}

@Override
Expand All @@ -359,13 +351,6 @@ public boolean isRequestForbiddenByNetwork() {
return (mServerState.getForbiddenErrorCode() != null) ? true : false;
}

@Override
public void requestCapabilitiesByOptions(@NonNull Uri uri,
@NonNull RcsContactUceCapability ownCapabilities,
@NonNull IOptionsResponseCallback callback) {
mOptionsController.sendCapabilitiesRequest(uri, ownCapabilities, callback);
}

@Override
public void refreshCapabilities(@NonNull List<Uri> contactNumbers,
@NonNull IRcsUceControllerCallback callback) throws RemoteException{
Expand Down Expand Up @@ -520,7 +505,7 @@ public void onUnpublish() {
public void retrieveOptionsCapabilitiesForRemote(@NonNull Uri contactUri,
@NonNull List<String> remoteCapabilities, @NonNull IOptionsRequestCallback c) {
logi("retrieveOptionsCapabilitiesForRemote");
mOptionsController.retrieveCapabilitiesForRemote(contactUri, remoteCapabilities, c);
mRequestManager.retrieveCapabilitiesForRemote(contactUri, remoteCapabilities, c);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/java/com/android/ims/rcs/uce/eab/EabUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.android.ims.rcs.uce.eab.EabProvider.ContactColumns;
import com.android.ims.rcs.uce.eab.EabProvider.EabCommonColumns;
import com.android.ims.rcs.uce.eab.EabProvider.OptionsColumns;
import com.android.ims.rcs.uce.eab.EabProvider.PresenceTupleColumns;
import com.android.ims.rcs.uce.util.UceUtils;

Expand Down Expand Up @@ -144,6 +145,8 @@ private static int removeContactCapabilities(int contactId, int commonId, Contex
int count = 0;
count = context.getContentResolver().delete(EabProvider.PRESENCE_URI,
PresenceTupleColumns.EAB_COMMON_ID + "=?", new String[]{String.valueOf(commonId)});
context.getContentResolver().delete(EabProvider.OPTIONS_URI,
OptionsColumns.EAB_COMMON_ID + "=?", new String[]{String.valueOf(commonId)});
context.getContentResolver().delete(EabProvider.COMMON_URI,
EabCommonColumns.EAB_CONTACT_ID + "=?", new String[]{String.valueOf(contactId)});
context.getContentResolver().delete(EabProvider.CONTACT_URI,
Expand Down
19 changes: 7 additions & 12 deletions src/java/com/android/ims/rcs/uce/options/OptionsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

import android.annotation.NonNull;
import android.net.Uri;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.aidl.IOptionsRequestCallback;
import android.os.RemoteException;
import android.telephony.ims.aidl.IOptionsResponseCallback;

import com.android.ims.rcs.uce.ControllerBase;
Expand All @@ -31,15 +30,11 @@
*/
public interface OptionsController extends ControllerBase {
/**
* Request the capabilities for the requested contact.
* Request the contact's capabilities of the given contact.
* @param contactUri The contact of the capabilities is being requested for.
* @param deviceFeatureTags The feature tags of the device's capabilities.
* @param c The response callback of the OPTIONS capabilities request.
*/
void sendCapabilitiesRequest(@NonNull Uri contactUri,
@NonNull RcsContactUceCapability ownCapabilities, @NonNull IOptionsResponseCallback c);

/**
* Retrieve the device's capabilities. This request is from the ImsService to send the
* capabilities to the remote side.
*/
void retrieveCapabilitiesForRemote(@NonNull Uri contactUri,
@NonNull List<String> remoteCapabilities, @NonNull IOptionsRequestCallback c);
void sendCapabilitiesRequest(@NonNull Uri contactUri, @NonNull List<String> deviceFeatureTags,
@NonNull IOptionsResponseCallback c) throws RemoteException;
}
53 changes: 30 additions & 23 deletions src/java/com/android/ims/rcs/uce/options/OptionsControllerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

package com.android.ims.rcs.uce.options;

import android.annotation.NonNull;
import android.content.Context;
import android.net.Uri;
import android.os.Looper;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.aidl.IOptionsRequestCallback;
import android.os.RemoteException;
import android.telephony.ims.aidl.IOptionsResponseCallback;
import android.telephony.ims.stub.RcsCapabilityExchangeImplBase;
import android.util.Log;

import com.android.ims.RcsFeatureManager;
import com.android.ims.rcs.uce.UceController.UceControllerCallback;
import com.android.ims.rcs.uce.util.UceUtils;

import java.util.List;

Expand All @@ -33,43 +34,49 @@
*/
public class OptionsControllerImpl implements OptionsController {

private final Context mContext;
private static final String LOG_TAG = UceUtils.getLogPrefix() + "OptionsController";

private final int mSubId;
private final UceControllerCallback mCallback;
private final Looper mLooper;
private final Context mContext;
private volatile boolean mIsDestroyedFlag;
private volatile RcsFeatureManager mRcsFeatureManager;

public OptionsControllerImpl(Context context, int subId, UceControllerCallback c,
Looper looper) {
mContext = context;
public OptionsControllerImpl(Context context, int subId) {
mSubId = subId;
mCallback = c;
mLooper = looper;
mContext = context;
}

@Override
public void onRcsConnected(RcsFeatureManager manager) {
// TODO: Implement this method
mRcsFeatureManager = manager;
}

@Override
public void onRcsDisconnected() {
// TODO: Implement this method
mRcsFeatureManager = null;
}

@Override
public void onDestroy() {
// TODO: Implement this method
mIsDestroyedFlag = true;
mRcsFeatureManager = null;
}

@Override
public void sendCapabilitiesRequest(Uri contactUri, RcsContactUceCapability ownCapabilities,
IOptionsResponseCallback c) {
// TODO: Implement this method
}
public void sendCapabilitiesRequest(Uri contactUri, @NonNull List<String> deviceFeatureTags,
IOptionsResponseCallback c) throws RemoteException {

@Override
public void retrieveCapabilitiesForRemote(Uri contactUri, List<String> remoteCapabilities,
IOptionsRequestCallback c) {
// TODO: Implement this method
if (mIsDestroyedFlag) {
throw new RemoteException("OPTIONS controller is destroyed");
}

RcsFeatureManager featureManager = mRcsFeatureManager;
if (featureManager == null) {
Log.w(LOG_TAG, "sendCapabilitiesRequest: Service is unavailable");
c.onCommandError(RcsCapabilityExchangeImplBase.COMMAND_CODE_SERVICE_UNAVAILABLE);
return;
}

featureManager.sendOptionsCapabilityRequest(contactUri, deviceFeatureTags, c);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import android.telephony.ims.RcsContactPresenceTuple;
import android.telephony.ims.RcsContactPresenceTuple.ServiceCapabilities;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.RcsContactUceCapability.CapabilityMechanism;
import android.telephony.ims.RcsContactUceCapability.OptionsBuilder;
import android.telephony.ims.RcsContactUceCapability.PresenceBuilder;
import android.telephony.ims.feature.MmTelFeature;
import android.telephony.ims.feature.MmTelFeature.MmTelCapabilities;
import android.util.Log;

import com.android.ims.rcs.uce.util.FeatureTags;
import com.android.ims.rcs.uce.util.UceUtils;

/**
Expand Down Expand Up @@ -259,14 +262,28 @@ private boolean isCallComposerAvailable(MmTelCapabilities capabilities) {
/**
* Get the device's capabilities.
*/
public synchronized RcsContactUceCapability getDeviceCapabilities(Context context) {
Uri uri = PublishUtils.getPublishingUri(context, mSubId);
public synchronized RcsContactUceCapability getDeviceCapabilities(
@CapabilityMechanism int mechanism, Context context) {
switch (mechanism) {
case RcsContactUceCapability.CAPABILITY_MECHANISM_PRESENCE:
return getPresenceCapabilities(context);
case RcsContactUceCapability.CAPABILITY_MECHANISM_OPTIONS:
return getOptionsCapabilities(context);
default:
logw("getDeviceCapabilities: invalid mechanism " + mechanism);
return null;
}
}

// Get the device's capabilities with the PRESENCE mechanism.
private RcsContactUceCapability getPresenceCapabilities(Context context) {
Uri uri = PublishUtils.getDeviceContactUri(context, mSubId);
if (uri == null) {
logw("getDeviceCapabilities: uri is empty");
logw("getPresenceCapabilities: uri is empty");
return null;
}
ServiceCapabilities.Builder servCapsBuilder = new ServiceCapabilities.Builder(
hasVolteCapability(), hasVtCapability());
hasVolteCapability(), hasVtCapability());
servCapsBuilder.addSupportedDuplexMode(ServiceCapabilities.DUPLEX_MODE_FULL);

RcsContactPresenceTuple.Builder tupleBuilder = new RcsContactPresenceTuple.Builder(
Expand All @@ -292,6 +309,21 @@ public synchronized RcsContactUceCapability getDeviceCapabilities(Context contex
return presenceBuilder.build();
}

// Get the device's capabilities with the OPTIONS mechanism.
private RcsContactUceCapability getOptionsCapabilities(Context context) {
Uri uri = PublishUtils.getDeviceContactUri(context, mSubId);
if (uri == null) {
logw("getOptionsCapabilities: uri is empty");
return null;
}

OptionsBuilder optionsBuilder = new OptionsBuilder(uri);
optionsBuilder.setRequestResult(RcsContactUceCapability.REQUEST_RESULT_FOUND);
FeatureTags.addMmTelFeatureTags(optionsBuilder,
hasVolteCapability(), hasVtCapability());
return optionsBuilder.build();
}

// Check if the device has the VoLTE capability
private synchronized boolean hasVolteCapability() {
if (mMmTelCapabilities != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.RcsContactUceCapability.CapabilityMechanism;
import android.telephony.ims.RcsUceAdapter.PublishState;
import android.telephony.ims.aidl.IRcsUcePublishStateCallback;

Expand Down Expand Up @@ -135,7 +136,7 @@ interface PublishControllerCallback {
/**
* Retrieve the device's capabilities.
*/
RcsContactUceCapability getDeviceCapabilities();
RcsContactUceCapability getDeviceCapabilities(@CapabilityMechanism int mechanism);

/**
* Publish the device's capabilities to the Presence server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.os.RemoteException;
import android.telephony.ims.ImsException;
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.aidl.IImsCapabilityCallback;
Expand Down Expand Up @@ -257,8 +258,8 @@ public void onUnpublish() {
}

@Override
public RcsContactUceCapability getDeviceCapabilities() {
return mDeviceCapabilityInfo.getDeviceCapabilities(mContext);
public RcsContactUceCapability getDeviceCapabilities(@CapabilityMechanism int mechanism) {
return mDeviceCapabilityInfo.getDeviceCapabilities(mechanism, mContext);
}

private void registerRcsAvailabilityChanged(RcsFeatureManager manager) {
Expand Down
Loading

0 comments on commit 14b6caa

Please sign in to comment.