Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49f90b33 authored by wangqi's avatar wangqi Committed by Copybara-Service
Browse files

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
parent c1401221
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -1058,6 +1058,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
  }

  @TargetApi(28)
  @Nullable
  public RttCall getRttCall() {
    if (!isActiveRttCall()) {
      return null;
@@ -1111,6 +1112,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
    if (!BuildCompat.isAtLeastP()) {
      return;
    }
    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 {
@@ -1122,6 +1124,7 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa
      } 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) {
      return;
@@ -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();