diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-04-12 23:23:09 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-04-12 23:23:09 +0000 |
commit | f599b4bbf9c9c0224f64934d78f00ba6690c6c7f (patch) | |
tree | 0f1f4cc08e164cde9f891f83749edff34eb94a89 /java/com/android/incallui | |
parent | 9ef6d8c84b7b33e069258d41db9eef16e3d2b9fa (diff) | |
parent | d6b10d559f345eab2dd3dd89b07cfc3fd79c59bc (diff) |
Merge "Add RTT transcript to call details."
Diffstat (limited to 'java/com/android/incallui')
5 files changed, 48 insertions, 8 deletions
diff --git a/java/com/android/incallui/RttCallPresenter.java b/java/com/android/incallui/RttCallPresenter.java index 5e8390793..21e28cee4 100644 --- a/java/com/android/incallui/RttCallPresenter.java +++ b/java/com/android/incallui/RttCallPresenter.java @@ -63,28 +63,34 @@ public class RttCallPresenter implements RttCallScreenDelegate, InCallStateListe LogUtil.enterBlock("RttCallPresenter.onRttCallScreenUiReady"); InCallPresenter.getInstance().addListener(this); startListenOnRemoteMessage(); - DialerCall call = CallList.getInstance().getActiveCall(); + DialerCall call = CallList.getInstance().getCallById(rttCallScreen.getCallId()); if (call != null) { rttCallScreen.onRestoreRttChat(call.getRttTranscript()); } } @Override + public void onSaveRttTranscript() { + LogUtil.enterBlock("RttCallPresenter.onSaveRttTranscript"); + DialerCall call = CallList.getInstance().getCallById(rttCallScreen.getCallId()); + if (call != null) { + saveTranscript(call); + } + } + + @Override public void onRttCallScreenUiUnready() { LogUtil.enterBlock("RttCallPresenter.onRttCallScreenUiUnready"); InCallPresenter.getInstance().removeListener(this); stopListenOnRemoteMessage(); - DialerCall call = CallList.getInstance().getActiveCall(); - if (call != null) { - saveTranscript(call); - } + onSaveRttTranscript(); } private void saveTranscript(DialerCall dialerCall) { LogUtil.enterBlock("RttCallPresenter.saveTranscript"); RttTranscript.Builder builder = RttTranscript.newBuilder(); builder - .setId(dialerCall.getNumber() + dialerCall.getCreationTimeMillis()) + .setId(String.valueOf(dialerCall.getCreationTimeMillis())) .setTimestamp(dialerCall.getCreationTimeMillis()) .setNumber(dialerCall.getNumber()) .addAllMessages(rttCallScreen.getRttTranscriptMessageList()); @@ -100,9 +106,9 @@ public class RttCallPresenter implements RttCallScreenDelegate, InCallStateListe } private void startListenOnRemoteMessage() { - DialerCall call = CallList.getInstance().getActiveCall(); + DialerCall call = CallList.getInstance().getCallById(rttCallScreen.getCallId()); if (call == null) { - LogUtil.i("RttCallPresenter.startListenOnRemoteMessage", "call is not active yet"); + LogUtil.i("RttCallPresenter.startListenOnRemoteMessage", "call does not exist"); return; } rttCall = call.getRttCall(); diff --git a/java/com/android/incallui/call/CallList.java b/java/com/android/incallui/call/CallList.java index eccdceeca..04e02c45b 100644 --- a/java/com/android/incallui/call/CallList.java +++ b/java/com/android/incallui/call/CallList.java @@ -745,6 +745,7 @@ public class CallList implements DialerCallDelegate { call.setState(DialerCall.State.IDLE); updateCallInMap(call); notifyGenericListeners(); + call.onDestroy(); } /** diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 3372c0329..5d32f46ad 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -57,6 +57,8 @@ import com.android.dialer.callintent.CallIntentParser; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.DefaultFutureCallback; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.duo.DuoComponent; @@ -74,6 +76,7 @@ import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.preferredsim.PreferredAccountRecorder; import com.android.dialer.rtt.RttTranscript; +import com.android.dialer.rtt.RttTranscriptUtil; import com.android.dialer.telecom.TelecomCallUtil; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.theme.R; @@ -86,6 +89,9 @@ import com.android.incallui.videotech.duo.DuoVideoTech; import com.android.incallui.videotech.empty.EmptyVideoTech; 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.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; @@ -536,6 +542,28 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa return countryIso; } + /** + * Called when call is disconnected and removed from {@link CallList}, UI may already be destroyed + * at this point. This is last chance to do something for the call. + */ + public void onDestroy() { + LogUtil.enterBlock("DialerCall.onDestroy"); + if (rttTranscript != null) { + RttTranscript rttTranscriptToSave = rttTranscript; + ListenableFuture<Void> future = + DialerExecutorComponent.get(context) + .backgroundExecutor() + .submit( + () -> { + new RttTranscriptUtil(context).saveRttTranscript(rttTranscriptToSave); + return null; + }); + Futures.addCallback(future, new DefaultFutureCallback<>(), MoreExecutors.directExecutor()); + // Sets to null so it won't be saved again when called multiple times. + rttTranscript = null; + } + } + private void updateIsVoiceMailNumber() { if (getHandle() != null && PhoneAccount.SCHEME_VOICEMAIL.equals(getHandle().getScheme())) { isVoicemailNumber = true; diff --git a/java/com/android/incallui/rtt/impl/RttChatFragment.java b/java/com/android/incallui/rtt/impl/RttChatFragment.java index 15baa8cfa..2d70b6b12 100644 --- a/java/com/android/incallui/rtt/impl/RttChatFragment.java +++ b/java/com/android/incallui/rtt/impl/RttChatFragment.java @@ -462,6 +462,9 @@ public class RttChatFragment extends Fragment } else { hideWaitingForJoinBanner(); } + if (primaryCallState.state() == State.DISCONNECTED) { + rttCallScreenDelegate.onSaveRttTranscript(); + } } private void showWaitingForJoinBanner() { diff --git a/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java b/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java index 8c484a844..990c0759e 100644 --- a/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java +++ b/java/com/android/incallui/rtt/protocol/RttCallScreenDelegate.java @@ -26,4 +26,6 @@ public interface RttCallScreenDelegate { void onRttCallScreenUiUnready(); void onLocalMessage(String message); + + void onSaveRttTranscript(); } |