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

Commit 1aa4314d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix error hold message after ending the call."

parents d3b8f793 8c757a44
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -2722,7 +2722,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                    mHoldSwitchingState = HoldSwapState.INACTIVE;
                }
                ImsPhoneConnection conn = findConnection(imsCall);
                if (conn != null) {
                if (conn != null && conn.getState() != ImsPhoneCall.State.DISCONNECTED) {
                    conn.onConnectionEvent(android.telecom.Connection.EVENT_CALL_HOLD_FAILED, null);
                }
                mPhone.notifySuppServiceFailed(Phone.SuppService.HOLD);
@@ -4454,4 +4454,14 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    public boolean isConferenceEventPackageEnabled() {
        return mIsConferenceEventPackageEnabled;
    }

    @VisibleForTesting
    public ImsCall.Listener getImsCallListener() {
        return mImsCallListener;
    }

    @VisibleForTesting
    public ArrayList<ImsPhoneConnection> getConnections() {
        return mConnections;
    }
}
+25 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.internal.telephony.imsphone;

import static junit.framework.TestCase.fail;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -33,6 +35,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.content.SharedPreferences;
@@ -99,6 +102,8 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
    private ImsPhoneConnection.Listener mImsPhoneConnectionListener;
    @Mock
    private ImsConfig mImsConfig;
    @Mock
    private ImsPhoneConnection mImsPhoneConnection;

    private void imsCallMocking(final ImsCall imsCall) throws Exception {

@@ -160,6 +165,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        mImsCall = spy(new ImsCall(mContext, mImsCallProfile));
        mSecondImsCall = spy(new ImsCall(mContext, mImsCallProfile));
        mImsPhoneConnectionListener = mock(ImsPhoneConnection.Listener.class);
        mImsPhoneConnection = mock(ImsPhoneConnection.class);
        imsCallMocking(mImsCall);
        imsCallMocking(mSecondImsCall);
        doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
@@ -980,6 +986,25 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
                                "SERVICE not allowed in this location")));
    }

    @Test
    @SmallTest
    public void testNoHoldErrorMessageWhenCallDisconnected() {
        when(mImsPhoneConnection.getImsCall()).thenReturn(mImsCall);
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocationOnMock) {
                fail("Error message showed when the call has already been disconnected!");
                return null;
            }
        }).when(mImsPhoneConnection)
                .onConnectionEvent(eq(android.telecom.Connection.EVENT_CALL_HOLD_FAILED), any());
        mCTUT.getConnections().add(mImsPhoneConnection);
        when(mImsPhoneConnection.getState()).thenReturn(ImsPhoneCall.State.DISCONNECTED);
        ImsReasonInfo info = new ImsReasonInfo(ImsReasonInfo.CODE_UNSPECIFIED,
                ImsReasonInfo.CODE_UNSPECIFIED, null);
        mCTUT.getImsCallListener().onCallHoldFailed(mImsPhoneConnection.getImsCall(), info);
    }

    private ImsPhoneConnection placeCallAndMakeActive() {
        try {
            doAnswer(new Answer<ImsCall>() {