Do not play sounds when unlocking from AoD.
Playing tap target sounds when unlocking from AoD
make them overlap. Let's skip taps and only play
the "unlock" sound.
Change-Id: I381e13604c61938ceceac903a8e2a52bf9192bbe
Fixes: 64411995
Test: runtest -x packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 7bc1a39..7067bc1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -80,6 +80,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.function.BooleanSupplier;
public class ExpandableNotificationRow extends ActivatableNotificationView
implements PluginListener<NotificationMenuRowPlugin> {
@@ -93,6 +94,7 @@
}
private LayoutListener mLayoutListener;
+ private boolean mDark;
private boolean mLowPriorityStateUpdated;
private final NotificationInflater mNotificationInflater;
private int mIconTransformContentShift;
@@ -175,6 +177,11 @@
private boolean mGroupExpansionChanging;
/**
+ * A supplier that returns true if keyguard is secure.
+ */
+ private BooleanSupplier mSecureStateProvider;
+
+ /**
* Whether or not a notification that is not part of a group of notifications can be manually
* expanded by the user.
*/
@@ -395,6 +402,14 @@
mAboveShelfChangedListener = aboveShelfChangedListener;
}
+ /**
+ * Sets a supplier that can determine whether the keyguard is secure or not.
+ * @param secureStateProvider A function that returns true if keyguard is secure.
+ */
+ public void setSecureStateProvider(BooleanSupplier secureStateProvider) {
+ mSecureStateProvider = secureStateProvider;
+ }
+
@Override
public boolean isDimmable() {
if (!getShowingLayout().isDimmable()) {
@@ -1454,6 +1469,7 @@
@Override
public void setDark(boolean dark, boolean fade, long delay) {
super.setDark(dark, fade, delay);
+ mDark = dark;
if (!mIsHeadsUp) {
// Only fade the showing view of the pulsing notification.
fade = false;
@@ -1468,6 +1484,17 @@
updateShelfIconColor();
}
+ /**
+ * Tap sounds should not be played when we're unlocking.
+ * Doing so would cause audio collision and the system would feel unpolished.
+ */
+ @Override
+ public boolean isSoundEffectsEnabled() {
+ final boolean mute = mDark && mSecureStateProvider != null &&
+ !mSecureStateProvider.getAsBoolean();
+ return !mute && super.isSoundEffectsEnabled();
+ }
+
public boolean isExpandable() {
if (mIsSummaryWithChildren && !mShowingPublic) {
return !mChildrenExpanded;