Merge "Fix readImmediately for CTS" into pi-dev
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 3e97c8f..468c8fa 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -854,6 +854,8 @@
private final OutputStreamWriter mPipeToInCall;
private final ParcelFileDescriptor mFdFromInCall;
private final ParcelFileDescriptor mFdToInCall;
+
+ private final FileInputStream mFromInCallFileInputStream;
private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
/**
@@ -862,11 +864,11 @@
public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
mFdFromInCall = fromInCall;
mFdToInCall = toInCall;
+ mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
// Wrap the FileInputStream in a Channel so that it's interruptible.
mPipeFromInCall = new InputStreamReader(
- Channels.newInputStream(Channels.newChannel(
- new FileInputStream(fromInCall.getFileDescriptor()))));
+ Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
mPipeToInCall = new OutputStreamWriter(
new FileOutputStream(toInCall.getFileDescriptor()));
}
@@ -914,7 +916,7 @@
* not entered any new text yet.
*/
public String readImmediately() throws IOException {
- if (mPipeFromInCall.ready()) {
+ if (mFromInCallFileInputStream.available() > 0) {
return read();
} else {
return null;