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
This commit is contained in:
Hall Liu
2018-02-09 16:40:03 -08:00
parent fc7423bcba
commit a549fed518
6 changed files with 49 additions and 35 deletions

View File

@@ -36633,6 +36633,7 @@ package android.provider {
field public static final deprecated java.lang.String RADIO_NFC = "nfc";
field public static final deprecated java.lang.String RADIO_WIFI = "wifi";
field public static final java.lang.String RINGTONE = "ringtone";
field public static final java.lang.String RTT_CALLING_MODE = "rtt_calling_mode";
field public static final java.lang.String SCREEN_BRIGHTNESS = "screen_brightness";
field public static final java.lang.String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
field public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1; // 0x1
@@ -40637,6 +40638,7 @@ package android.telecom {
field public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 128; // 0x80
field public static final int PROPERTY_HIGH_DEF_AUDIO = 16; // 0x10
field public static final int PROPERTY_IS_EXTERNAL_CALL = 64; // 0x40
field public static final int PROPERTY_RTT = 1024; // 0x400
field public static final int PROPERTY_SELF_MANAGED = 256; // 0x100
field public static final int PROPERTY_WIFI = 8; // 0x8
}

View File

@@ -3692,18 +3692,15 @@ public final class Settings {
new SettingsValidators.InclusiveIntegerRangeValidator(0, 3);
/**
* User-selected RTT mode
* User-selected RTT mode. When on, outgoing and incoming calls will be answered as RTT
* calls when supported by the device and carrier. Boolean value.
* 0 = OFF
* 1 = FULL
* 2 = VCO
* 3 = HCO
* Uses the same constants as TTY (e.g. {@link android.telecom.TelecomManager#TTY_MODE_OFF})
* @hide
* 1 = ON
*/
public static final String RTT_CALLING_MODE = "rtt_calling_mode";
/** @hide */
public static final Validator RTT_CALLING_MODE_VALIDATOR = TTY_MODE_VALIDATOR;
public static final Validator RTT_CALLING_MODE_VALIDATOR = BOOLEAN_VALIDATOR;
/**
* Whether the sounds effects (key clicks, lid open ...) are enabled. The value is

View File

@@ -425,8 +425,14 @@ public final class Call {
*/
public static final int PROPERTY_ASSISTED_DIALING_USED = 0x00000200;
/**
* Indicates that the call is an RTT call. Use {@link #getRttCall()} to get the
* {@link RttCall} object that is used to send and receive text.
*/
public static final int PROPERTY_RTT = 0x00000400;
//******************************************************************************************
// Next PROPERTY value: 0x00000400
// Next PROPERTY value: 0x00000800
//******************************************************************************************
private final String mTelecomCallId;
@@ -1189,6 +1195,23 @@ public final class Call {
return null;
}
}
/**
* Closes the underlying file descriptors
* @hide
*/
public void close() {
try {
mReceiveStream.close();
} catch (IOException e) {
// ignore
}
try {
mTransmitStream.close();
} catch (IOException e) {
// ignore
}
}
}
/**
@@ -1664,7 +1687,7 @@ public final class Call {
* @return true if there is a connection, false otherwise.
*/
public boolean isRttActive() {
return mRttCall != null;
return mRttCall != null && mDetails.hasProperty(Details.PROPERTY_RTT);
}
/**
@@ -1867,7 +1890,8 @@ public final class Call {
boolean isRttChanged = false;
boolean rttModeChanged = false;
if (parcelableCall.getParcelableRttCall() != null && parcelableCall.getIsRttCallChanged()) {
if (parcelableCall.getIsRttCallChanged()
&& mDetails.hasProperty(Details.PROPERTY_RTT)) {
ParcelableRttCall parcelableRttCall = parcelableCall.getParcelableRttCall();
InputStreamReader receiveStream = new InputStreamReader(
new ParcelFileDescriptor.AutoCloseInputStream(

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));
}
@@ -2914,22 +2916,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) {

View File

@@ -143,6 +143,8 @@ public final class ConnectionRequest implements Parcelable {
private final boolean mShouldShowIncomingCallUi;
private final ParcelFileDescriptor mRttPipeToInCall;
private final ParcelFileDescriptor mRttPipeFromInCall;
// Cached return value of getRttTextStream -- we don't want to wrap it more than once.
private Connection.RttTextStream mRttTextStream;
/**
* @param accountHandle The accountHandle which should be used to place the call.
@@ -312,7 +314,10 @@ public final class ConnectionRequest implements Parcelable {
*/
public Connection.RttTextStream getRttTextStream() {
if (isRequestingRtt()) {
return new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall);
if (mRttTextStream == null) {
mRttTextStream = new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall);
}
return mRttTextStream;
} else {
return null;
}

View File

@@ -144,6 +144,7 @@ public abstract class ConnectionService extends Service {
private static final String SESSION_HANDOVER_COMPLETE = "CS.hC";
private static final String SESSION_EXTRAS_CHANGED = "CS.oEC";
private static final String SESSION_START_RTT = "CS.+RTT";
private static final String SESSION_UPDATE_RTT_PIPES = "CS.uRTT";
private static final String SESSION_STOP_RTT = "CS.-RTT";
private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR";
private static final String SESSION_CONNECTION_SERVICE_FOCUS_LOST = "CS.cSFL";
@@ -1865,7 +1866,6 @@ public abstract class ConnectionService extends Service {
Log.d(this, "stopRtt(%s)", callId);
if (mConnectionById.containsKey(callId)) {
findConnectionForAction(callId, "stopRtt").onStopRtt();
findConnectionForAction(callId, "stopRtt").unsetRttProperty();
} else if (mConferenceById.containsKey(callId)) {
Log.w(this, "stopRtt called on a conference.");
}