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

Commit e7392180 authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Hold StateFlow for focusedDisplayId in ScreenshotProxyService

This CL changes ScreenshotProxyService to hold the StateFlow for
focusedDisplayId rather than accessing it on-demand.
As FocusedDisplayRepository#focusedDisplayId is not a StateFlow but its
getter generates new StateFlow from the original cold flow, it’s not
supposed to be inlined, which results in returning the default value
before the cold flow emits the correct value.

Bug: 399644508
Flag: com.android.window.flags.enable_display_focus_in_shell_transitions
Flag: com.android.systemui.screenshot_multidisplay_focus_change
Test: manual - connect an external display and screenshot
Change-Id: Id72c4ae2cc673980915ac77aff3c3aea97956367
parent 7cb3bdab
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -38,9 +38,11 @@ constructor(
    private val mExpansionMgr: ShadeExpansionStateManager,
    @Main private val mMainDispatcher: CoroutineDispatcher,
    private val activityStarter: ActivityStarter,
    private val focusedDisplayRepository: FocusedDisplayRepository,
    focusedDisplayRepository: FocusedDisplayRepository,
) : LifecycleService() {

    private val focusedDisplayId = focusedDisplayRepository.focusedDisplayId

    private val mBinder: IBinder =
        object : IScreenshotProxy.Stub() {
            /** @return true when the notification shade is partially or fully expanded. */
@@ -56,7 +58,7 @@ constructor(
                }
            }

            override fun getFocusedDisplay(): Int = focusedDisplayRepository.focusedDisplayId.value
            override fun getFocusedDisplay(): Int = focusedDisplayId.value
        }

    private suspend fun executeAfterDismissing(callback: IOnDoneCallback) =