Search in sources :

Example 16 with ImsCallProfile

use of android.telephony.ims.ImsCallProfile in project android_frameworks_opt_telephony by LineageOS.

the class ImsCallProfileTest method testExtrasCleanup.

/**
 * Ensures that the {@link ImsCallProfile} will discard invalid extras when it is parceled.
 */
@Test
@SmallTest
public void testExtrasCleanup() {
    ImsCallProfile srcParcel = new ImsCallProfile();
    // Put in a private parcelable type.
    srcParcel.mCallExtras.putParcelable("JUNK", new JunkParcelable());
    // Put in an api defined parcelable type.
    srcParcel.mCallExtras.putParcelable("NOTJUNK", new DisconnectCause(DisconnectCause.BUSY));
    // Put in some valid things.
    srcParcel.mCallExtras.putInt("INT", 1);
    srcParcel.mCallExtras.putString("STRING", "hello");
    // Parcel it.
    Parcel parcel = Parcel.obtain();
    srcParcel.writeToParcel(parcel, 0);
    byte[] parcelBytes = parcel.marshall();
    parcel.recycle();
    // Unparcel it.
    parcel = Parcel.obtain();
    parcel.unmarshall(parcelBytes, 0, parcelBytes.length);
    parcel.setDataPosition(0);
    ImsCallProfile unparceledProfile = ImsCallProfile.CREATOR.createFromParcel(parcel);
    parcel.recycle();
    assertNotNull(unparceledProfile.mCallExtras);
    assertEquals(3, unparceledProfile.mCallExtras.size());
    assertEquals(1, unparceledProfile.getCallExtraInt("INT"));
    assertEquals("hello", unparceledProfile.getCallExtra("STRING"));
    assertFalse(unparceledProfile.mCallExtras.containsKey("JUNK"));
    DisconnectCause parceledCause = unparceledProfile.mCallExtras.getParcelable("NOTJUNK");
    assertEquals(DisconnectCause.BUSY, parceledCause.getCode());
}
Also used : DisconnectCause(android.telecom.DisconnectCause) ImsCallProfile(android.telephony.ims.ImsCallProfile) Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ImsCallProfile (android.telephony.ims.ImsCallProfile)16 ImsCall (com.android.ims.ImsCall)8 ImsException (com.android.ims.ImsException)8 RemoteException (android.os.RemoteException)5 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 CallStateException (com.android.internal.telephony.CallStateException)5 Test (org.junit.Test)5 Connection (com.android.internal.telephony.Connection)4 TelephonyTest (com.android.internal.telephony.TelephonyTest)4 Bundle (android.os.Bundle)3 FlakyTest (androidx.test.filters.FlakyTest)3 ImsPhone (com.android.internal.telephony.imsphone.ImsPhone)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 ContentResolver (android.content.ContentResolver)1 Context (android.content.Context)1 NetworkCapabilities (android.net.NetworkCapabilities)1 AsyncResult (android.os.AsyncResult)1 Handler (android.os.Handler)1 IBinder (android.os.IBinder)1