Fix issue where incoming calls go into DND mode while ringing.
The previous logic for setting auto-DND mode needed a tweak. We should
only suppress notifications when the earpiece has ACTIVE focus (ie
not during ringing).
Bug: 31614063
Change-Id: I9944e8a181421f78f7e691154f571b4348fd212c
diff --git a/src/com/android/server/telecom/CallAudioRouteStateMachine.java b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
index 04a48d4..ce03e61 100644
--- a/src/com/android/server/telecom/CallAudioRouteStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
@@ -282,7 +282,9 @@
super.enter();
setSpeakerphoneOn(false);
setBluetoothOn(false);
- setNotificationsSuppressed(true);
+ if (mAudioFocusType == ACTIVE_FOCUS) {
+ setNotificationsSuppressed(true);
+ }
CallAudioState newState = new CallAudioState(mIsMuted, ROUTE_EARPIECE,
mAvailableRoutes);
setSystemAudioState(newState);
@@ -333,6 +335,10 @@
transitionTo(mActiveSpeakerRoute);
return HANDLED;
case SWITCH_FOCUS:
+ if (msg.arg1 == ACTIVE_FOCUS) {
+ setNotificationsSuppressed(true);
+ }
+
if (msg.arg1 == NO_FOCUS) {
reinitialize();
}
@@ -1284,19 +1290,23 @@
return;
}
+ Log.i(this, "setNotificationsSuppressed: on=%s; suppressed=%s", (on ? "yes" : "no"),
+ (mAreNotificationSuppressed ? "yes" : "no"));
if (on) {
- // Enabling suppression of notifications.
- int interruptionFilter = mInterruptionFilterProxy.getCurrentInterruptionFilter();
- if (interruptionFilter == NotificationManager.INTERRUPTION_FILTER_ALL) {
- // No interruption filter is specified, so suppress notifications by setting the
- // current filter to alarms-only.
- mAreNotificationSuppressed = true;
- mInterruptionFilterProxy.setInterruptionFilter(
- NotificationManager.INTERRUPTION_FILTER_ALARMS);
- } else {
- // Interruption filter is already chosen by the user, so do not attempt to change
- // it.
- mAreNotificationSuppressed = false;
+ if (!mAreNotificationSuppressed) {
+ // Enabling suppression of notifications.
+ int interruptionFilter = mInterruptionFilterProxy.getCurrentInterruptionFilter();
+ if (interruptionFilter == NotificationManager.INTERRUPTION_FILTER_ALL) {
+ // No interruption filter is specified, so suppress notifications by setting the
+ // current filter to alarms-only.
+ mAreNotificationSuppressed = true;
+ mInterruptionFilterProxy.setInterruptionFilter(
+ NotificationManager.INTERRUPTION_FILTER_ALARMS);
+ } else {
+ // Interruption filter is already chosen by the user, so do not attempt to change
+ // it.
+ mAreNotificationSuppressed = false;
+ }
}
} else {
// Disabling suppression of notifications.