RTT bugfixes, part 5

* Add a new API to allow Telecom to inform ConnectionServices when the
RTT text stream changes
* No longer set the RTT property from ConnectionService. Client apps
should be setting properties themselves.
* Add Dialer-side RTT property in order to remove the dependence on
checking the RTT streams, which have a complex lifecycle

Bug: 72951201
Bug: 72648661
Test: manual, with real RTT calls and Dialer's SimulatorConnection, also
cts
Change-Id: Ic4c7d883d2dc6baf8e8c0eaa4df58d7de8762b9e
Merged-In: Ic4c7d883d2dc6baf8e8c0eaa4df58d7de8762b9e
This commit is contained in:
Hall Liu
2018-02-09 16:40:03 -08:00
parent 47e1d11b47
commit e9041241de
6 changed files with 49 additions and 35 deletions

View File

@@ -40,6 +40,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.
*/
@@ -2620,7 +2625,6 @@ public abstract class Connection extends Conferenceable {
* {@link #onStartRtt(RttTextStream)} has succeeded.
*/
public final void sendRttInitiationSuccess() {
setRttProperty();
mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
}
@@ -2632,7 +2636,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));
}
@@ -2641,7 +2644,6 @@ public abstract class Connection extends Conferenceable {
* side of the coll.
*/
public final void sendRttSessionRemotelyTerminated() {
unsetRttProperty();
mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
}
@@ -2941,22 +2943,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) {