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

Commit b254a13b authored by Darrell Shi's avatar Darrell Shi
Browse files

Ignore binder buffer overflow in startListening

AppWidgetHost#startListening can fail with a binder buffer overflow when
widget RemoteViews are too large. This change, mirroring the behavior on
launcher, ignores the error, until a framework fix is available.

Fix: 402970061
Test: none; the change simply ignores an exception which is not
      consistently reproducible
Flag: EXEMPT bugfix
Change-Id: Idda00213f43e390b913780fc6504bc5ba7407ea1
parent 2ba3a051
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.communal.widgets

import android.appwidget.AppWidgetHost
import android.content.Context
import android.os.DeadObjectException
import android.os.TransactionTooLargeException
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.systemui.communal.shared.model.GlanceableHubMultiUserHelper
import com.android.systemui.log.LogBuffer
@@ -78,7 +80,16 @@ class CommunalAppWidgetHost(
    }

    override fun startListening() {
        try {
            super.startListening()
        } catch (e: Exception) {
            if (!e.isBinderSizeError()) {
                throw RuntimeException(e)
            }
            // We ignore the binder size error, which is caused by the list of RemoteViews passed
            // back being too large that the binder buffer space runs out. See b/14255011 and
            // b/402970061 for more context.
        }
        backgroundScope.launch {
            synchronized(observers) {
                observers.forEach { observer -> observer.onHostStartListening() }
@@ -127,5 +138,9 @@ class CommunalAppWidgetHost(

    companion object {
        private const val TAG = "CommunalAppWidgetHost"

        private fun Exception.isBinderSizeError(): Boolean {
            return cause is TransactionTooLargeException || cause is DeadObjectException
        }
    }
}