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

Commit c5bf6286 authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Fix concurrency issues in ImsPhoneCall." into rvc-dev

parents f586455a 1b6208b2
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -269,10 +269,14 @@ public class ImsPhoneCall extends Call {
        return (ImsPhoneConnection) connections.get(0);
    }

    /*package*/ void
    setMute(boolean mute) {
        ImsCall imsCall = getFirstConnection() == null ?
                null : getFirstConnection().getImsCall();
    /**
     * Sets the mute state of the call.
     * @param mute {@code true} if the call could be muted; {@code false} otherwise.
     */
    @VisibleForTesting
    public void setMute(boolean mute) {
        ImsPhoneConnection connection = getFirstConnection();
        ImsCall imsCall = connection == null ? null : connection.getImsCall();
        if (imsCall != null) {
            try {
                imsCall.setMute(mute);
@@ -317,9 +321,9 @@ public class ImsPhoneCall extends Call {
     */
    @VisibleForTesting
    @UnsupportedAppUsage
    public ImsCall
    getImsCall() {
        return (getFirstConnection() == null) ? null : getFirstConnection().getImsCall();
    public ImsCall getImsCall() {
        ImsPhoneConnection connection = getFirstConnection();
        return (connection == null) ? null : connection.getImsCall();
    }

    /*package*/ static boolean isLocalTone(ImsCall imsCall) {
+26 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.test.suitebuilder.annotation.SmallTest;

import androidx.test.filters.FlakyTest;

import com.android.ims.ImsCall;
import com.android.ims.ImsException;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.TelephonyTest;

@@ -183,4 +185,28 @@ public class ImsPhoneCallTest extends TelephonyTest {
        mImsCallUT.isMultiparty();
        verify(mImsCall, times(1)).isMultiparty();
    }

    @Test
    @SmallTest
    public void testGetImsCall() {
        doReturn(mImsCall).when(mConnection1).getImsCall();
        mImsCallUT.attach(mConnection1, Call.State.ACTIVE);

        ImsCall imsCall = mImsCallUT.getImsCall();
        assertEquals(mImsCall, imsCall);
    }

    @Test
    @SmallTest
    public void testSetMute() {
        doReturn(mImsCall).when(mConnection1).getImsCall();
        mImsCallUT.attach(mConnection1, Call.State.ACTIVE);

        mImsCallUT.setMute(true);
        try {
            verify(mImsCall).setMute(eq(true));
        } catch (ImsException e) {
            fail("Exception unexpected");
        }
    }
}