From 1e89cbccf3f6ce0a6251af5f810bea63fa0f5f44 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Fri, 11 Oct 2013 19:00:53 -0700 Subject: Recalculate in-call state when activity ends. Previoulsy we only calculated the in-call state on activity end if TeleService was still connected. This was insufficient as transitions to NO_CALLS (which happens generally when TeleService disconnects) may rely on the recalculation after the activity ends in cases where the app finish()es out of in-call's normal flow (like hitting back button while the call is ending). bug:11122139 Change-Id: I02eb8e7a977048d6f167c11a3f28e7aa629bdbe2 --- .../src/com/android/incallui/InCallPresenter.java | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 1b9f60cc2..2fbbf34bf 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -135,6 +135,7 @@ public class InCallPresenter implements CallList.Listener { */ public void setActivity(InCallActivity inCallActivity) { boolean updateListeners = false; + boolean doAttemptCleanup = false; if (inCallActivity != null) { if (mInCallActivity == null) { @@ -171,9 +172,12 @@ public class InCallPresenter implements CallList.Listener { Log.i(this, "UI Destroyed)"); updateListeners = true; mInCallActivity = null; - attemptCleanup(); - } + // We attempt cleanup for the destroy case but only after we recalculate the state + // to see if we need to come back up or stay shut down. This is why we do the cleanup + // after the call to onCallListChange() instead of directly here. + doAttemptCleanup = true; + } // Messages can come from the telephony layer while the activity is coming up // and while the activity is going down. So in both cases we need to recalculate what @@ -183,11 +187,20 @@ public class InCallPresenter implements CallList.Listener { // (2) All calls could disconnect and then get a new incoming call before the // activity is destroyed. // - // ... but only if we are still connected (or got a new connection) to the service. - // Otherwise the service will come back up when it needs us. - if (updateListeners && mServiceConnected) { + // b/1122139 - We previously had a check for mServiceConnected here as well, but there are + // cases where we need to recalculate the current state even if the service in not + // connected. In particular the case where startOrFinish() is called while the app is + // already finish()ing. In that case, we skip updating the state with the knowledge that + // we will check again once the activity has finished. That means we have to recalculate the + // state here even if the service is disconnected since we may not have finished a state + // transition while finish()ing. + if (updateListeners) { onCallListChange(mCallList); } + + if (doAttemptCleanup) { + attemptCleanup(); + } } /** -- cgit v1.2.3