Fix readImmediately for CTS

The readImmediately API (only used by CTS so far) was broken by a
previous change that unknowingly changed the semantics of ready().
Fixing this so that CTS tests work again.

Change-Id: I6970713eae2a01dd07e30778ca8ee0d9bc7dfeb9
Fixes: 111125833
Test: CTS
This commit is contained in:
Hall Liu
2018-07-03 15:17:41 -07:00
parent 730a25995e
commit 17eb1bd6e4

View File

@@ -854,6 +854,8 @@ public abstract class Connection extends Conferenceable {
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 abstract class Connection extends Conferenceable {
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 @@ public abstract class Connection extends Conferenceable {
* not entered any new text yet.
*/
public String readImmediately() throws IOException {
if (mPipeFromInCall.ready()) {
if (mFromInCallFileInputStream.available() > 0) {
return read();
} else {
return null;