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

Commit 9a0886f5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Change how RTT pipes are set"

parents f3fa9930 ca5c780a
Loading
Loading
Loading
Loading
+33 −11
Original line number Diff line number Diff line
@@ -996,11 +996,29 @@ public class ImsPhoneConnection extends Connection implements
    }

    public void onRttMessageReceived(String message) {
        getOrCreateRttTextHandler().sendToInCall(message);
        synchronized (this) {
            if (mRttTextHandler == null) {
                Rlog.w(LOG_TAG, "onRttMessageReceived: RTT text handler not available."
                        + " Attempting to create one.");
                if (mRttTextStream == null) {
                    Rlog.e(LOG_TAG, "onRttMessageReceived:"
                            + " Unable to process incoming message. No textstream available");
                    return;
                }
                createRttTextHandler();
            }
        }
        mRttTextHandler.sendToInCall(message);
    }

    public void setCurrentRttTextStream(android.telecom.Connection.RttTextStream rttTextStream) {
        synchronized (this) {
            mRttTextStream = rttTextStream;
            if (mRttTextHandler == null && mIsRttEnabledForCall) {
                Rlog.i(LOG_TAG, "setCurrentRttTextStream: Creating a text handler");
                createRttTextHandler();
            }
        }
    }

    public boolean hasRttTextStream() {
@@ -1012,20 +1030,24 @@ public class ImsPhoneConnection extends Connection implements
    }

    public void startRttTextProcessing() {
        synchronized (this) {
            if (mRttTextStream == null) {
                Rlog.w(LOG_TAG, "startRttTextProcessing: no RTT text stream. Ignoring.");
                return;
            }
        getOrCreateRttTextHandler().initialize(mRttTextStream);
    }

    private ImsRttTextHandler getOrCreateRttTextHandler() {
            if (mRttTextHandler != null) {
            return mRttTextHandler;
                Rlog.w(LOG_TAG, "startRttTextProcessing: RTT text handler already exists");
                return;
            }
            createRttTextHandler();
        }
    }

    // Make sure to synchronize on ImsPhoneConnection.this before calling.
    private void createRttTextHandler() {
        mRttTextHandler = new ImsRttTextHandler(Looper.getMainLooper(),
                (message) -> getImsCall().sendRttMessage(message));
        return mRttTextHandler;
        mRttTextHandler.initialize(mRttTextStream);
    }

    /**