Remove more code from NotificationManager.
updateInCallNotification is not longer used. Delete along with code that
uses it.
Bug: 10605959
Change-Id: Idb69020a4dd99a36575aae0a77990f8c3ca693a9
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 3003290..bbffbd2 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -333,9 +333,6 @@
int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY;
new InCallTonePlayer(toneToPlay).start();
mVoicePrivacyState = true;
- // Update the VP icon:
- if (DBG) log("- updating notification for VP state...");
- mApplication.notificationMgr.updateInCallNotification();
}
break;
@@ -345,9 +342,6 @@
int toneToPlay = InCallTonePlayer.TONE_VOICE_PRIVACY;
new InCallTonePlayer(toneToPlay).start();
mVoicePrivacyState = false;
- // Update the VP icon:
- if (DBG) log("- updating notification for VP state...");
- mApplication.notificationMgr.updateInCallNotification();
}
break;
@@ -359,10 +353,6 @@
onResendMute();
break;
- case UPDATE_IN_CALL_NOTIFICATION:
- mApplication.notificationMgr.updateInCallNotification();
- break;
-
default:
// super.handleMessage(msg);
}
@@ -456,6 +446,7 @@
mCallWaitingTonePlayer = new InCallTonePlayer(InCallTonePlayer.TONE_CALL_WAITING);
mCallWaitingTonePlayer.start();
}
+
// in this case, just fall through like before, and call
// showIncomingCall().
if (DBG) log("- showing incoming call (this is a WAITING call)...");
@@ -679,55 +670,13 @@
if (state == PhoneConstants.State.OFFHOOK) {
// basically do onPhoneStateChanged + display the incoming call UI
onPhoneStateChanged(r);
+
if (DBG) log("- showing incoming call (unknown connection appeared)...");
final Connection c = (Connection) r.result;
notifyCallModelerOfNewRingingCall(c);
}
}
- /**
- * Informs the user about a new incoming call.
- *
- * In most cases this means "bring up the full-screen incoming call
- * UI". However, if an immersive activity is running, the system
- * NotificationManager will instead pop up a small notification window
- * on top of the activity.
- *
- * Watch out: be sure to call this method only once per incoming call,
- * or otherwise we may end up launching the InCallScreen multiple
- * times (which can lead to slow responsiveness and/or visible
- * glitches.)
- *
- * Note this method handles only the onscreen UI for incoming calls;
- * the ringer and/or vibrator are started separately (see the various
- * calls to Ringer.ring() in this class.)
- *
- * @see NotificationMgr#updateNotificationAndLaunchIncomingCallUi()
- */
- private void showIncomingCall() {
- log("showIncomingCall()... phone state = " + mCM.getState());
-
- // Before bringing up the "incoming call" UI, force any system
- // dialogs (like "recent tasks" or the power dialog) to close first.
- try {
- ActivityManagerNative.getDefault().closeSystemDialogs("call");
- } catch (RemoteException e) {
- }
-
- // Go directly to the in-call screen.
- // (No need to do anything special if we're already on the in-call
- // screen; it'll notice the phone state change and update itself.)
- mApplication.requestWakeState(PhoneGlobals.WakeState.FULL);
-
- // Post the "incoming call" notification *and* include the
- // fullScreenIntent that'll launch the incoming-call UI.
- // (This will usually take us straight to the incoming call
- // screen, but if an immersive activity is running it'll just
- // appear as a notification.)
- if (DBG) log("- updating notification from showIncomingCall()...");
- mApplication.notificationMgr.updateNotificationAndLaunchIncomingCallUi();
- }
-
private void notifyCallModelerOfNewRingingCall(Connection c) {
mCallModeler.onNewRingingConnection(c);
}
@@ -803,26 +752,6 @@
// remove it!
if (DBG) log("stopRing()... (OFFHOOK state)");
mRinger.stopRing();
-
- // Post a request to update the "in-call" status bar icon.
- //
- // We don't call NotificationMgr.updateInCallNotification()
- // directly here, for two reasons:
- // (1) a single phone state change might actually trigger multiple
- // onPhoneStateChanged() callbacks, so this prevents redundant
- // updates of the notification.
- // (2) we suppress the status bar icon while the in-call UI is
- // visible (see updateInCallNotification()). But when launching
- // an outgoing call the phone actually goes OFFHOOK slightly
- // *before* the InCallScreen comes up, so the delay here avoids a
- // brief flicker of the icon at that point.
-
- if (DBG) log("- posting UPDATE_IN_CALL_NOTIFICATION request...");
- // Remove any previous requests in the queue
- removeMessages(UPDATE_IN_CALL_NOTIFICATION);
- final int IN_CALL_NOTIFICATION_UPDATE_DELAY = 1000; // msec
- sendEmptyMessageDelayed(UPDATE_IN_CALL_NOTIFICATION,
- IN_CALL_NOTIFICATION_UPDATE_DELAY);
}
if (fgPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
@@ -1665,13 +1594,6 @@
mApplication.cdmaPhoneCallState.setCurrentCallState(
CdmaPhoneCallState.PhoneCallState.SINGLE_ACTIVE);
- // Display the incoming call to the user if the InCallScreen isn't
- // already in the foreground.
- if (!mApplication.isShowingCallScreen()) {
- if (DBG) log("- showing incoming call (CDMA call waiting)...");
- showIncomingCall();
- }
-
// Start timer for CW display
mCallWaitingTimeOut = false;
sendEmptyMessageDelayed(CALLWAITING_CALLERINFO_DISPLAY_DONE,
diff --git a/src/com/android/phone/InCallScreen.java b/src/com/android/phone/InCallScreen.java
index 4073bbb..53cd40d 100644
--- a/src/com/android/phone/InCallScreen.java
+++ b/src/com/android/phone/InCallScreen.java
@@ -494,10 +494,6 @@
updateExpandedViewState();
- // ...and update the in-call notification too, since the status bar
- // icon needs to be hidden while we're the foreground activity:
- mApp.notificationMgr.updateInCallNotification();
-
// Listen for broadcast intents that might affect the onscreen UI.
registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_HEADSET_PLUG));
@@ -760,8 +756,6 @@
updateExpandedViewState();
- // ...and the in-call notification too:
- mApp.notificationMgr.updateInCallNotification();
// ...and *always* reset the system bar back to its normal state
// when leaving the in-call UI.
// (While we're the foreground activity, we disable navigation in
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 5c33ab4..7771fa9 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -67,7 +67,7 @@
*
* @see PhoneGlobals.notificationMgr
*/
-public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteListener{
+public class NotificationMgr {
private static final String LOG_TAG = "NotificationMgr";
private static final boolean DBG =
(PhoneGlobals.DBG_LEVEL >= 1) && (SystemProperties.getInt("ro.debuggable", 0) == 1);
@@ -112,8 +112,6 @@
// used to track the missed call counter, default to 0.
private int mNumberMissedCalls = 0;
- private boolean mHasInCallNotification = false;
-
// used to track the notification of selected network unavailable
private boolean mSelectedUnavailableNotify = false;
@@ -278,10 +276,6 @@
mQueryHandler.startQuery(CALL_LOG_TOKEN, null, Calls.CONTENT_URI, CALL_LOG_PROJECTION,
where.toString(), null, Calls.DEFAULT_SORT_ORDER);
- // Update (or cancel) the in-call notification
- if (DBG) log("- updating in-call notification at startup...");
- updateInCallNotification();
-
// Depend on android.app.StatusBarManager to be set to
// disable(DISABLE_NONE) upon startup. This will be the
// case even if the phone app crashes.
@@ -705,229 +699,11 @@
}
/**
- * Updates the phone app's status bar notification based on the
- * current telephony state, or cancels the notification if the phone
- * is totally idle.
- *
- * This method will never actually launch the incoming-call UI.
- * (Use updateNotificationAndLaunchIncomingCallUi() for that.)
- */
- public void updateInCallNotification() {
- // allowFullScreenIntent=false means *don't* allow the incoming
- // call UI to be launched.
- updateInCallNotification(false);
- }
-
- /**
- * Updates the phone app's status bar notification *and* launches the
- * incoming call UI in response to a new incoming call.
- *
- * This is just like updateInCallNotification(), with one exception:
- * If an incoming call is ringing (or call-waiting), the notification
- * will also include a "fullScreenIntent" that will cause the
- * InCallScreen to be launched immediately, unless the current
- * foreground activity is marked as "immersive".
- *
- * (This is the mechanism that actually brings up the incoming call UI
- * when we receive a "new ringing connection" event from the telephony
- * layer.)
- *
- * Watch out: this method should ONLY be called directly from the code
- * path in CallNotifier that handles the "new ringing connection"
- * event from the telephony layer. All other places that update the
- * in-call notification (like for phone state changes) should call
- * updateInCallNotification() instead. (This ensures that we don't
- * end up launching the InCallScreen multiple times for a single
- * incoming call, which could cause slow responsiveness and/or visible
- * glitches.)
- *
- * Also note that this method is safe to call even if the phone isn't
- * actually ringing (or, more likely, if an incoming call *was*
- * ringing briefly but then disconnected). In that case, we'll simply
- * update or cancel the in-call notification based on the current
- * phone state.
- *
- * @see #updateInCallNotification(boolean)
- */
- public void updateNotificationAndLaunchIncomingCallUi() {
- // Set allowFullScreenIntent=true to indicate that we *should*
- // launch the incoming call UI if necessary.
- updateInCallNotification(true);
- }
-
- /**
- * Helper method for updateInCallNotification() and
- * updateNotificationAndLaunchIncomingCallUi(): Update the phone app's
- * status bar notification based on the current telephony state, or
- * cancels the notification if the phone is totally idle.
- *
- * @param allowFullScreenIntent If true, *and* an incoming call is
- * ringing, the notification will include a "fullScreenIntent"
- * pointing at the InCallScreen (which will cause the InCallScreen
- * to be launched.)
- * Watch out: This should be set to true *only* when directly
- * handling the "new ringing connection" event from the telephony
- * layer (see updateNotificationAndLaunchIncomingCallUi().)
- */
- private void updateInCallNotification(boolean allowFullScreenIntent) {
- if (DBG) log("updateInCallNotification(allowFullScreenIntent = "
- + allowFullScreenIntent + ")...");
-
- // Never display the "ongoing call" notification on
- // non-voice-capable devices, even if the phone is actually
- // offhook (like during a non-interactive OTASP call.)
- if (!PhoneGlobals.sVoiceCapable) {
- if (DBG) log("- non-voice-capable device; suppressing notification.");
- return;
- }
-
- // If the phone is idle, completely clean up all call-related
- // notifications.
- if (mCM.getState() == PhoneConstants.State.IDLE) {
- cancelInCall();
- cancelMute();
- cancelSpeakerphone();
- return;
- }
-
- final boolean hasRingingCall = mCM.hasActiveRingingCall();
- if (DBG) {
- log(" - hasRingingCall = " + hasRingingCall);
- }
-
- // Suppress the in-call notification if the InCallScreen is the
- // foreground activity, since it's already obvious that you're on a
- // call. (The status bar icon is needed only if you navigate *away*
- // from the in-call UI.)
- boolean suppressNotification = mApp.isShowingCallScreen();
- // if (DBG) log("- suppressNotification: initial value: " + suppressNotification);
-
- // ...except for a couple of cases where we *never* suppress the
- // notification:
- //
- // - If there's an incoming ringing call: always show the
- // notification, since the in-call notification is what actually
- // launches the incoming call UI in the first place (see
- // notification.fullScreenIntent below.) This makes sure that we'll
- // correctly handle the case where a new incoming call comes in but
- // the InCallScreen is already in the foreground.
- if (hasRingingCall) suppressNotification = false;
-
- // - If "voice privacy" mode is active: always show the notification,
- // since that's the only "voice privacy" indication we have.
- boolean enhancedVoicePrivacy = mApp.notifier.getVoicePrivacyState();
- // if (DBG) log("updateInCallNotification: enhancedVoicePrivacy = " + enhancedVoicePrivacy);
- if (enhancedVoicePrivacy) suppressNotification = false;
-
- if (suppressNotification) {
- if (DBG) log("- suppressNotification = true; reducing clutter in status bar...");
- cancelInCall();
- // Suppress the mute and speaker status bar icons too
- // (also to reduce clutter in the status bar.)
- cancelSpeakerphone();
- cancelMute();
- return;
- }
-
- mHasInCallNotification = true;
-
- // Activate a couple of special Notification features if an
- // incoming call is ringing:
- if (hasRingingCall) {
- if (DBG) log("- Using hi-pri notification for ringing call!");
-
- if (allowFullScreenIntent) {
-
- // Ugly hack alert:
- //
- // The NotificationManager has the (undocumented) behavior
- // that it will *ignore* the fullScreenIntent field if you
- // post a new Notification that matches the ID of one that's
- // already active. Unfortunately this is exactly what happens
- // when you get an incoming call-waiting call: the
- // "ongoing call" notification is already visible, so the
- // InCallScreen won't get launched in this case!
- // (The result: if you bail out of the in-call UI while on a
- // call and then get a call-waiting call, the incoming call UI
- // won't come up automatically.)
- //
- // The workaround is to just notice this exact case (this is a
- // call-waiting call *and* the InCallScreen is not in the
- // foreground) and manually cancel the in-call notification
- // before (re)posting it.
- //
- // TODO: there should be a cleaner way of avoiding this
- // problem (see discussion in bug 3184149.)
- Call ringingCall = mCM.getFirstActiveRingingCall();
- if ((ringingCall.getState() == Call.State.WAITING) && !mApp.isShowingCallScreen()) {
- Log.i(LOG_TAG, "updateInCallNotification: call-waiting! force relaunch...");
- // Cancel the IN_CALL_NOTIFICATION immediately before
- // (re)posting it; this seems to force the
- // NotificationManager to launch the fullScreenIntent.
- mNotificationManager.cancel(IN_CALL_NOTIFICATION);
- }
- }
- }
-
- // Finally, refresh the mute and speakerphone notifications (since
- // some phone state changes can indirectly affect the mute and/or
- // speaker state).
- updateSpeakerNotification();
- updateMuteNotification();
- }
-
- /**
- * Implemented for CallerInfoAsyncQuery.OnQueryCompleteListener interface.
- * refreshes the contentView when called.
- */
- @Override
- public void onQueryComplete(int token, Object cookie, CallerInfo ci){
- if (DBG) log("CallerInfo query complete (for NotificationMgr), "
- + "updating in-call notification..");
- if (DBG) log("- cookie: " + cookie);
- if (DBG) log("- ci: " + ci);
-
- if (cookie == this) {
- // Ok, this is the caller-id query we fired off in
- // updateInCallNotification(), presumably when an incoming call
- // first appeared. If the caller-id info matched any contacts,
- // compactName should now be a real person name rather than a raw
- // phone number:
- if (DBG) log("- compactName is now: "
- + PhoneUtils.getCompactNameFromCallerInfo(ci, mContext));
-
- // Now that our CallerInfo object has been fully filled-in,
- // refresh the in-call notification.
- if (DBG) log("- updating notification after query complete...");
- updateInCallNotification();
- } else {
- Log.w(LOG_TAG, "onQueryComplete: caller-id query from unknown source! "
- + "cookie = " + cookie);
- }
- }
-
- /**
- * Take down the in-call notification.
- * @see updateInCallNotification()
- */
- private void cancelInCall() {
- if (DBG) log("cancelInCall()...");
- mNotificationManager.cancel(IN_CALL_NOTIFICATION);
- mHasInCallNotification = false;
- }
-
- /**
* Completely take down the in-call notification *and* the mute/speaker
* notifications as well, to indicate that the phone is now idle.
*/
/* package */ void cancelCallInProgressNotifications() {
- if (DBG) log("cancelCallInProgressNotifications()...");
- if (!mHasInCallNotification) {
- return;
- }
-
if (DBG) log("cancelCallInProgressNotifications");
- cancelInCall();
cancelMute();
cancelSpeakerphone();
}
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 49a3427..b70b159 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -105,7 +105,6 @@
// Message codes; see mHandler below.
private static final int EVENT_SIM_NETWORK_LOCKED = 3;
private static final int EVENT_SIM_STATE_CHANGED = 8;
- private static final int EVENT_UPDATE_INCALL_NOTIFICATION = 9;
private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
private static final int EVENT_DATA_ROAMING_OK = 11;
private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12;
@@ -301,16 +300,6 @@
}
break;
- case EVENT_UPDATE_INCALL_NOTIFICATION:
- // Tell the NotificationMgr to update the "ongoing
- // call" icon in the status bar, if necessary.
- // Currently, this is triggered by a bluetooth headset
- // state change (since the status bar icon needs to
- // turn blue when bluetooth is active.)
- if (DBG) Log.d (LOG_TAG, "- updating in-call notification from handler...");
- notificationMgr.updateInCallNotification();
- break;
-
case EVENT_DATA_ROAMING_DISCONNECTED:
notificationMgr.showDataDisconnectedRoaming();
break;