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

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

Merge "Only update address of IMS call for incoming calls." into oc-dr1-dev

parents d70fdd53 eb746540
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -236,6 +236,15 @@ public class ImsPhoneConnection extends Connection implements
    public void dispose() {
    }

    /**
     * Sets whether this call is an incoming call or not.
     * @param isIncoming {@code true} if the call is an incoming call, {@code false} if it is an
     *                               outgoing call.
     */
    public void setIsIncoming(boolean isIncoming) {
        mIsIncoming = isIncoming;
    }

    static boolean
    equalsHandlesNulls (Object a, Object b) {
        return (a == null) ? (b == null) : a.equals (b);
@@ -757,7 +766,10 @@ public class ImsPhoneConnection extends Connection implements

        boolean changed = false;
        ImsCallProfile callProfile = imsCall.getCallProfile();
        if (callProfile != null) {
        if (callProfile != null && isIncoming()) {
            // Only look for changes to the address for incoming calls.  The originating identity
            // can change for outgoing calls due to, for example, a call being forwarded to
            // voicemail.  This address change does not need to be presented to the user.
            String address = callProfile.getCallExtra(ImsCallProfile.EXTRA_OI);
            String name = callProfile.getCallExtra(ImsCallProfile.EXTRA_CNA);
            int nump = ImsCallProfile.OIRToPresentation(
@@ -765,8 +777,9 @@ public class ImsPhoneConnection extends Connection implements
            int namep = ImsCallProfile.OIRToPresentation(
                    callProfile.getCallExtraInt(ImsCallProfile.EXTRA_CNAP));
            if (Phone.DEBUG_PHONE) {
                Rlog.d(LOG_TAG, "callId = " + getTelecomCallId() + " address = " + Rlog.pii(LOG_TAG,
                        address) + " name = " + name + " nump = " + nump + " namep = " + namep);
                Rlog.d(LOG_TAG, "updateAddressDisplay: callId = " + getTelecomCallId()
                        + " address = " + Rlog.pii(LOG_TAG, address) + " name = " + name
                        + " nump = " + nump + " namep = " + namep);
            }
            if (!mIsMergeInProcess) {
                // Only process changes to the name and address when a merge is not in process.
+22 −0
Original line number Diff line number Diff line
@@ -265,6 +265,9 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
        assertTrue(mConnectionUT.isWifi());
    }

    /**
     * Test updates to address for incoming calls.
     */
    @Test
    @SmallTest
    public void testAddressUpdate() {
@@ -283,10 +286,29 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
        for (String[] testAddress : testAddressMappingSet) {
            mConnectionUT = new ImsPhoneConnection(mImsPhone, testAddress[0], mImsCT,
                    mForeGroundCall, false);
            mConnectionUT.setIsIncoming(true);
            doReturn(testAddress[1]).when(mImsCallProfile)
                    .getCallExtra(eq(ImsCallProfile.EXTRA_OI));
            mConnectionUT.updateAddressDisplay(mImsCall);
            assertEquals(testAddress[2], mConnectionUT.getAddress());
        }
    }

    /**
     * Ensure updates to the address for outgoing calls are ignored.
     */
    @Test
    @SmallTest
    public void testSetAddressOnOutgoing() {
        String inputAddress = "12345";
        String updateAddress = "6789";

        mConnectionUT = new ImsPhoneConnection(mImsPhone, inputAddress, mImsCT, mForeGroundCall,
                false);
        mConnectionUT.setIsIncoming(false);
        doReturn(updateAddress).when(mImsCallProfile)
                .getCallExtra(eq(ImsCallProfile.EXTRA_OI));
        mConnectionUT.updateAddressDisplay(mImsCall);
        assertEquals(inputAddress, mConnectionUT.getAddress());
    }
}