Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/AvalancheControllerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ class AvalancheControllerTest : SysuiTestCase() { // Initialize AvalancheController and TestableHeadsUpManager during setUp instead of // declaration, where mocks are null mAvalancheController = AvalancheController(dumpManager) mAvalancheController = AvalancheController(dumpManager, mUiEventLoggerFake) testableHeadsUpManager = TestableHeadsUpManager( Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +27 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.when; import android.app.Notification; import android.app.PendingIntent; import android.app.Person; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.FlagsParameterization; import android.testing.TestableLooper; Loading Loading @@ -147,7 +148,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Override public void SysuiSetup() throws Exception { super.SysuiSetup(); mAvalancheController = new AvalancheController(dumpManager); mAvalancheController = new AvalancheController(dumpManager, mUiEventLoggerFake); } @Test Loading Loading @@ -610,7 +611,31 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { } @Test public void testPinEntry_logsPeek() { @EnableFlags(NotificationThrottleHun.FLAG_NAME) public void testPinEntry_logsPeek_throttleEnabled() { final BaseHeadsUpManager hum = createHeadsUpManager(); // Needs full screen intent in order to be pinned final BaseHeadsUpManager.HeadsUpEntry entryToPin = hum.new HeadsUpEntry( HeadsUpManagerTestUtil.createFullScreenIntentEntry(/* id = */ 0, mContext)); // Note: the standard way to show a notification would be calling showNotification rather // than onAlertEntryAdded. However, in practice showNotification in effect adds // the notification and then updates it; in order to not log twice, the entry needs // to have a functional ExpandableNotificationRow that can keep track of whether it's // pinned or not (via isRowPinned()). That feels like a lot to pull in to test this one bit. hum.onEntryAdded(entryToPin); assertEquals(2, mUiEventLoggerFake.numLogs()); assertEquals(AvalancheController.ThrottleEvent.SHOWN.getId(), mUiEventLoggerFake.eventId(0)); assertEquals(BaseHeadsUpManager.NotificationPeekEvent.NOTIFICATION_PEEK.getId(), mUiEventLoggerFake.eventId(1)); } @Test @DisableFlags(NotificationThrottleHun.FLAG_NAME) public void testPinEntry_logsPeek_throttleDisabled() { final BaseHeadsUpManager hum = createHeadsUpManager(); // Needs full screen intent in order to be pinned Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { mContext.getOrCreateTestableResources().addOverride( R.integer.ambient_notification_extension_time, 500); mAvalancheController = new AvalancheController(dumpManager); mAvalancheController = new AvalancheController(dumpManager, mUiEventLogger); } @Test Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt +26 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.statusbar.policy import android.util.Log import androidx.annotation.VisibleForTesting import com.android.internal.logging.UiEvent import com.android.internal.logging.UiEventLogger import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager Loading @@ -35,6 +37,7 @@ class AvalancheController @Inject constructor( dumpManager: DumpManager, private val uiEventLogger: UiEventLogger ) : Dumpable { private val tag = "AvalancheController" Loading Loading @@ -65,6 +68,21 @@ constructor( // For debugging only @VisibleForTesting var debugDropSet: MutableSet<HeadsUpEntry> = HashSet() enum class ThrottleEvent(private val id: Int) : UiEventLogger.UiEventEnum { @UiEvent(doc = "HUN was shown.") SHOWN(1812), @UiEvent(doc = "HUN was dropped to show higher priority HUNs.") DROPPED(1813), @UiEvent(doc = "HUN was removed while waiting to show.") REMOVED(1814); override fun getId(): Int { return id } } init { dumpManager.registerNormalDumpable(tag, /* module */ this) } Loading Loading @@ -145,6 +163,7 @@ constructor( log { "$fn => remove from next" } if (entry in nextMap) nextMap.remove(entry) if (entry in nextList) nextList.remove(entry) uiEventLogger.log(ThrottleEvent.REMOVED) } else if (entry in debugDropSet) { log { "$fn => remove from dropset" } debugDropSet.remove(entry) Loading Loading @@ -268,6 +287,7 @@ constructor( private fun showNow(entry: HeadsUpEntry, runnableList: MutableList<Runnable>) { log { "SHOW: " + getKey(entry) } uiEventLogger.log(ThrottleEvent.SHOWN) headsUpEntryShowing = entry runnableList.forEach { Loading Loading @@ -295,6 +315,12 @@ constructor( // Remove runnable labels for dropped huns val listToDrop = nextList.subList(1, nextList.size) // Log dropped HUNs for (e in listToDrop) { uiEventLogger.log(ThrottleEvent.DROPPED) } if (debug) { // Clear runnable labels for (e in listToDrop) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/AvalancheControllerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -78,7 +78,7 @@ class AvalancheControllerTest : SysuiTestCase() { // Initialize AvalancheController and TestableHeadsUpManager during setUp instead of // declaration, where mocks are null mAvalancheController = AvalancheController(dumpManager) mAvalancheController = AvalancheController(dumpManager, mUiEventLoggerFake) testableHeadsUpManager = TestableHeadsUpManager( Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +27 −2 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.when; import android.app.Notification; import android.app.PendingIntent; import android.app.Person; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.FlagsParameterization; import android.testing.TestableLooper; Loading Loading @@ -147,7 +148,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { @Override public void SysuiSetup() throws Exception { super.SysuiSetup(); mAvalancheController = new AvalancheController(dumpManager); mAvalancheController = new AvalancheController(dumpManager, mUiEventLoggerFake); } @Test Loading Loading @@ -610,7 +611,31 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { } @Test public void testPinEntry_logsPeek() { @EnableFlags(NotificationThrottleHun.FLAG_NAME) public void testPinEntry_logsPeek_throttleEnabled() { final BaseHeadsUpManager hum = createHeadsUpManager(); // Needs full screen intent in order to be pinned final BaseHeadsUpManager.HeadsUpEntry entryToPin = hum.new HeadsUpEntry( HeadsUpManagerTestUtil.createFullScreenIntentEntry(/* id = */ 0, mContext)); // Note: the standard way to show a notification would be calling showNotification rather // than onAlertEntryAdded. However, in practice showNotification in effect adds // the notification and then updates it; in order to not log twice, the entry needs // to have a functional ExpandableNotificationRow that can keep track of whether it's // pinned or not (via isRowPinned()). That feels like a lot to pull in to test this one bit. hum.onEntryAdded(entryToPin); assertEquals(2, mUiEventLoggerFake.numLogs()); assertEquals(AvalancheController.ThrottleEvent.SHOWN.getId(), mUiEventLoggerFake.eventId(0)); assertEquals(BaseHeadsUpManager.NotificationPeekEvent.NOTIFICATION_PEEK.getId(), mUiEventLoggerFake.eventId(1)); } @Test @DisableFlags(NotificationThrottleHun.FLAG_NAME) public void testPinEntry_logsPeek_throttleDisabled() { final BaseHeadsUpManager hum = createHeadsUpManager(); // Needs full screen intent in order to be pinned Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/HeadsUpManagerPhoneTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ public class HeadsUpManagerPhoneTest extends BaseHeadsUpManagerTest { mContext.getOrCreateTestableResources().addOverride( R.integer.ambient_notification_extension_time, 500); mAvalancheController = new AvalancheController(dumpManager); mAvalancheController = new AvalancheController(dumpManager, mUiEventLogger); } @Test Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt +26 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui.statusbar.policy import android.util.Log import androidx.annotation.VisibleForTesting import com.android.internal.logging.UiEvent import com.android.internal.logging.UiEventLogger import com.android.systemui.Dumpable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager Loading @@ -35,6 +37,7 @@ class AvalancheController @Inject constructor( dumpManager: DumpManager, private val uiEventLogger: UiEventLogger ) : Dumpable { private val tag = "AvalancheController" Loading Loading @@ -65,6 +68,21 @@ constructor( // For debugging only @VisibleForTesting var debugDropSet: MutableSet<HeadsUpEntry> = HashSet() enum class ThrottleEvent(private val id: Int) : UiEventLogger.UiEventEnum { @UiEvent(doc = "HUN was shown.") SHOWN(1812), @UiEvent(doc = "HUN was dropped to show higher priority HUNs.") DROPPED(1813), @UiEvent(doc = "HUN was removed while waiting to show.") REMOVED(1814); override fun getId(): Int { return id } } init { dumpManager.registerNormalDumpable(tag, /* module */ this) } Loading Loading @@ -145,6 +163,7 @@ constructor( log { "$fn => remove from next" } if (entry in nextMap) nextMap.remove(entry) if (entry in nextList) nextList.remove(entry) uiEventLogger.log(ThrottleEvent.REMOVED) } else if (entry in debugDropSet) { log { "$fn => remove from dropset" } debugDropSet.remove(entry) Loading Loading @@ -268,6 +287,7 @@ constructor( private fun showNow(entry: HeadsUpEntry, runnableList: MutableList<Runnable>) { log { "SHOW: " + getKey(entry) } uiEventLogger.log(ThrottleEvent.SHOWN) headsUpEntryShowing = entry runnableList.forEach { Loading Loading @@ -295,6 +315,12 @@ constructor( // Remove runnable labels for dropped huns val listToDrop = nextList.subList(1, nextList.size) // Log dropped HUNs for (e in listToDrop) { uiEventLogger.log(ThrottleEvent.DROPPED) } if (debug) { // Clear runnable labels for (e in listToDrop) { Loading