Skip to content

Commit b1c8a77

Browse files
author
Hall Liu
committed
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
1 parent eea2441 commit b1c8a77

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

api/current.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38870,7 +38870,7 @@ package android.telecom {
3887038870

3887138871
public static final class Call.RttCall {
3887238872
method public int getRttAudioMode();
38873-
method public java.lang.String read() throws java.io.IOException;
38873+
method public java.lang.String read();
3887438874
method public java.lang.String readImmediately() throws java.io.IOException;
3887538875
method public void setRttMode(int);
3887638876
method public void write(java.lang.String) throws java.io.IOException;

api/system-current.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42226,7 +42226,7 @@ package android.telecom {
4222642226

4222742227
public static final class Call.RttCall {
4222842228
method public int getRttAudioMode();
42229-
method public java.lang.String read() throws java.io.IOException;
42229+
method public java.lang.String read();
4223042230
method public java.lang.String readImmediately() throws java.io.IOException;
4223142231
method public void setRttMode(int);
4223242232
method public void write(java.lang.String) throws java.io.IOException;

api/test-current.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39105,7 +39105,7 @@ package android.telecom {
3910539105

3910639106
public static final class Call.RttCall {
3910739107
method public int getRttAudioMode();
39108-
method public java.lang.String read() throws java.io.IOException;
39108+
method public java.lang.String read();
3910939109
method public java.lang.String readImmediately() throws java.io.IOException;
3911039110
method public void setRttMode(int);
3911139111
method public void write(java.lang.String) throws java.io.IOException;

telecomm/java/android/telecom/Call.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,12 +1089,17 @@ public void write(String input) throws IOException {
10891089
* @return A string containing text sent by the remote user, or {@code null} if the
10901090
* conversation has been terminated or if there was an error while reading.
10911091
*/
1092-
public String read() throws IOException {
1093-
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1094-
if (numRead < 0) {
1092+
public String read() {
1093+
try {
1094+
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1095+
if (numRead < 0) {
1096+
return null;
1097+
}
1098+
return new String(mReadBuffer, 0, numRead);
1099+
} catch (IOException e) {
1100+
Log.w(this, "Exception encountered when reading from InputStreamReader: %s", e);
10951101
return null;
10961102
}
1097-
return new String(mReadBuffer, 0, numRead);
10981103
}
10991104

11001105
/**
@@ -1105,7 +1110,11 @@ public String read() throws IOException {
11051110
*/
11061111
public String readImmediately() throws IOException {
11071112
if (mReceiveStream.ready()) {
1108-
return read();
1113+
int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1114+
if (numRead < 0) {
1115+
return null;
1116+
}
1117+
return new String(mReadBuffer, 0, numRead);
11091118
} else {
11101119
return null;
11111120
}

0 commit comments

Comments
 (0)