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

Commit ee2c1a06 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Correctly unregister listeners when MMTEL moves to not ready" am:...

Merge "Correctly unregister listeners when MMTEL moves to not ready" am: 28a9c79e am: 108d33e8 am: bac3cdd7 am: 0622ab23 am: c804a4ca

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1558909

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4c7f52c6b7a190e932ae9faa8509569c35a2a42f
parents e8da2f54 c804a4ca
Loading
Loading
Loading
Loading
+22 −36
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ import com.android.ims.ImsConfigListener;
import com.android.ims.ImsEcbm;
import com.android.ims.ImsException;
import com.android.ims.ImsManager;
import com.android.ims.ImsMultiEndpoint;
import com.android.ims.ImsUtInterface;
import com.android.ims.internal.ConferenceParticipant;
import com.android.ims.internal.IImsCallSession;
@@ -995,7 +994,13 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    public void startListeningForCalls() throws ImsException {
        log("startListeningForCalls");
        mOperationLocalLog.log("startListeningForCalls - Connecting to ImsService");
        mImsManager.open(mMmTelFeatureListener);
        ImsExternalCallTracker externalCallTracker = mPhone.getExternalCallTracker();
        ImsExternalCallTracker.ExternalCallStateListener externalCallStateListener =
                externalCallTracker != null
                        ? externalCallTracker.getExternalCallStateListener() : null;

        mImsManager.open(mMmTelFeatureListener, mPhone.getImsEcbmStateListener(),
                externalCallStateListener);
        mImsManager.addRegistrationCallback(mPhone.getImsMmTelRegistrationCallback(), this::post);
        mImsManager.addCapabilitiesCallback(mImsCapabilityCallback, this::post);

@@ -1003,8 +1008,6 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {

        mImsManager.getConfigInterface().addConfigCallback(mConfigCallback);

        // Get the ECBM interface and set IMSPhone's listener object for notifications
        getEcbmInterface().setEcbmStateListener(mPhone.getImsEcbmStateListener());
        if (mPhone.isInEcm()) {
            // Call exit ECBM which will invoke onECBMExited
            mPhone.exitEmergencyCallbackMode();
@@ -1015,17 +1018,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                Phone.TTY_MODE_OFF);
        mImsManager.setUiTTYMode(mPhone.getContext(), mPreferredTtyMode, null);

        ImsMultiEndpoint multiEndpoint = getMultiEndpointInterface();
        if (multiEndpoint != null) {
            multiEndpoint.setExternalCallStateListener(
                    mPhone.getExternalCallTracker().getExternalCallStateListener());
        }

        //Set UT interface listener to receive UT indications.
        // Set UT interface listener to receive UT indications & keep track of the interface so the
        // handler reference can be cleared.
        mUtInterface = getUtInterface();
        if (mUtInterface != null) {
            mUtInterface.registerForSuppServiceIndication(this,
                    EVENT_SUPP_SERVICE_INDICATION, null);
            mUtInterface.registerForSuppServiceIndication(this, EVENT_SUPP_SERVICE_INDICATION,
                    null);
        }

        // Where device to device communication is available, ensure that the
@@ -1049,16 +1047,25 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    private void stopListeningForCalls() {
        log("stopListeningForCalls");
        mOperationLocalLog.log("stopListeningForCalls - Disconnecting from ImsService");
        resetImsCapabilities();
        // Only close on valid session.
        if (mImsManager != null) {
            mImsManager.removeRegistrationListener(mPhone.getImsMmTelRegistrationCallback());
            mImsManager.removeCapabilitiesCallback(mImsCapabilityCallback);
            try {
                mImsManager.setConfigListener(null);
                mImsManager.getConfigInterface().removeConfigCallback(mConfigCallback.getBinder());
            } catch (ImsException e) {
                Log.w(LOG_TAG, "stopListeningForCalls: unable to remove config callback.");
            }
            // Will release other listeners for MMTEL/ECBM/UT/MultiEndpoint Indications set in #open
            mImsManager.close();
        }
        if (mUtInterface != null) {
            mUtInterface.unregisterForSuppServiceIndication(this);
            mUtInterface = null;
        }

        resetImsCapabilities();
        hangupAllOrphanedConnections(DisconnectCause.LOST_SIGNAL);
        // For compatibility with apps that still use deprecated intent
        sendImsServiceStateIntent(ImsManager.ACTION_IMS_SERVICE_DOWN);
@@ -1115,9 +1122,6 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        mHandoverCall.dispose();

        clearDisconnected();
        if (mUtInterface != null) {
            mUtInterface.unregisterForSuppServiceIndication(this);
        }
        mPhone.getContext().unregisterReceiver(mReceiver);
        mPhone.getDefaultPhone().getDataEnabledSettings().unregisterForDataEnabledChanged(this);
        mImsManagerConnector.disconnect();
@@ -3941,7 +3945,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            throw getImsManagerIsNullException();
        }

        ImsUtInterface ut = mImsManager.getSupplementaryServiceConfiguration();
        ImsUtInterface ut = mImsManager.createOrGetSupplementaryServiceConfiguration();
        return ut;
    }

@@ -4412,24 +4416,6 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        return ecbm;
    }

    /* package */
    ImsMultiEndpoint getMultiEndpointInterface() throws ImsException {
        if (mImsManager == null) {
            throw getImsManagerIsNullException();
        }

        try {
            return mImsManager.getMultiEndpointInterface();
        } catch (ImsException e) {
            if (e.getCode() == ImsReasonInfo.CODE_MULTIENDPOINT_NOT_SUPPORTED) {
                return null;
            } else {
                throw e;
            }

        }
    }

    public boolean isInEmergencyCall() {
        return mIsInEmergencyCall;
    }
+3 −5
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        doAnswer(invocation -> {
            mMmTelListener = (MmTelFeature.Listener) invocation.getArguments()[0];
            return null;
        }).when(mImsManager).open(any(MmTelFeature.Listener.class));
        }).when(mImsManager).open(any(), any(), any());

        doAnswer(new Answer<ImsCall>() {
            @Override
@@ -770,8 +770,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
                eq(new String[]{"+17005554141"}), nullable(ImsCall.Listener.class));
        // Make sure that open is called in ImsPhoneCallTracker when it was first connected and
        // again after retry.
        verify(mImsManager, times(2)).open(
                nullable(MmTelFeature.Listener.class));
        verify(mImsManager, times(2)).open(any(), any(), any());
    }

    @FlakyTest
@@ -788,8 +787,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        processAllMessages();
        // Make sure that open is called in ImsPhoneCallTracker to re-establish connection to
        // ImsService
        verify(mImsManager, times(2)).open(
                nullable(MmTelFeature.Listener.class));
        verify(mImsManager, times(2)).open(any(), any(), any());
    }

    @Test