Skip to content

Commit d33be52

Browse files
Hall LiuAndroid (Google) Code Review
authored andcommitted
Merge "Do not throw IOException from RttCall.read()" into oc-mr1-dev
2 parents fac2141 + b1c8a77 commit d33be52

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
@@ -38877,7 +38877,7 @@ package android.telecom {
3887738877

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

4212342123
public static final class Call.RttCall {
4212442124
method public int getRttAudioMode();
42125-
method public java.lang.String read() throws java.io.IOException;
42125+
method public java.lang.String read();
4212642126
method public java.lang.String readImmediately() throws java.io.IOException;
4212742127
method public void setRttMode(int);
4212842128
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
@@ -39120,7 +39120,7 @@ package android.telecom {
3912039120

3912139121
public static final class Call.RttCall {
3912239122
method public int getRttAudioMode();
39123-
method public java.lang.String read() throws java.io.IOException;
39123+
method public java.lang.String read();
3912439124
method public java.lang.String readImmediately() throws java.io.IOException;
3912539125
method public void setRttMode(int);
3912639126
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)