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

Commit 46b64e6c authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Protect against NPE during RTT call sessions

If the ImsCall moves to null during RTT session
we do not guard against against using the now
null reference, which can cause an NPE.

Guard against this condition as is done in the
rest of the class when this condition occurs.

Fixes: 233779563
Test: atest FrameworksTelephonyTests; verify calling on TMO
Change-Id: I92b7af69d2f51d4c32016ccc2a8972d338ba17ce
parent 7dfa08a1
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -1167,17 +1167,24 @@ public class ImsPhoneConnection extends Connection implements
     */
    public void startRtt(android.telecom.Connection.RttTextStream textStream) {
        ImsCall imsCall = getImsCall();
        if (imsCall != null) {
            getImsCall().sendRttModifyRequest(true);
            setCurrentRttTextStream(textStream);
        if (imsCall == null) {
            Rlog.w(LOG_TAG, "startRtt failed, imsCall is null");
            return;
        }
        imsCall.sendRttModifyRequest(true);
        setCurrentRttTextStream(textStream);
    }

    /**
     * Terminate the current RTT session.
     */
    public void stopRtt() {
        getImsCall().sendRttModifyRequest(false);
        ImsCall imsCall = getImsCall();
        if (imsCall == null) {
            Rlog.w(LOG_TAG, "stopRtt failed, imsCall is null");
            return;
        }
        imsCall.sendRttModifyRequest(false);
    }

    /**
@@ -1189,8 +1196,10 @@ public class ImsPhoneConnection extends Connection implements
    public void sendRttModifyResponse(android.telecom.Connection.RttTextStream textStream) {
        boolean accept = textStream != null;
        ImsCall imsCall = getImsCall();

        if (imsCall != null) {
        if (imsCall == null) {
            Rlog.w(LOG_TAG, "sendRttModifyResponse failed, imsCall is null");
            return;
        }
        imsCall.sendRttModifyResponse(accept);
        if (accept) {
            setCurrentRttTextStream(textStream);
@@ -1198,7 +1207,6 @@ public class ImsPhoneConnection extends Connection implements
            Rlog.e(LOG_TAG, "sendRttModifyResponse: foreground call has no connections");
        }
    }
    }

    public void onRttMessageReceived(String message) {
        synchronized (this) {
@@ -1277,6 +1285,8 @@ public class ImsPhoneConnection extends Connection implements
                    ImsCall imsCall = getImsCall();
                    if (imsCall != null) {
                        imsCall.sendRttMessage(message);
                    } else {
                        Rlog.w(LOG_TAG, "createRttTextHandler: imsCall is null");
                    }
                });
        mRttTextHandler.initialize(mRttTextStream);