Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38d30647 authored by Ioana Alexandru's avatar Ioana Alexandru Committed by Android (Google) Code Review
Browse files

Merge "Pass a bg handler when registering broadcast receiver" into main

parents c7b0b7b6 4d851ae6
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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) }
            }
+1 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ class ZenModeRepositoryTest {
                notificationManager,
                testScope.backgroundScope,
                testScope.testScheduler,
                backgroundHandler = null,
            )
    }

+5 −2
Original line number Diff line number Diff line
@@ -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