From b1c8a77f5984e9a5a694fada9fd5dc491e518281 Mon Sep 17 00:00:00 2001 From: Hall Liu Date: Mon, 17 Jul 2017 17:04:41 -0700 Subject: [PATCH] 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 --- api/current.txt | 2 +- api/system-current.txt | 2 +- api/test-current.txt | 2 +- telecomm/java/android/telecom/Call.java | 19 ++++++++++++++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/api/current.txt b/api/current.txt index 7a2cecd930abc..1ff7e88e48e75 100644 --- a/api/current.txt +++ b/api/current.txt @@ -38870,7 +38870,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; diff --git a/api/system-current.txt b/api/system-current.txt index 27d3ee4299cc7..b4d5b1a6a4c83 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -42226,7 +42226,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; diff --git a/api/test-current.txt b/api/test-current.txt index 2478004e126a8..ea565f60ab7a8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -39105,7 +39105,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; diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index c1289d3f14012..e13bd61937199 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -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; }