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

Commit 117564da authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Check for null extras in ImsPhoneConnection.

It is technically possible for an ImsCallProfile to have a null extras
bundle.  Adding some null checks into ImsPhoneConnection in methods
which inspect that bundle.

Test: Add unit tests for null check.
Fixes: 158125491
Change-Id: Ib1a413defef654d043b9b457616de23a2a1bb464
parent 50ddc3c2
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1211,6 +1211,9 @@ public class ImsPhoneConnection extends Connection implements
     * @param extras The ImsCallProfile extras.
     */
    private void updateImsCallRatFromExtras(Bundle extras) {
        if (extras == null) {
            return;
        }
        if (extras.containsKey(ImsCallProfile.EXTRA_CALL_NETWORK_TYPE)
                || extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE)
                || extras.containsKey(ImsCallProfile.EXTRA_CALL_RAT_TYPE_ALT)) {
@@ -1227,6 +1230,9 @@ public class ImsPhoneConnection extends Connection implements
    }

    private void updateEmergencyCallFromExtras(Bundle extras) {
        if (extras == null) {
            return;
        }
        if (extras.getBoolean(ImsCallProfile.EXTRA_EMERGENCY_CALL)) {
            setIsNetworkIdentifiedEmergencyCall(true);
        }
@@ -1255,7 +1261,9 @@ public class ImsPhoneConnection extends Connection implements
            updateImsCallRatFromExtras(extras);
            updateEmergencyCallFromExtras(extras);
            mExtras.clear();
            if (extras != null) {
                mExtras.putAll(extras);
            }
            setConnectionExtras(mExtras);
        }
        return changed;
+12 −0
Original line number Diff line number Diff line
@@ -92,6 +92,18 @@ public class ImsPhoneConnectionTest extends TelephonyTest {
        super.tearDown();
    }

    @Test
    @SmallTest
    public void testNullExtras() {
        mImsCallProfile.mCallExtras = null;
        try {
            mConnectionUT = new ImsPhoneConnection(mImsPhone, mImsCall, mImsCT, mForeGroundCall,
                    false);
        } catch (NullPointerException npe) {
            Assert.fail("Should not get NPE updating extras.");
        }
    }

    @Test
    @SmallTest
    public void testImsIncomingConnectionCorrectness() {