diff options
author | wangqi <wangqi@google.com> | 2018-04-30 11:55:07 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-30 18:16:45 -0700 |
commit | bed9e2f7d26e21c4f68cb5b3f0641e3110fbef77 (patch) | |
tree | 798731922b81da082ae8da9b1b76284d5c3b4b59 /java/com/android/incallui/call/DialerCall.java | |
parent | bae70895a77ebb7c24ec16aa73b986cb11434c67 (diff) |
Store RTT transcript message received when UI is in background.
If the call disconnects when RTT UI is in background, any messages received from remote should be saved to transcript. RttCallPrensenter might not be available at this point, so the job is done inside DialerCall#onRemovedFromCallList
Bug: 78576798
Test: presubmit
PiperOrigin-RevId: 194821868
Change-Id: I10381b1c292f918763360c7a4bcd0470250f2293
Diffstat (limited to 'java/com/android/incallui/call/DialerCall.java')
-rw-r--r-- | java/com/android/incallui/call/DialerCall.java | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index d57de15e5..d736edc94 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -83,6 +83,7 @@ import com.android.dialer.util.PermissionsUtil; import com.android.incallui.audiomode.AudioModeProvider; import com.android.incallui.call.state.DialerCallState; import com.android.incallui.latencyreport.LatencyReport; +import com.android.incallui.rtt.protocol.RttChatMessage; import com.android.incallui.speakeasy.runtime.Constraints; import com.android.incallui.videotech.VideoTech; import com.android.incallui.videotech.VideoTech.VideoTechListener; @@ -92,6 +93,7 @@ import com.android.incallui.videotech.ims.ImsVideoTech; import com.android.incallui.videotech.utils.VideoUtils; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; +import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; @@ -1084,6 +1086,28 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa getTelecomCall().respondToRttRequest(rttRequestId, accept); } + @TargetApi(28) + private void saveRttTranscript() { + 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); + } + } catch (IOException e) { + LogUtil.e("DialerCall.saveRttTranscript", "error when reading remaining message", e); + } + Futures.addCallback( + RttTranscriptUtil.saveRttTranscript(context, rttTranscript), + new DefaultFutureCallback<>(), + MoreExecutors.directExecutor()); + } + public boolean hasReceivedVideoUpgradeRequest() { return VideoUtils.hasReceivedVideoUpgradeRequest(getVideoTech().getSessionModificationState()); } @@ -1615,11 +1639,9 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa 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) { - Futures.addCallback( - RttTranscriptUtil.saveRttTranscript(context, rttTranscript), - new DefaultFutureCallback<>(), - MoreExecutors.directExecutor()); + saveRttTranscript(); } isCallRemoved = true; } |