Merge "RTT bugfixes, part 5"

This commit is contained in:
Hall Liu
2018-02-15 23:31:18 +00:00
committed by Android (Google) Code Review
6 changed files with 49 additions and 35 deletions

View File

@@ -41,6 +41,8 @@ import android.os.SystemClock;
import android.util.ArraySet;
import android.view.Surface;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
@@ -860,18 +862,19 @@ public abstract class Connection extends Conferenceable {
mFdFromInCall = fromInCall;
mFdToInCall = toInCall;
mPipeFromInCall = new InputStreamReader(
new ParcelFileDescriptor.AutoCloseInputStream(fromInCall));
new FileInputStream(fromInCall.getFileDescriptor()));
mPipeToInCall = new OutputStreamWriter(
new ParcelFileDescriptor.AutoCloseOutputStream(toInCall));
new FileOutputStream(toInCall.getFileDescriptor()));
}
/**
* Writes the string {@param input} into the text stream to the UI for this RTT call. Since
* RTT transmits text in real-time, this method should be called as often as text snippets
* are received from the remote user, even if it is only one character.
*
* <p>
* This method is not thread-safe -- calling it from multiple threads simultaneously may
* lead to interleaved text.
*
* @param input The message to send to the in-call app.
*/
public void write(String input) throws IOException {
@@ -884,9 +887,10 @@ public abstract class Connection extends Conferenceable {
* Reads a string from the in-call app, blocking if there is no data available. Returns
* {@code null} if the RTT conversation has been terminated and there is no further data
* to read.
*
* <p>
* This method is not thread-safe -- calling it from multiple threads simultaneously may
* lead to interleaved text.
*
* @return A string containing text entered by the user, or {@code null} if the
* conversation has been terminated or if there was an error while reading.
*/
@@ -901,6 +905,7 @@ public abstract class Connection extends Conferenceable {
/**
* Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
* be read.
*
* @return A string containing text entered by the user, or {@code null} if the user has
* not entered any new text yet.
*/
@@ -2635,7 +2640,6 @@ public abstract class Connection extends Conferenceable {
* {@link #onStartRtt(RttTextStream)} has succeeded.
*/
public final void sendRttInitiationSuccess() {
setRttProperty();
mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
}
@@ -2647,7 +2651,6 @@ public abstract class Connection extends Conferenceable {
* exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
*/
public final void sendRttInitiationFailure(int reason) {
unsetRttProperty();
mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
}
@@ -2656,7 +2659,6 @@ public abstract class Connection extends Conferenceable {
* side of the coll.
*/
public final void sendRttSessionRemotelyTerminated() {
unsetRttProperty();
mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
}
@@ -2956,22 +2958,6 @@ public abstract class Connection extends Conferenceable {
*/
public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
/**
* Internal method to set {@link #PROPERTY_IS_RTT}.
* @hide
*/
void setRttProperty() {
setConnectionProperties(getConnectionProperties() | PROPERTY_IS_RTT);
}
/**
* Internal method to un-set {@link #PROPERTY_IS_RTT}.
* @hide
*/
void unsetRttProperty() {
setConnectionProperties(getConnectionProperties() & (~PROPERTY_IS_RTT));
}
static String toLogSafePhoneNumber(String number) {
// For unknown number, log empty string.
if (number == null) {