Loading packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +27 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import com.android.systemui.statusbar.stack.StackScrollState; import java.util.ArrayList; import java.util.List; import java.util.function.BooleanSupplier; public class ExpandableNotificationRow extends ActivatableNotificationView implements PluginListener<NotificationMenuRowPlugin> { Loading @@ -93,6 +94,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } private LayoutListener mLayoutListener; private boolean mDark; private boolean mLowPriorityStateUpdated; private final NotificationInflater mNotificationInflater; private int mIconTransformContentShift; Loading Loading @@ -174,6 +176,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private OnExpandClickListener mOnExpandClickListener; 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. Loading Loading @@ -395,6 +402,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView 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()) { Loading Loading @@ -1454,6 +1469,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView @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; Loading @@ -1468,6 +1484,17 @@ public class ExpandableNotificationRow extends ActivatableNotificationView 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; Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +1 −0 Original line number Diff line number Diff line Loading @@ -6809,6 +6809,7 @@ public class StatusBar extends SystemUI implements DemoMode, row.setOnExpandClickListener(this); row.setRemoteViewClickHandler(mOnClickHandler); row.setInflationCallback(this); row.setSecureStateProvider(this::isKeyguardCurrentlySecure); // Get the app name. // Note that Notification.Builder#bindHeaderAppName has similar logic Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -134,4 +134,16 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { row.setAboveShelf(false); verify(listener).onAboveShelfStateChanged(false); } @Test public void testClickSound() throws Exception { Assert.assertTrue("Should play sounds by default.", mGroup.isSoundEffectsEnabled()); mGroup.setDark(true /* dark */, false /* fade */, 0 /* delay */); mGroup.setSecureStateProvider(()-> false); Assert.assertFalse("Shouldn't play sounds when dark and trusted.", mGroup.isSoundEffectsEnabled()); mGroup.setSecureStateProvider(()-> true); Assert.assertTrue("Should always play sounds when not trusted.", mGroup.isSoundEffectsEnabled()); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +27 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ import com.android.systemui.statusbar.stack.StackScrollState; import java.util.ArrayList; import java.util.List; import java.util.function.BooleanSupplier; public class ExpandableNotificationRow extends ActivatableNotificationView implements PluginListener<NotificationMenuRowPlugin> { Loading @@ -93,6 +94,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } private LayoutListener mLayoutListener; private boolean mDark; private boolean mLowPriorityStateUpdated; private final NotificationInflater mNotificationInflater; private int mIconTransformContentShift; Loading Loading @@ -174,6 +176,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private OnExpandClickListener mOnExpandClickListener; 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. Loading Loading @@ -395,6 +402,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView 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()) { Loading Loading @@ -1454,6 +1469,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView @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; Loading @@ -1468,6 +1484,17 @@ public class ExpandableNotificationRow extends ActivatableNotificationView 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; Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +1 −0 Original line number Diff line number Diff line Loading @@ -6809,6 +6809,7 @@ public class StatusBar extends SystemUI implements DemoMode, row.setOnExpandClickListener(this); row.setRemoteViewClickHandler(mOnClickHandler); row.setInflationCallback(this); row.setSecureStateProvider(this::isKeyguardCurrentlySecure); // Get the app name. // Note that Notification.Builder#bindHeaderAppName has similar logic Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -134,4 +134,16 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { row.setAboveShelf(false); verify(listener).onAboveShelfStateChanged(false); } @Test public void testClickSound() throws Exception { Assert.assertTrue("Should play sounds by default.", mGroup.isSoundEffectsEnabled()); mGroup.setDark(true /* dark */, false /* fade */, 0 /* delay */); mGroup.setSecureStateProvider(()-> false); Assert.assertFalse("Shouldn't play sounds when dark and trusted.", mGroup.isSoundEffectsEnabled()); mGroup.setSecureStateProvider(()-> true); Assert.assertTrue("Should always play sounds when not trusted.", mGroup.isSoundEffectsEnabled()); } }