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

Commit a21511a4 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Change how RTT pipes are set" into pi-dev am: 1d923603

am: 1daf9226

Change-Id: Idc9856b8008b9dd5cf8b1920b6d022a86ee1e07a
parents 0211329c 1daf9226
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);
    }

    /**