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

Commit 8b6ee72c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use correct context for Screen Record Dialog" into main

parents d36cda8d 2d242456
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.mediaprojection.permission.SINGLE_APP
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import com.android.systemui.screenrecord.domain.interactor.screenRecordingStartStopInteractor
import com.android.systemui.shade.data.repository.shadeDialogContextInteractor
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.statusbar.phone.SystemUIDialogManager
@@ -103,8 +104,8 @@ class ScreenRecordPermissionDialogDelegateTest : SysuiTestCase() {
                systemUIDialogFactory,
                context,
                context.getSystemService(DisplayManager::class.java)!!,
                { fakeDisplayWindowPropertiesRepository },
                kosmos.screenRecordingStartStopInteractor,
                kosmos.shadeDialogContextInteractor,
            )
        dialog = underTest.createDialog()
    }
+5 −17
Original line number Diff line number Diff line
@@ -20,9 +20,7 @@ import android.hardware.display.DisplayManager
import android.os.Bundle
import android.os.UserHandle
import android.view.View
import android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR
import androidx.annotation.StyleRes
import com.android.systemui.display.data.repository.DisplayWindowPropertiesRepository
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger
import com.android.systemui.mediaprojection.permission.BaseMediaProjectionPermissionContentManager
import com.android.systemui.mediaprojection.permission.BaseMediaProjectionPermissionDialogDelegate
@@ -32,9 +30,9 @@ import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import com.android.systemui.screenrecord.domain.interactor.ScreenRecordingStartStopInteractor
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shade.domain.interactor.ShadeDialogContextInteractor
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import com.android.systemui.statusbar.phone.SystemUIDialog
import dagger.Lazy
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@@ -52,8 +50,8 @@ class ScreenRecordPermissionDialogDelegate(
    @StyleRes private val theme: Int,
    private val context: Context,
    private val displayManager: DisplayManager,
    private val displayWindowPropertiesRepository: Lazy<DisplayWindowPropertiesRepository>,
    private val screenRecordingStartStopInteractor: ScreenRecordingStartStopInteractor,
    private val shadeDialogContextInteractor: ShadeDialogContextInteractor,
) :
    BaseMediaProjectionPermissionDialogDelegate<SystemUIDialog>(
        ScreenRecordPermissionContentManager.createOptionList(displayManager),
@@ -76,8 +74,8 @@ class ScreenRecordPermissionDialogDelegate(
        systemUIDialogFactory: SystemUIDialog.Factory,
        @ShadeDisplayAware context: Context,
        displayManager: DisplayManager,
        displayWindowPropertiesRepository: Lazy<DisplayWindowPropertiesRepository>,
        screenRecordingStartStopInteractor: ScreenRecordingStartStopInteractor,
        shadeDialogContextInteractor: ShadeDialogContextInteractor,
    ) : this(
        hostUserHandle,
        hostUid,
@@ -90,8 +88,8 @@ class ScreenRecordPermissionDialogDelegate(
        theme = SystemUIDialog.DEFAULT_THEME,
        context,
        displayManager,
        displayWindowPropertiesRepository,
        screenRecordingStartStopInteractor,
        shadeDialogContextInteractor,
    )

    @AssistedFactory
@@ -121,17 +119,7 @@ class ScreenRecordPermissionDialogDelegate(
    override fun createDialog(): SystemUIDialog {
        val displayContext =
            if (ShadeWindowGoesAround.isEnabled) {
                // This dialog needs to stay visible even if the notification shade closes,
                // for example, after unlocking the device. If we used the shade's own context, the
                // 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
                // display.  This ensures the dialog remains visible independently of the shade.
                displayWindowPropertiesRepository
                    .get()
                    .get(context.displayId, TYPE_STATUS_BAR)
                    ?.context
                    // falls back to the default context if the status bar context is not available
                    ?: context
                shadeDialogContextInteractor.context
            } else {
                context
            }