diff options
author | Christine Chen <christinech@google.com> | 2013-10-15 12:22:13 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-15 12:22:13 -0700 |
commit | 7298b75752c4260e165736faf2910564c109cde5 (patch) | |
tree | f43bb7862e06bd5470ad70a3f22958f69f413bab | |
parent | 3fe6ee99d33f99dacbd6273da94601cbfb491b1c (diff) | |
parent | dee25388edd6ae501034e8ad035df67b284b04db (diff) |
am ce535368: am 7a6a3dd6: am 346708a5: Merge "Clears notification when there is no call." into klp-dev
* commit 'ce53536803caf69a3d1fc6e417c18e3c0cbe6f2a':
Clears notification when there is no call.
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallApp.java | 2 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallPresenter.java | 15 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/StatusBarNotifier.java | 12 |
3 files changed, 27 insertions, 2 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallApp.java b/InCallUI/src/com/android/incallui/InCallApp.java index dcc78481b..7d276bce9 100644 --- a/InCallUI/src/com/android/incallui/InCallApp.java +++ b/InCallUI/src/com/android/incallui/InCallApp.java @@ -63,7 +63,7 @@ public class InCallApp extends Application { // TODO: Commands of this nature should exist in the CallList or a // CallController class that has access to CallCommandClient and // CallList. - InCallPresenter.getInstance().hangUpOngoingCall(); + InCallPresenter.getInstance().hangUpOngoingCall(context); } } } diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 2fbbf34bf..5830e726c 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -16,6 +16,7 @@ package com.android.incallui; +import com.android.incallui.service.PhoneNumberService; import com.google.android.collect.Sets; import com.google.common.base.Preconditions; @@ -211,6 +212,9 @@ public class InCallPresenter implements CallList.Listener { */ @Override public void onCallListChange(CallList callList) { + if (callList == null) { + return; + } InCallState newState = getPotentialStateFromCallList(callList); newState = startOrFinishUi(newState); @@ -270,8 +274,12 @@ public class InCallPresenter implements CallList.Listener { * Given the call list, return the state in which the in-call screen should be. */ public static InCallState getPotentialStateFromCallList(CallList callList) { + InCallState newState = InCallState.NO_CALLS; + if (callList == null) { + return newState; + } if (callList.getIncomingCall() != null) { newState = InCallState.INCOMING; } else if (callList.getOutgoingCall() != null) { @@ -321,10 +329,15 @@ public class InCallPresenter implements CallList.Listener { /** * Hangs up any active or outgoing calls. */ - public void hangUpOngoingCall() { + public void hangUpOngoingCall(Context context) { // By the time we receive this intent, we could be shut down and call list // could be null. Bail in those cases. if (mCallList == null) { + if (mStatusBarNotifier == null) { + // The In Call UI has crashed but the notification still stayed up. We should not + // come to this stage. + StatusBarNotifier.clearInCallNotification(context); + } return; } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 1690c5494..459921f1f 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -140,6 +140,15 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { mIsShowingNotification = false; } + /* package */ static void clearInCallNotification(Context backupContext) { + Log.i(StatusBarNotifier.class.getSimpleName(), + "Something terrible happened. Clear all InCall notifications"); + + NotificationManager notificationManager = + (NotificationManager) backupContext.getSystemService(Context.NOTIFICATION_SERVICE); + notificationManager.cancel(IN_CALL_NOTIFICATION); + } + /** * Helper method for updateInCallNotification() and * updateNotificationAndLaunchIncomingCallUi(): Update the phone app's @@ -390,6 +399,9 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { * Gets the most relevant call to display in the notification. */ private Call getCallToShow(CallList callList) { + if (callList == null) { + return null; + } Call call = callList.getIncomingCall(); if (call == null) { call = callList.getOutgoingCall(); |