diff options
4 files changed, 63 insertions, 69 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java index 88bef91d043f..206b39c28da3 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/BaseHeadsUpManagerTest.java @@ -627,7 +627,7 @@ public class BaseHeadsUpManagerTest extends SysuiTestCase { hum.onEntryAdded(entryToPin); assertEquals(2, mUiEventLoggerFake.numLogs()); - assertEquals(AvalancheController.ThrottleEvent.SHOWN.getId(), + assertEquals(AvalancheController.ThrottleEvent.AVALANCHE_THROTTLING_HUN_SHOWN.getId(), mUiEventLoggerFake.eventId(0)); assertEquals(BaseHeadsUpManager.NotificationPeekEvent.NOTIFICATION_PEEK.getId(), mUiEventLoggerFake.eventId(1)); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/AvalancheProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/AvalancheProvider.kt index c29d700396af..a8fd082dd1e1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/AvalancheProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/AvalancheProvider.kt @@ -24,6 +24,7 @@ import android.util.Log import com.android.internal.logging.UiEventLogger import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.statusbar.notification.interruption.AvalancheSuppressor.AvalancheEvent import javax.inject.Inject // Class to track avalanche trigger event time. @@ -31,37 +32,41 @@ import javax.inject.Inject class AvalancheProvider @Inject constructor( - private val broadcastDispatcher: BroadcastDispatcher, - private val logger: VisualInterruptionDecisionLogger, - private val uiEventLogger: UiEventLogger, + private val broadcastDispatcher: BroadcastDispatcher, + private val logger: VisualInterruptionDecisionLogger, + private val uiEventLogger: UiEventLogger, ) { val TAG = "AvalancheProvider" val timeoutMs = 120000 var startTime: Long = 0L - private val avalancheTriggerIntents = mutableSetOf( + private val avalancheTriggerIntents = + mutableSetOf( Intent.ACTION_AIRPLANE_MODE_CHANGED, Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MANAGED_PROFILE_AVAILABLE, Intent.ACTION_USER_SWITCHED - ) + ) - private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - if (intent.action in avalancheTriggerIntents) { + private val broadcastReceiver: BroadcastReceiver = + object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.action in avalancheTriggerIntents) { - // Ignore when airplane mode turned on - if (intent.action == Intent.ACTION_AIRPLANE_MODE_CHANGED - && intent.getBooleanExtra(/* name= */ "state", /* defaultValue */ false)) { - Log.d(TAG, "broadcastReceiver: ignore airplane mode on") - return + // Ignore when airplane mode turned on + if ( + intent.action == Intent.ACTION_AIRPLANE_MODE_CHANGED && + intent.getBooleanExtra(/* name= */ "state", /* defaultValue */ false) + ) { + Log.d(TAG, "broadcastReceiver: ignore airplane mode on") + return + } + Log.d(TAG, "broadcastReceiver received intent.action=" + intent.action) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_RECEIVED_TRIGGERING_EVENT) + startTime = System.currentTimeMillis() } - Log.d(TAG, "broadcastReceiver received intent.action=" + intent.action) - uiEventLogger.log(AvalancheSuppressor.AvalancheEvent.START); - startTime = System.currentTimeMillis() } } - } fun register() { val intentFilter = IntentFilter() @@ -70,4 +75,4 @@ constructor( } broadcastDispatcher.registerReceiver(broadcastReceiver, intentFilter) } -}
\ No newline at end of file +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt index f84b5f48c864..367aaadf2942 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt @@ -270,32 +270,26 @@ class AvalancheSuppressor( } enum class AvalancheEvent(private val id: Int) : UiEventLogger.UiEventEnum { - @UiEvent( - doc = - "An avalanche event occurred but this notification was suppressed by a " + - "non-avalanche suppressor." - ) - START(1802), - @UiEvent(doc = "HUN was suppressed in avalanche.") SUPPRESS(1803), - @UiEvent(doc = "HUN allowed during avalanche because it is high priority.") - ALLOW_CONVERSATION_AFTER_AVALANCHE(1804), - @UiEvent(doc = "HUN allowed during avalanche because it is a high priority conversation.") - ALLOW_HIGH_PRIORITY_CONVERSATION_ANY_TIME(1805), - @UiEvent(doc = "HUN allowed during avalanche because it is a call.") ALLOW_CALLSTYLE(1806), - @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.") - ALLOW_CATEGORY_REMINDER(1807), + @UiEvent(doc = "An avalanche event occurred, and a suppression period will start now.") + AVALANCHE_SUPPRESSOR_RECEIVED_TRIGGERING_EVENT(1824), + @UiEvent(doc = "HUN was suppressed in avalanche.") + AVALANCHE_SUPPRESSOR_HUN_SUPPRESSED(1825), + @UiEvent(doc = "HUN allowed during avalanche because conversation newer than the trigger.") + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_NEW_CONVERSATION(1826), + @UiEvent(doc = "HUN allowed during avalanche because it is a priority conversation.") + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_PRIORITY_CONVERSATION(1827), + @UiEvent(doc = "HUN allowed during avalanche because it is a CallStyle notification.") + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CALL_STYLE(1828), + @UiEvent(doc = "HUN allowed during avalanche because it is a reminder notification.") + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_REMINDER(1829), @UiEvent(doc = "HUN allowed during avalanche because it is a calendar notification.") - ALLOW_CATEGORY_EVENT(1808), - @UiEvent( - doc = - "HUN allowed during avalanche because it has a full screen intent and " + - "the full screen intent permission is granted." - ) - ALLOW_FSI_WITH_PERMISSION_ON(1809), + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_EVENT(1830), + @UiEvent(doc = "HUN allowed during avalanche because it has FSI.") + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_FSI_WITH_PERMISSION(1831), @UiEvent(doc = "HUN allowed during avalanche because it is colorized.") - ALLOW_COLORIZED(1810), + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_COLORIZED(1832), @UiEvent(doc = "HUN allowed during avalanche because it is an emergency notification.") - ALLOW_EMERGENCY(1811); + AVALANCHE_SUPPRESSOR_HUN_ALLOWED_EMERGENCY(1833); override fun getId(): Int { return id @@ -323,46 +317,46 @@ class AvalancheSuppressor( entry.ranking.isConversation && entry.sbn.notification.getWhen() > avalancheProvider.startTime ) { - uiEventLogger.log(AvalancheEvent.ALLOW_CONVERSATION_AFTER_AVALANCHE) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_NEW_CONVERSATION) return State.ALLOW_CONVERSATION_AFTER_AVALANCHE } if (entry.channel?.isImportantConversation == true) { - uiEventLogger.log(AvalancheEvent.ALLOW_HIGH_PRIORITY_CONVERSATION_ANY_TIME) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_PRIORITY_CONVERSATION) return State.ALLOW_HIGH_PRIORITY_CONVERSATION_ANY_TIME } if (entry.sbn.notification.isStyle(Notification.CallStyle::class.java)) { - uiEventLogger.log(AvalancheEvent.ALLOW_CALLSTYLE) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CALL_STYLE) return State.ALLOW_CALLSTYLE } if (entry.sbn.notification.category == CATEGORY_REMINDER) { - uiEventLogger.log(AvalancheEvent.ALLOW_CATEGORY_REMINDER) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_REMINDER) return State.ALLOW_CATEGORY_REMINDER } if (entry.sbn.notification.category == CATEGORY_EVENT) { - uiEventLogger.log(AvalancheEvent.ALLOW_CATEGORY_EVENT) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_CATEGORY_EVENT) return State.ALLOW_CATEGORY_EVENT } if (entry.sbn.notification.fullScreenIntent != null) { - uiEventLogger.log(AvalancheEvent.ALLOW_FSI_WITH_PERMISSION_ON) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_FSI_WITH_PERMISSION) return State.ALLOW_FSI_WITH_PERMISSION_ON } if (entry.sbn.notification.isColorized) { - uiEventLogger.log(AvalancheEvent.ALLOW_COLORIZED) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_COLORIZED) return State.ALLOW_COLORIZED } if ( packageManager.checkPermission(RECEIVE_EMERGENCY_BROADCAST, entry.sbn.packageName) == PERMISSION_GRANTED ) { - uiEventLogger.log(AvalancheEvent.ALLOW_EMERGENCY) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_ALLOWED_EMERGENCY) return State.ALLOW_EMERGENCY } - uiEventLogger.log(AvalancheEvent.SUPPRESS) + uiEventLogger.log(AvalancheEvent.AVALANCHE_SUPPRESSOR_HUN_SUPPRESSED) return State.SUPPRESS } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt index a97298527e11..32774e0b270a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/AvalancheController.kt @@ -35,10 +35,7 @@ import javax.inject.Inject @SysUISingleton class AvalancheController @Inject -constructor( - dumpManager: DumpManager, - private val uiEventLogger: UiEventLogger -) : Dumpable { +constructor(dumpManager: DumpManager, private val uiEventLogger: UiEventLogger) : Dumpable { private val tag = "AvalancheController" private val debug = Compile.IS_DEBUG && Log.isLoggable(tag, Log.DEBUG) @@ -69,14 +66,11 @@ constructor( @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 shown.") AVALANCHE_THROTTLING_HUN_SHOWN(1821), @UiEvent(doc = "HUN was dropped to show higher priority HUNs.") - DROPPED(1813), - + AVALANCHE_THROTTLING_HUN_DROPPED(1822), @UiEvent(doc = "HUN was removed while waiting to show.") - REMOVED(1814); + AVALANCHE_THROTTLING_HUN_REMOVED(1823); override fun getId(): Int { return id @@ -97,7 +91,7 @@ constructor( runnable.run() return } - log { "\n "} + log { "\n " } val fn = "$label => AvalancheController.update ${getKey(entry)}" if (entry == null) { log { "Entry is NULL, stop update." } @@ -129,9 +123,10 @@ constructor( // HeadsUpEntry.updateEntry recursively calls AvalancheController#update // and goes to the isShowing case above headsUpEntryShowing!!.updateEntry( - /* updatePostTime= */ false, - /* updateEarliestRemovalTime= */ false, - /* reason= */ "avalanche duration update") + /* updatePostTime= */ false, + /* updateEarliestRemovalTime= */ false, + /* reason= */ "avalanche duration update" + ) } } logState("after $fn") @@ -152,7 +147,7 @@ constructor( runnable.run() return } - log { "\n "} + log { "\n " } val fn = "$label => AvalancheController.delete " + getKey(entry) if (entry == null) { log { "$fn => entry NULL, running runnable" } @@ -163,7 +158,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) + uiEventLogger.log(ThrottleEvent.AVALANCHE_THROTTLING_HUN_REMOVED) } else if (entry in debugDropSet) { log { "$fn => remove from dropset" } debugDropSet.remove(entry) @@ -287,7 +282,7 @@ constructor( private fun showNow(entry: HeadsUpEntry, runnableList: MutableList<Runnable>) { log { "SHOW: " + getKey(entry) } - uiEventLogger.log(ThrottleEvent.SHOWN) + uiEventLogger.log(ThrottleEvent.AVALANCHE_THROTTLING_HUN_SHOWN) headsUpEntryShowing = entry runnableList.forEach { @@ -318,7 +313,7 @@ constructor( // Log dropped HUNs for (e in listToDrop) { - uiEventLogger.log(ThrottleEvent.DROPPED) + uiEventLogger.log(ThrottleEvent.AVALANCHE_THROTTLING_HUN_DROPPED) } if (debug) { |