From f3a65b2e9bcbf162aa8a715709028b2deeb2ca09 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Thu, 18 Jun 2015 14:23:34 -0700 Subject: Fix for InCallUI finishing too quickly to display error dialog Increase the delay before disconnecting the call for DisconnectCause.ERROR, so that the user has time to acknowledge the error. To avoid regressing on b/20956721, keep track of any calls that are pending a disconnect. If the user has explicitly dismissed the error dialog, disconnect the call immediately to avoid blocking the UI any further. Bug: 21436856 Change-Id: I339cdbf1ba99fda5b1f5c8c31f722c97b64f487f --- InCallUI/src/com/android/incallui/CallList.java | 22 +++++++++++++++++++++- .../src/com/android/incallui/InCallActivity.java | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index 5d38e2477..c0014bdfe 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -28,6 +28,7 @@ import com.google.common.collect.Maps; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -60,6 +61,8 @@ public class CallList { new ConcurrentHashMap(8, 0.9f, 1)); private final HashMap> mCallUpdateListenerMap = Maps .newHashMap(); + private final Set mPendingDisconnectCalls = Collections.newSetFromMap( + new ConcurrentHashMap(8, 0.9f, 1)); /** * Static singleton accessor method. @@ -390,6 +393,19 @@ public class CallList { notifyGenericListeners(); } + /** + * Called when the user has dismissed an error dialog. This indicates acknowledgement of + * the disconnect cause, and that any pending disconnects should immediately occur. + */ + public void onErrorDialogDismissed() { + final Iterator iterator = mPendingDisconnectCalls.iterator(); + while (iterator.hasNext()) { + Call call = iterator.next(); + iterator.remove(); + finishDisconnectedCall(call); + } + } + /** * Processes an update for a single call. * @@ -438,6 +454,7 @@ public class CallList { // Set up a timer to destroy the call after X seconds. final Message msg = mHandler.obtainMessage(EVENT_DISCONNECTED_TIMEOUT, call); mHandler.sendMessageDelayed(msg, getDelayForDisconnect(call)); + mPendingDisconnectCalls.add(call); mCallById.put(call.getId(), call); mCallByTelecommCall.put(call.getTelecommCall(), call); @@ -467,9 +484,9 @@ public class CallList { delay = DISCONNECTED_CALL_SHORT_TIMEOUT_MS; break; case DisconnectCause.REMOTE: + case DisconnectCause.ERROR: delay = DISCONNECTED_CALL_MEDIUM_TIMEOUT_MS; break; - case DisconnectCause.ERROR: case DisconnectCause.REJECTED: case DisconnectCause.MISSED: case DisconnectCause.CANCELED: @@ -505,6 +522,9 @@ public class CallList { * Sets up a call for deletion and notifies listeners of change. */ private void finishDisconnectedCall(Call call) { + if (mPendingDisconnectCalls.contains(call)) { + mPendingDisconnectCalls.remove(call); + } call.setState(Call.State.IDLE); updateCallInMap(call); notifyGenericListeners(); diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 01ddac4ec..ab7dd1b8b 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -861,6 +861,7 @@ public class InCallActivity extends Activity implements FragmentDisplayManager { private void onDialogDismissed() { mDialog = null; + CallList.getInstance().onErrorDialogDismissed(); InCallPresenter.getInstance().onDismissDialog(); } } -- cgit v1.2.3