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

This commit is contained in:
Hall Liu
2017-08-17 16:17:53 +00:00
committed by Android (Google) Code Review
4 changed files with 17 additions and 8 deletions

View File

@@ -38877,7 +38877,7 @@ package android.telecom {
public static final class Call.RttCall { public static final class Call.RttCall {
method public int getRttAudioMode(); 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 java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int); method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException; method public void write(java.lang.String) throws java.io.IOException;

View File

@@ -42122,7 +42122,7 @@ package android.telecom {
public static final class Call.RttCall { public static final class Call.RttCall {
method public int getRttAudioMode(); 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 java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int); method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException; method public void write(java.lang.String) throws java.io.IOException;

View File

@@ -39120,7 +39120,7 @@ package android.telecom {
public static final class Call.RttCall { public static final class Call.RttCall {
method public int getRttAudioMode(); 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 java.lang.String readImmediately() throws java.io.IOException;
method public void setRttMode(int); method public void setRttMode(int);
method public void write(java.lang.String) throws java.io.IOException; 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 * @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. * conversation has been terminated or if there was an error while reading.
*/ */
public String read() throws IOException { public String read() {
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE); try {
if (numRead < 0) { 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 null;
} }
return new String(mReadBuffer, 0, numRead);
} }
/** /**
@@ -1105,7 +1110,11 @@ public final class Call {
*/ */
public String readImmediately() throws IOException { public String readImmediately() throws IOException {
if (mReceiveStream.ready()) { 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 { } else {
return null; return null;
} }