merge in klp-release history after reset to klp-dev
diff --git a/src/com/android/incallui/InCallApp.java b/src/com/android/incallui/InCallApp.java index dcc7848..7d276bc 100644 --- a/src/com/android/incallui/InCallApp.java +++ b/src/com/android/incallui/InCallApp.java
@@ -63,7 +63,7 @@ // 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/src/com/android/incallui/InCallPresenter.java b/src/com/android/incallui/InCallPresenter.java index 2fbbf34..5830e72 100644 --- a/src/com/android/incallui/InCallPresenter.java +++ b/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 @@ */ @Override public void onCallListChange(CallList callList) { + if (callList == null) { + return; + } InCallState newState = getPotentialStateFromCallList(callList); newState = startOrFinishUi(newState); @@ -270,8 +274,12 @@ * 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 @@ /** * 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/src/com/android/incallui/StatusBarNotifier.java b/src/com/android/incallui/StatusBarNotifier.java index 1690c54..459921f 100644 --- a/src/com/android/incallui/StatusBarNotifier.java +++ b/src/com/android/incallui/StatusBarNotifier.java
@@ -140,6 +140,15 @@ 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 @@ * 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();