diff options
| author | 2024-07-09 15:28:04 +0000 | |
|---|---|---|
| committer | 2024-07-09 15:28:04 +0000 | |
| commit | 38d30647e60eff7e39feb2addc8dd4d37f13b9ae (patch) | |
| tree | 38547d81c9ffd3c484e1a3d00fd8b196974f8e78 | |
| parent | c7b0b7b6e0a3a649a7a6d42eb9f72c33b7c5f911 (diff) | |
| parent | 4d851ae6b80d079c27d160504944226d7aacd086 (diff) | |
Merge "Pass a bg handler when registering broadcast receiver" into main
3 files changed, 18 insertions, 3 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/ZenModeRepository.kt b/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/ZenModeRepository.kt index 58541418d812..273a63db801c 100644 --- a/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/ZenModeRepository.kt +++ b/packages/SettingsLib/src/com/android/settingslib/notification/data/repository/ZenModeRepository.kt @@ -21,6 +21,7 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter +import android.os.Handler import com.android.settingslib.flags.Flags import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineScope @@ -50,6 +51,9 @@ class ZenModeRepositoryImpl( private val notificationManager: NotificationManager, val scope: CoroutineScope, val backgroundCoroutineContext: CoroutineContext, + // This is nullable just to simplify testing, since SettingsLib doesn't have a good way + // to create a fake handler. + val backgroundHandler: Handler?, ) : ZenModeRepository { private val notificationBroadcasts = @@ -69,7 +73,14 @@ class ZenModeRepositoryImpl( if (Flags.volumePanelBroadcastFix() && android.app.Flags.modesApi()) addAction( NotificationManager.ACTION_CONSOLIDATED_NOTIFICATION_POLICY_CHANGED) - }) + }, + /* broadcastPermission = */ null, + /* scheduler = */ if (Flags.volumePanelBroadcastFix()) { + backgroundHandler + } else { + null + }, + ) awaitClose { context.unregisterReceiver(receiver) } } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/data/repository/ZenModeRepositoryTest.kt b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/data/repository/ZenModeRepositoryTest.kt index 5294ce382aa9..096c25db8629 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/data/repository/ZenModeRepositoryTest.kt +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/notification/data/repository/ZenModeRepositoryTest.kt @@ -69,6 +69,7 @@ class ZenModeRepositoryTest { notificationManager, testScope.backgroundScope, testScope.testScheduler, + backgroundHandler = null, ) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java index fec7cf060480..b63ee4c52e14 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.dagger; import android.app.NotificationManager; import android.content.Context; +import android.os.Handler; import android.service.notification.NotificationListenerService; import com.android.internal.jank.InteractionJankMonitor; @@ -283,9 +284,11 @@ public interface NotificationsModule { Context context, NotificationManager notificationManager, @Application CoroutineScope coroutineScope, - @Background CoroutineContext coroutineContext) { + @Background CoroutineContext coroutineContext, + @Background Handler handler + ) { return new ZenModeRepositoryImpl(context, notificationManager, - coroutineScope, coroutineContext); + coroutineScope, coroutineContext, handler); } @Provides |