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

Commit 28c2d7f3 authored by Hui Wang's avatar Hui Wang
Browse files

Move RCS provisioning changed callback logic to RcsProvisioningMonitor

As there may be separated services to provide MMTEl and RCS features,
RCS provioning callback should not depend on MMTEL feature.

Bug: 177018241
Test: atest TeleServiceTests:com.android.phone.RcsProvisioningMonitorTest
Test: atest CtsTelephonyTestCases:android.telephony.ims.cts.ImsServiceTest
Merged-In: Ic4164af93f404e75d0bc9c2d692d054d4b714f5f
Change-Id: Ic4164af93f404e75d0bc9c2d692d054d4b714f5f
parent df47a021
Loading
Loading
Loading
Loading
+0 −42
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ 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;
@@ -2863,47 +2862,6 @@ 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();
    }
+0 −63
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ 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;
@@ -198,52 +197,6 @@ 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
@@ -254,7 +207,6 @@ 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) {
@@ -264,7 +216,6 @@ 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
@@ -513,20 +464,6 @@ 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) {