Merge "RTT bugfixes, part 5"

This commit is contained in:
Hall Liu
2018-02-22 19:16:41 +00:00
committed by Gerrit Code Review
6 changed files with 49 additions and 35 deletions

View File

@@ -35422,6 +35422,7 @@ package android.provider {
field public static final deprecated java.lang.String RADIO_NFC = "nfc"; 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 deprecated java.lang.String RADIO_WIFI = "wifi";
field public static final java.lang.String RINGTONE = "ringtone"; 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 = "screen_brightness";
field public static final java.lang.String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode"; field public static final java.lang.String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
field public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1; // 0x1 field public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1; // 0x1
@@ -39250,6 +39251,7 @@ package android.telecom {
field public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 128; // 0x80 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_HIGH_DEF_AUDIO = 16; // 0x10
field public static final int PROPERTY_IS_EXTERNAL_CALL = 64; // 0x40 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_SELF_MANAGED = 256; // 0x100
field public static final int PROPERTY_WIFI = 8; // 0x8 field public static final int PROPERTY_WIFI = 8; // 0x8
} }

View File

@@ -3665,18 +3665,15 @@ public final class Settings {
public static final Validator TTY_MODE_VALIDATOR = new InclusiveIntegerRangeValidator(0, 3); public static final Validator TTY_MODE_VALIDATOR = new 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 * 0 = OFF
* 1 = FULL * 1 = ON
* 2 = VCO
* 3 = HCO
* Uses the same constants as TTY (e.g. {@link android.telecom.TelecomManager#TTY_MODE_OFF})
* @hide
*/ */
public static final String RTT_CALLING_MODE = "rtt_calling_mode"; public static final String RTT_CALLING_MODE = "rtt_calling_mode";
/** @hide */ /** @hide */
public static final Validator RTT_CALLING_MODE_VALIDATOR = TTY_MODE_VALIDATOR; public static final Validator RTT_CALLING_MODE_VALIDATOR = sBooleanValidator;
/** /**
* Whether the sounds effects (key clicks, lid open ...) are enabled. The value is * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is

View File

@@ -426,8 +426,14 @@ public final class Call {
*/ */
public static final int PROPERTY_ASSISTED_DIALING_USED = 0x00000200; 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; private final String mTelecomCallId;
@@ -1190,6 +1196,23 @@ public final class Call {
return null; 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
}
}
} }
/** /**
@@ -1665,7 +1688,7 @@ public final class Call {
* @return true if there is a connection, false otherwise. * @return true if there is a connection, false otherwise.
*/ */
public boolean isRttActive() { public boolean isRttActive() {
return mRttCall != null; return mRttCall != null && mDetails.hasProperty(Details.PROPERTY_RTT);
} }
/** /**
@@ -1868,7 +1891,8 @@ public final class Call {
boolean isRttChanged = false; boolean isRttChanged = false;
boolean rttModeChanged = false; boolean rttModeChanged = false;
if (parcelableCall.getParcelableRttCall() != null && parcelableCall.getIsRttCallChanged()) { if (parcelableCall.getIsRttCallChanged()
&& mDetails.hasProperty(Details.PROPERTY_RTT)) {
ParcelableRttCall parcelableRttCall = parcelableCall.getParcelableRttCall(); ParcelableRttCall parcelableRttCall = parcelableCall.getParcelableRttCall();
InputStreamReader receiveStream = new InputStreamReader( InputStreamReader receiveStream = new InputStreamReader(
new ParcelFileDescriptor.AutoCloseInputStream( new ParcelFileDescriptor.AutoCloseInputStream(

View File

@@ -40,6 +40,8 @@ import android.os.SystemClock;
import android.util.ArraySet; import android.util.ArraySet;
import android.view.Surface; import android.view.Surface;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
@@ -860,18 +862,19 @@ public abstract class Connection extends Conferenceable {
mFdFromInCall = fromInCall; mFdFromInCall = fromInCall;
mFdToInCall = toInCall; mFdToInCall = toInCall;
mPipeFromInCall = new InputStreamReader( mPipeFromInCall = new InputStreamReader(
new ParcelFileDescriptor.AutoCloseInputStream(fromInCall)); new FileInputStream(fromInCall.getFileDescriptor()));
mPipeToInCall = new OutputStreamWriter( 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 * 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 * 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. * 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 * This method is not thread-safe -- calling it from multiple threads simultaneously may
* lead to interleaved text. * lead to interleaved text.
*
* @param input The message to send to the in-call app. * @param input The message to send to the in-call app.
*/ */
public void write(String input) throws IOException { 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 * 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 * {@code null} if the RTT conversation has been terminated and there is no further data
* to read. * to read.
* * <p>
* This method is not thread-safe -- calling it from multiple threads simultaneously may * This method is not thread-safe -- calling it from multiple threads simultaneously may
* lead to interleaved text. * lead to interleaved text.
*
* @return A string containing text entered by the user, or {@code null} if the * @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. * 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 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
* be read. * be read.
*
* @return A string containing text entered by the user, or {@code null} if the user has * @return A string containing text entered by the user, or {@code null} if the user has
* not entered any new text yet. * not entered any new text yet.
*/ */
@@ -2620,7 +2625,6 @@ public abstract class Connection extends Conferenceable {
* {@link #onStartRtt(RttTextStream)} has succeeded. * {@link #onStartRtt(RttTextStream)} has succeeded.
*/ */
public final void sendRttInitiationSuccess() { public final void sendRttInitiationSuccess() {
setRttProperty();
mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this)); 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}. * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
*/ */
public final void sendRttInitiationFailure(int reason) { public final void sendRttInitiationFailure(int reason) {
unsetRttProperty();
mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason)); mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
} }
@@ -2641,7 +2644,6 @@ public abstract class Connection extends Conferenceable {
* side of the coll. * side of the coll.
*/ */
public final void sendRttSessionRemotelyTerminated() { public final void sendRttSessionRemotelyTerminated() {
unsetRttProperty();
mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this)); mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
} }
@@ -2941,22 +2943,6 @@ public abstract class Connection extends Conferenceable {
*/ */
public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {} 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) { static String toLogSafePhoneNumber(String number) {
// For unknown number, log empty string. // For unknown number, log empty string.
if (number == null) { if (number == null) {

View File

@@ -143,6 +143,8 @@ public final class ConnectionRequest implements Parcelable {
private final boolean mShouldShowIncomingCallUi; private final boolean mShouldShowIncomingCallUi;
private final ParcelFileDescriptor mRttPipeToInCall; private final ParcelFileDescriptor mRttPipeToInCall;
private final ParcelFileDescriptor mRttPipeFromInCall; 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. * @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() { public Connection.RttTextStream getRttTextStream() {
if (isRequestingRtt()) { if (isRequestingRtt()) {
return new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall); if (mRttTextStream == null) {
mRttTextStream = new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall);
}
return mRttTextStream;
} else { } else {
return null; return null;
} }

View File

@@ -143,6 +143,7 @@ public abstract class ConnectionService extends Service {
private static final String SESSION_HANDOVER_COMPLETE = "CS.hC"; private static final String SESSION_HANDOVER_COMPLETE = "CS.hC";
private static final String SESSION_EXTRAS_CHANGED = "CS.oEC"; private static final String SESSION_EXTRAS_CHANGED = "CS.oEC";
private static final String SESSION_START_RTT = "CS.+RTT"; 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_STOP_RTT = "CS.-RTT";
private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR"; private static final String SESSION_RTT_UPGRADE_RESPONSE = "CS.rTRUR";
private static final String SESSION_HANDOVER_FAILED = "CS.haF"; private static final String SESSION_HANDOVER_FAILED = "CS.haF";
@@ -1864,7 +1865,6 @@ public abstract class ConnectionService extends Service {
Log.d(this, "stopRtt(%s)", callId); Log.d(this, "stopRtt(%s)", callId);
if (mConnectionById.containsKey(callId)) { if (mConnectionById.containsKey(callId)) {
findConnectionForAction(callId, "stopRtt").onStopRtt(); findConnectionForAction(callId, "stopRtt").onStopRtt();
findConnectionForAction(callId, "stopRtt").unsetRttProperty();
} else if (mConferenceById.containsKey(callId)) { } else if (mConferenceById.containsKey(callId)) {
Log.w(this, "stopRtt called on a conference."); Log.w(this, "stopRtt called on a conference.");
} }