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

Commit 1a369071 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Fix error hold message after ending the call." am: 1aa4314d am: e4742fb6

Change-Id: I037d3de5682602dc77ba5dc957c7d380cef4c9e0
parents 59e7b879 e4742fb6
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -2722,7 +2722,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                    mHoldSwitchingState = HoldSwapState.INACTIVE;
                    mHoldSwitchingState = HoldSwapState.INACTIVE;
                }
                }
                ImsPhoneConnection conn = findConnection(imsCall);
                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);
                    conn.onConnectionEvent(android.telecom.Connection.EVENT_CALL_HOLD_FAILED, null);
                }
                }
                mPhone.notifySuppServiceFailed(Phone.SuppService.HOLD);
                mPhone.notifySuppServiceFailed(Phone.SuppService.HOLD);
@@ -4454,4 +4454,14 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    public boolean isConferenceEventPackageEnabled() {
    public boolean isConferenceEventPackageEnabled() {
        return mIsConferenceEventPackageEnabled;
        return mIsConferenceEventPackageEnabled;
    }
    }

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

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


import static junit.framework.TestCase.fail;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
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.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


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


    private void imsCallMocking(final ImsCall imsCall) throws Exception {
    private void imsCallMocking(final ImsCall imsCall) throws Exception {


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