diff options
author | Tyler Gunn <tgunn@google.com> | 2020-05-12 09:49:23 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2020-05-12 09:56:32 -0700 |
commit | 1b6208b21f8c0784e91fee46dc1855b77815be6f (patch) | |
tree | e51e976eecd13d5f9a05d7483d06e1b025cd3621 /tests/telephonytests | |
parent | ed4731a7d8478fbdbc24b58aa73dac87a5ebc249 (diff) | |
download | telephony-1b6208b21f8c0784e91fee46dc1855b77815be6f.tar.gz |
Fix concurrency issues in ImsPhoneCall.
The class had a couple places where getFirstConnection() was referenced,
but it was possible for concurrent access to take place on the connection
between when getFirstConnection() was first called and when the return
value from it was referenced. This was easy to fix by just storing the
instance of ImsPhoneConnection returned.
Fixes: 156168243
Test: Manual regression test for IMS phone calls.
Test: Add unit tests for get methods in question; can't really test the
concurrency in the test but can test basic operation.
Change-Id: I341fabf6e7cde869a7a8075f18ed15b593206471
Diffstat (limited to 'tests/telephonytests')
-rw-r--r-- | tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTest.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTest.java b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTest.java index 335f5a4a85..31fbfad319 100644 --- a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTest.java +++ b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTest.java @@ -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"); + } + } } |