Merge "Do not throw IOException from RttCall.read()" into oc-mr1-dev

am: d33be52592

Change-Id: I9fe75eee8b3aaf8d96de20dfffbff2a0ad7e6508
This commit is contained in:
Hall Liu
2017-08-17 16:27:04 +00:00
committed by android-build-merger
4 changed files with 17 additions and 8 deletions

View File

@@ -38906,7 +38906,7 @@ package android.telecom {
public static final class Call.RttCall {
method public int getRttAudioMode();
method public java.lang.String read() throws java.io.IOException;
method public java.lang.String read();
method public java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException;

View File

@@ -42151,7 +42151,7 @@ package android.telecom {
public static final class Call.RttCall {
method public int getRttAudioMode();
method public java.lang.String read() throws java.io.IOException;
method public java.lang.String read();
method public java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException;

View File

@@ -39149,7 +39149,7 @@ package android.telecom {
public static final class Call.RttCall {
method public int getRttAudioMode();
method public java.lang.String read() throws java.io.IOException;
method public java.lang.String read();
method public java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException;

View File

@@ -1089,12 +1089,17 @@ public final class Call {
* @return A string containing text sent by the remote user, or {@code null} if the
* conversation has been terminated or if there was an error while reading.
*/
public String read() throws IOException {
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
if (numRead < 0) {
public String read() {
try {
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
if (numRead < 0) {
return null;
}
return new String(mReadBuffer, 0, numRead);
} catch (IOException e) {
Log.w(this, "Exception encountered when reading from InputStreamReader: %s", e);
return null;
}
return new String(mReadBuffer, 0, numRead);
}
/**
@@ -1105,7 +1110,11 @@ public final class Call {
*/
public String readImmediately() throws IOException {
if (mReceiveStream.ready()) {
return read();
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
if (numRead < 0) {
return null;
}
return new String(mReadBuffer, 0, numRead);
} else {
return null;
}