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

Commit 6735c802 authored by Hall Liu's avatar Hall Liu
Browse files

Add null checks for getImsCall()

When certain RTT operations are performed near the end of a call, the
phone process may crash with a NPE since mImsCall in ImsPhoneConnection
becomes null. Add null checks to fix this.

Change-Id: I4da899f26ce897224429387927a48288454d0c8b
Merged-In: I4da899f26ce897224429387927a48288454d0c8b
Fixes: 110570770
Test: manual
parent bd394035
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -982,9 +982,12 @@ public class ImsPhoneConnection extends Connection implements
    }

    public void sendRttModifyRequest(android.telecom.Connection.RttTextStream textStream) {
        ImsCall imsCall = getImsCall();
        if (imsCall != null) {
            getImsCall().sendRttModifyRequest();
            setCurrentRttTextStream(textStream);
        }
    }

    /**
     * Sends the user's response to a remotely-issued RTT upgrade request
@@ -996,6 +999,7 @@ public class ImsPhoneConnection extends Connection implements
        boolean accept = textStream != null;
        ImsCall imsCall = getImsCall();

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

    public void onRttMessageReceived(String message) {
        synchronized (this) {
@@ -1055,7 +1060,12 @@ public class ImsPhoneConnection extends Connection implements
    // Make sure to synchronize on ImsPhoneConnection.this before calling.
    private void createRttTextHandler() {
        mRttTextHandler = new ImsRttTextHandler(Looper.getMainLooper(),
                (message) -> getImsCall().sendRttMessage(message));
                (message) -> {
                    ImsCall imsCall = getImsCall();
                    if (imsCall != null) {
                        imsCall.sendRttMessage(message);
                    }
                });
        mRttTextHandler.initialize(mRttTextStream);
    }