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

Commit 35d50531 authored by brycelee's avatar brycelee
Browse files

Handle AppWidgetHost stop listening on background thread.

This code path calls AppWidgetHost methods with synchronized
bocks that can lead to potential ANRs on the main thread.

Fixes: 428173750
Flag: EXEMPT bugfix
Test: atest CommunalWidgetHostTest
Change-Id: Ibea2ff2567dbb11ce87b76e4055ad819bdb2140a
parent f4a872bb
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ constructor(
    }

    override fun onHostStopListening() {
        bgScope.launch {
            // Remove listeners
            _appWidgetProviders.value.keys.forEach { appWidgetId ->
                appWidgetHost.removeListener(appWidgetId)
@@ -179,6 +180,7 @@ constructor(
            // Clear providers
            _appWidgetProviders.value = emptyMap()
        }
    }

    override fun onAllocateAppWidgetId(appWidgetId: Int) {
        try {