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

Commit bf4015a8 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/25505206']...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/25505206'] into sparse-11131061-L91100030000585058.
SPARSE_CHANGE: Ia96544625d206d149a6fab5d144e93d6ee0ca4af

Change-Id: I7da23acd46b50239affb3efe7d15507690fb29da
parents 837d28ab 8caaca39
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -37,17 +37,23 @@ constructor(

    @MainThread
    fun enable(onShadeInteraction: Runnable) {
        if (shadeExpansionCollectorJob == null) {
        if (shadeExpansionCollectorJob != null) {
            Log.e(TAG, "Already enabled")
            return
        }
        if (shadeInteractorLazy.get().isUserInteracting.value) {
            Log.e(TAG, "isUserInteracting already true, skipping enable")
            return
        }
        shadeExpansionCollectorJob =
            scope.launch {
                Log.i(TAG, "Enable detector")
                // wait for it to emit true once
                shadeInteractorLazy.get().isUserInteracting.first { it }
                Log.i(TAG, "Detector detected shade interaction")
                onShadeInteraction.run()
            }
        shadeExpansionCollectorJob?.invokeOnCompletion { shadeExpansionCollectorJob = null }
        } else {
            Log.e(TAG, "Already enabled")
        }
    }

    @MainThread
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ interface ShadeInteractor : BaseShadeInteractor {
     * input (i.e. dragging a pointer). This will be true even if the user's input gesture had ended
     * but a transition they initiated is still animating.
     */
    val isUserInteracting: Flow<Boolean>
    val isUserInteracting: StateFlow<Boolean>

    /** Are touches allowed on the notification panel? */
    val isShadeTouchable: Flow<Boolean>
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ class ShadeInteractorEmptyImpl @Inject constructor() : ShadeInteractor {
    override val isAnyExpanded: StateFlow<Boolean> = inactiveFlowBoolean
    override val isUserInteractingWithShade: Flow<Boolean> = inactiveFlowBoolean
    override val isUserInteractingWithQs: Flow<Boolean> = inactiveFlowBoolean
    override val isUserInteracting: Flow<Boolean> = inactiveFlowBoolean
    override val isUserInteracting: StateFlow<Boolean> = inactiveFlowBoolean
    override val isShadeTouchable: Flow<Boolean> = inactiveFlowBoolean
    override val isExpandToQsEnabled: Flow<Boolean> = inactiveFlowBoolean
}
+2 −1
Original line number Diff line number Diff line
@@ -65,9 +65,10 @@ constructor(
    override val isShadeFullyExpanded: Flow<Boolean> =
        baseShadeInteractor.shadeExpansion.map { it >= 1f }.distinctUntilChanged()

    override val isUserInteracting: Flow<Boolean> =
    override val isUserInteracting: StateFlow<Boolean> =
        combine(isUserInteractingWithShade, isUserInteractingWithQs) { shade, qs -> shade || qs }
            .distinctUntilChanged()
            .stateIn(scope, SharingStarted.Eagerly, false)

    override val isShadeTouchable: Flow<Boolean> =
        combine(
+12 −0
Original line number Diff line number Diff line
@@ -97,6 +97,18 @@ class AuthDialogPanelInteractionDetectorTest : SysuiTestCase() {
            verify(action).run()
        }

    @Test
    fun enableDetector_isUserInteractingTrue_shouldNotPostRunnable() =
        testComponent.runTest {
            // GIVEN isInteracting starts true
            shadeRepository.setLegacyShadeTracking(true)
            runCurrent()
            detector.enable(action)

            // THEN action was not run
            verifyZeroInteractions(action)
        }

    @Test
    fun enableDetector_shadeExpandImmediate_shouldNotPostRunnable() =
        testComponent.runTest {