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

Commit 946efb43 authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Fix screenrecord crash in next due to DisplayWindowPropertiesRepository

DisplayWindowPropertiesRepository should be instantiated only when some flags are on, and they were still off in next.
As there are no presubmits exercising this on next, this only failed in postsubmits.

Bug: 424690468
Flag: com.android.systemui.shade_window_goes_around
Test: ScreenRecordPermissionDialogDelegateTest
Change-Id: Ied12049178c30b407ef3717721eede2af7e16952
parent b73e93fd
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -102,7 +102,7 @@ class ScreenRecordPermissionDialogDelegateTest : SysuiTestCase() {
                systemUIDialogFactory,
                systemUIDialogFactory,
                context,
                context,
                context.getSystemService(DisplayManager::class.java)!!,
                context.getSystemService(DisplayManager::class.java)!!,
                fakeDisplayWindowPropertiesRepository,
                { fakeDisplayWindowPropertiesRepository },
            )
            )
        dialog = underTest.createDialog()
        dialog = underTest.createDialog()
    }
    }
+7 −3
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import com.android.systemui.settings.UserContextProvider
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.phone.SystemUIDialog
import dagger.Lazy
import dagger.assisted.Assisted
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import dagger.assisted.AssistedInject
@@ -52,7 +53,7 @@ class ScreenRecordPermissionDialogDelegate(
    @StyleRes private val theme: Int,
    @StyleRes private val theme: Int,
    private val context: Context,
    private val context: Context,
    private val displayManager: DisplayManager,
    private val displayManager: DisplayManager,
    private val displayWindowPropertiesRepository: DisplayWindowPropertiesRepository,
    private val displayWindowPropertiesRepository: Lazy<DisplayWindowPropertiesRepository>,
) :
) :
    BaseMediaProjectionPermissionDialogDelegate<SystemUIDialog>(
    BaseMediaProjectionPermissionDialogDelegate<SystemUIDialog>(
        ScreenRecordPermissionContentManager.createOptionList(displayManager),
        ScreenRecordPermissionContentManager.createOptionList(displayManager),
@@ -76,7 +77,7 @@ class ScreenRecordPermissionDialogDelegate(
        systemUIDialogFactory: SystemUIDialog.Factory,
        systemUIDialogFactory: SystemUIDialog.Factory,
        @ShadeDisplayAware context: Context,
        @ShadeDisplayAware context: Context,
        displayManager: DisplayManager,
        displayManager: DisplayManager,
        displayWindowPropertiesRepository: DisplayWindowPropertiesRepository,
        displayWindowPropertiesRepository: Lazy<DisplayWindowPropertiesRepository>,
    ) : this(
    ) : this(
        hostUserHandle,
        hostUserHandle,
        hostUid,
        hostUid,
@@ -125,7 +126,10 @@ class ScreenRecordPermissionDialogDelegate(
                // dialog would be tied to the shade and disappear when the shade collapses.
                // dialog would be tied to the shade and disappear when the shade collapses.
                // To avoid this, we get a context associated with the status bar on the current
                // To avoid this, we get a context associated with the status bar on the current
                // display.  This ensures the dialog remains visible independently of the shade.
                // display.  This ensures the dialog remains visible independently of the shade.
                displayWindowPropertiesRepository.get(context.displayId, TYPE_STATUS_BAR)?.context
                displayWindowPropertiesRepository
                    .get()
                    .get(context.displayId, TYPE_STATUS_BAR)
                    ?.context
                    // falls back to the default context if the status bar context is not available
                    // falls back to the default context if the status bar context is not available
                    ?: context
                    ?: context
            } else {
            } else {