Do not throw IOException from RttCall.read()
Modify the signature of read() to no longer throw an IOException
Change-Id: Ib5a1d8615a4bd66716a54c53865a2d560f33de83
Test: builds
Fixes: 63769529
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index c1289d3..e13bd61 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -1089,12 +1089,17 @@
* @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 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;
}