From be55a98f79c4721af7e4b1bd6854271d19f9333f Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Sun, 15 Sep 2013 15:43:33 -0700 Subject: Shut down if UI starts after service is disconnected. Additionally, this change can cause multiple calls to attemptToCleanup() so the change adds appropriate null checks. bug:10767438 Change-Id: Ieeb4a00653a6b3bcacca105d649ca9efd8ae8d44 --- .../src/com/android/incallui/InCallPresenter.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 47b0871ae..82da5b8f7 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -127,6 +127,16 @@ public class InCallPresenter implements CallList.Listener { boolean updateListeners = false; if (inCallActivity != null) { + // When the UI comes up, we need to first check the state of the Service. + // If the service is not attached, that means that a call probably connected and + // then immediately disconnected before the UI was able to come up. A disconnected + // service means we dont have calls, so start tearing down the UI instead. + if (mServiceConnected == false) { + inCallActivity.finish(); + attemptCleanup(); + return; + } + if (mInCallActivity == null) { updateListeners = true; Log.i(this, "UI Initialized"); @@ -421,17 +431,23 @@ public class InCallPresenter implements CallList.Listener { // blow away stale contact info so that we get fresh data on // the next set of calls - mContactInfoCache.clearCache(); + if (mContactInfoCache != null) { + mContactInfoCache.clearCache(); + } mContactInfoCache = null; mProximitySensor = null; mAudioModeProvider = null; - removeListener(mStatusBarNotifier); + if (mStatusBarNotifier != null) { + removeListener(mStatusBarNotifier); + } mStatusBarNotifier = null; - mCallList.removeListener(this); + if (mCallList != null) { + mCallList.removeListener(this); + } mCallList = null; mContext = null; -- cgit v1.2.3