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

Commit b75e9557 authored by Hui Wang's avatar Hui Wang
Browse files

RCS Provisioning APIs for Single Registration

Bug: 154864150
Test: atest FrameworksTelephonyTests:com.telephony.ims.RcsConfigTest
Test: atest TeleServiceTests:RcsProvisioningMonitorTest
Test: atest CtsTelephonyTestCases:android.telephony.ims.cts.ImsServiceTest
Merged-In: Ic0c6484045807317a7f4faf343cbdfd25fd85259
Change-Id: Ic0c6484045807317a7f4faf343cbdfd25fd85259
parent 2aafe6d0
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsRegistration;
import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IImsSmsListener;
import android.telephony.ims.aidl.IRcsConfigCallback;
import android.telephony.ims.aidl.ISipTransport;
import android.telephony.ims.feature.CapabilityChangeRequest;
import android.telephony.ims.feature.ImsFeature;
@@ -2828,6 +2829,47 @@ public class ImsManager implements FeatureUpdates {
                provisionStatus);
    }

    /**
     * Adds a callback of RCS provisioning for a specified subscription.
     * @param callback A {@link android.telephony.ims.aidl.IRcsConfigCallback}
     *         for RCS provisioning change.
     * @param subId The subscription that is associated with the callback.
     * @throws IllegalStateException when the {@link ImsService} connection is not available.
     * @throws IllegalArgumentException when the {@link IRcsConfigCallback} argument is null.
     */
    public void addRcsProvisioningCallbackForSubscription(IRcsConfigCallback callback, int subId) {
        if (callback == null) {
            throw new IllegalArgumentException("provisioning callback can't be null");
        }

        mMmTelConnectionRef.get().addRcsProvisioningCallbackForSubscription(callback, subId);
        log("Capability Callback registered for subscription.");
    }

    /**
     * Removes a previously registered {@link android.telephony.ims.aidl.IRcsConfigCallback}.
     * @throws IllegalStateException when the {@link ImsService} connection is not available.
     * @throws IllegalArgumentException when the {@link IRcsConfigCallback} argument is null.
     */
    public void removeRcsProvisioningCallbackForSubscription(
            IRcsConfigCallback callback, int subId) {
        if (callback == null) {
            throw new IllegalArgumentException("provisioning callback can't be null");
        }

        mMmTelConnectionRef.get().removeRcsProvisioningCallbackForSubscription(callback, subId);
    }

    /**
     * Removes all RCS provisioning callbacks
     *
     * <p>This method is called when default message application change or some other event
     * which need force to remove all RCS provisioning callbacks.
     */
    public void clearRcsProvisioningCallbacks() {
        mMmTelConnectionRef.get().clearRcsProvisioningCallbacks();
    }

    private boolean isDataEnabled() {
        return new TelephonyManager(mContext, getSubId()).isDataConnectionAllowed();
    }
+63 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.telephony.ims.aidl.IImsMmTelFeature;
import android.telephony.ims.aidl.IImsRegistration;
import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IImsSmsListener;
import android.telephony.ims.aidl.IRcsConfigCallback;
import android.telephony.ims.aidl.ISipTransport;
import android.telephony.ims.feature.CapabilityChangeRequest;
import android.telephony.ims.feature.ImsFeature;
@@ -197,6 +198,52 @@ public class MmTelFeatureConnection extends FeatureConnection {
        }
    }

    private class RcsProvisioningCallbackManager
            extends ImsCallbackAdapterManager<IRcsConfigCallback> {
        public RcsProvisioningCallbackManager (Context context, Object lock) {
            super(context, lock, mSlotId);
        }

        @Override
        public void registerCallback(IRcsConfigCallback localCallback) {
            IImsConfig binder = getConfig();
            if (binder == null) {
                // Config interface is not currently available.
                Log.w(TAG + " [" + mSlotId + "]",
                        "RcsProvisioningCallbackManager - couldn't register,"
                        + " binder is null.");
                throw new IllegalStateException("RcsConfig is not available!");
            }
            try {
                binder.addRcsConfigCallback(localCallback);
            }catch (RemoteException e) {
                throw new IllegalStateException("ImsService is not available!");
            }
        }

        @Override
        public void unregisterCallback(IRcsConfigCallback localCallback) {
            IImsConfig binder = getConfig();
            if (binder != null) {
                try {
                    binder.removeRcsConfigCallback(localCallback);
                } catch (RemoteException e) {
                    Log.w(TAG + " [" + mSlotId + "]", "RcsProvisioningCallbackManager - couldn't"
                            + " unregister, binder is dead.");
                }
            } else {
                Log.w(TAG + " [" + mSlotId + "]", "RcsProvisioningCallbackManager - couldn't"
                        + " unregister, binder is null.");
            }
            try {
                localCallback.onRemoved();
            } catch (RemoteException e) {
                Log.w(TAG + " [" + mSlotId + "]", "RcsProvisioningCallbackManager - couldn't"
                        + " notify onRemoved, binder is dead.");
            }
        }
    }

    // Updated by IImsServiceFeatureCallback when FEATURE_EMERGENCY_MMTEL is sent.
    private boolean mSupportsEmergencyCalling = false;
    // MMTEL specific binder Interfaces
@@ -207,6 +254,7 @@ public class MmTelFeatureConnection extends FeatureConnection {
    private final ImsRegistrationCallbackAdapter mRegistrationCallbackManager;
    private final CapabilityCallbackManager mCapabilityCallbackManager;
    private final ProvisioningCallbackManager mProvisioningCallbackManager;
    private final RcsProvisioningCallbackManager mRcsProvisioningCallbackManager;

    public MmTelFeatureConnection(Context context, int slotId, IImsMmTelFeature f,
            IImsConfig c, IImsRegistration r, ISipTransport s) {
@@ -216,6 +264,7 @@ public class MmTelFeatureConnection extends FeatureConnection {
        mRegistrationCallbackManager = new ImsRegistrationCallbackAdapter(context, mLock);
        mCapabilityCallbackManager = new CapabilityCallbackManager(context, mLock);
        mProvisioningCallbackManager = new ProvisioningCallbackManager(context, mLock);
        mRcsProvisioningCallbackManager = new RcsProvisioningCallbackManager(context, mLock);
    }

    @Override
@@ -464,6 +513,20 @@ public class MmTelFeatureConnection extends FeatureConnection {
        }
    }

    public void addRcsProvisioningCallbackForSubscription(IRcsConfigCallback callback,
            int subId) {
        mRcsProvisioningCallbackManager.addCallbackForSubscription(callback, subId);
    }

    public void removeRcsProvisioningCallbackForSubscription(IRcsConfigCallback callback,
            int subId) {
        mRcsProvisioningCallbackManager.removeCallbackForSubscription(callback , subId);
    }

    public void clearRcsProvisioningCallbacks() {
        mRcsProvisioningCallbackManager.close();
    }

    @Override
    protected Integer retrieveFeatureState() {
        if (mBinder != null) {