summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-05-03 12:34:08 -0700
committerCopybara-Service <copybara-piper@google.com>2018-05-04 15:56:38 -0700
commit49f90b332c6e716196276dab0f3d7e21b56b696e (patch)
treea3f4c462a4d33b08eaeefb56b0ecdfe993d091eb /java
parentc1401221314601a479a7ad293cc382416f2304f3 (diff)
Add test to verify no crash on multiple DialerCall#onRemovedFromCallList.
This change also add a null check for RttCall when saving RTT transcript. Test: DialerCallTest PiperOrigin-RevId: 195293823 Change-Id: I67cf3410480ac106933486d9d31f0fbb3183b074
Diffstat (limited to 'java')
-rw-r--r--java/com/android/incallui/call/DialerCall.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index 9e1e17e2a..77e2ea30b 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -1058,6 +1058,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
}
@TargetApi(28)
+ @Nullable
public RttCall getRttCall() {
if (!isActiveRttCall()) {
return null;
@@ -1111,16 +1112,18 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
if (!BuildCompat.isAtLeastP()) {
return;
}
- // Save any remaining text in the buffer that's not shown by UI yet.
- // This may happen when the call is switched to background before disconnect.
- try {
- String messageLeft = getRttCall().readImmediately();
- if (!TextUtils.isEmpty(messageLeft)) {
- rttTranscript =
- RttChatMessage.getRttTranscriptWithNewRemoteMessage(rttTranscript, messageLeft);
+ if (getRttCall() != null) {
+ // Save any remaining text in the buffer that's not shown by UI yet.
+ // This may happen when the call is switched to background before disconnect.
+ try {
+ String messageLeft = getRttCall().readImmediately();
+ if (!TextUtils.isEmpty(messageLeft)) {
+ rttTranscript =
+ RttChatMessage.getRttTranscriptWithNewRemoteMessage(rttTranscript, messageLeft);
+ }
+ } catch (IOException e) {
+ LogUtil.e("DialerCall.saveRttTranscript", "error when reading remaining message", e);
}
- } catch (IOException e) {
- LogUtil.e("DialerCall.saveRttTranscript", "error when reading remaining message", e);
}
// Don't save transcript if it's empty.
if (rttTranscript.getMessagesCount() == 0) {
@@ -1662,7 +1665,6 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
if (videoTechManager != null) {
videoTechManager.dispatchRemovedFromCallList();
}
- // TODO(a bug): Add tests for it to make sure no crash on subsequent call to this method.
// TODO(wangqi): Consider moving this to a DialerCallListener.
if (rttTranscript != null && !isCallRemoved) {
saveRttTranscript();