diff options
author | Hall Liu <hallliu@google.com> | 2017-04-04 23:31:37 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-04-04 23:31:38 +0000 |
commit | f6f3c16dfbc9c00513f36fa53d20f7fa65992b3c (patch) | |
tree | 96c9d8d0b73eef96d88ab6f0d671677cd073ec67 /telecomm/java/android/telecom/Call.java | |
parent | f19c52d20dff52c33776b4663359b83541ca3272 (diff) | |
parent | ffa4a812f88effeaf293643601a9f2b8e18c517d (diff) |
Merge "Add @TestApi annotations to CS-side RTT APIs for CTS"
Diffstat (limited to 'telecomm/java/android/telecom/Call.java')
-rw-r--r-- | telecomm/java/android/telecom/Call.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java index ded28b0cb4c0..2ec95cc97101 100644 --- a/telecomm/java/android/telecom/Call.java +++ b/telecomm/java/android/telecom/Call.java @@ -1001,15 +1001,24 @@ 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() { - 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); + public String read() throws IOException { + int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE); + if (numRead < 0) { + return null; + } + return new String(mReadBuffer, 0, numRead); + } + + /** + * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to + * be read. + * @return A string containing text entered by the user, or {@code null} if the user has + * not entered any new text yet. + */ + public String readImmediately() throws IOException { + if (mReceiveStream.ready()) { + return read(); + } else { return null; } } |