Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0eafb70e authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Add the ability to return SipTransport implementation if capable

Bug: 154763999
Test: atest ImsCommonTests
Merged-In: Id72487917c804476f0e8f96e4ef9e98e48c5f237
Change-Id: Id72487917c804476f0e8f96e4ef9e98e48c5f237
parent 3c69ca62
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsService;
import android.telephony.ims.aidl.IImsConfig;
import android.telephony.ims.aidl.IImsRegistration;
import android.telephony.ims.aidl.ISipTransport;
@@ -183,6 +184,14 @@ public abstract class FeatureConnection {
        }
    }

    public boolean isCapable(@ImsService.ImsServiceCapability long capabilities)
            throws RemoteException {
        if (!isBinderAlive()) {
            throw new RemoteException("isCapable: ImsService is not alive");
        }
        return (getFeatureCapabilties() & capabilities) > 0;
    }

    /**
     * @return an integer describing the current Feature Status, defined in
     * {@link ImsFeature.ImsState}.
+21 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.ims.ImsException;
import android.telephony.ims.ImsService;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.RegistrationManager;
import android.telephony.ims.aidl.IImsCapabilityCallback;
@@ -34,6 +35,7 @@ import android.telephony.ims.aidl.IImsRcsController;
import android.telephony.ims.aidl.IImsRcsFeature;
import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IRcsFeatureListener;
import android.telephony.ims.aidl.ISipTransport;
import android.telephony.ims.feature.CapabilityChangeRequest;
import android.telephony.ims.feature.ImsFeature;
import android.telephony.ims.feature.RcsFeature;
@@ -342,6 +344,25 @@ public class RcsFeatureManager implements FeatureUpdates {
            mRcsFeatureConnection.removeCallbackForSubscription(subId, callback);
    }

    public boolean isImsServiceCapable(@ImsService.ImsServiceCapability long capabilities)
            throws ImsException {
        try {
            return mRcsFeatureConnection.isCapable(capabilities);
        } catch (RemoteException e) {
            throw new ImsException(e.getMessage(), ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
        }
    }

    /**
     * @return The SipTransport interface if it exists or {@code null} if it does not exist due to
     * the ImsService not supporting it.
     */
    public ISipTransport getSipTransport() throws ImsException {
        if (!isImsServiceCapable(ImsService.CAPABILITY_SIP_DELEGATE_CREATION)) {
            return null;
        }
        return mRcsFeatureConnection.getSipTransport();
    }
    /**
     * Query for the specific capability.
     */