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

Commit b1dbb465 authored by Olivier St-Onge's avatar Olivier St-Onge Committed by Android (Google) Code Review
Browse files

Revert "Finish BrightnessDialog when shade is opened."

This reverts commit cad68c69.

Reason for revert: Added test is flaky

Change-Id: I74529c4f93bc23964b674c394e27c71a2d923622
parent cad68c69
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.WindowManagerPolicyConstants.EXTRA_FROM_BRIGHTNESS_KEY;

import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow;

import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.Rect;
@@ -89,17 +87,6 @@ public class BrightnessDialog extends Activity {
        if (mShadeInteractor.isQsExpanded().getValue()) {
            finish();
        }

        View view = findViewById(R.id.brightness_mirror_container);
        if (view != null) {
            collectFlow(view, mShadeInteractor.isQsExpanded(), this::onShadeStateChange);
        }
    }

    private void onShadeStateChange(boolean isQsExpanded) {
        if (isQsExpanded) {
            requestFinish();
        }
    }

    private void setWindowAttributes() {
+3 −17
Original line number Diff line number Diff line
@@ -36,10 +36,8 @@ import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.whenever
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import dagger.Lazy
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Rule
@@ -61,6 +59,7 @@ class BrightnessDialogTest : SysuiTestCase() {
    @Mock private lateinit var brightnessControllerFactory: BrightnessController.Factory
    @Mock private lateinit var brightnessController: BrightnessController
    @Mock private lateinit var accessibilityMgr: AccessibilityManagerWrapper
    @Mock private lateinit var shadeInteractorLazy: Lazy<ShadeInteractor>
    @Mock private lateinit var shadeInteractor: ShadeInteractor

    private val clock = FakeSystemClock()
@@ -90,6 +89,7 @@ class BrightnessDialogTest : SysuiTestCase() {
            .thenReturn(brightnessSliderController)
        `when`(brightnessSliderController.rootView).thenReturn(View(context))
        `when`(brightnessControllerFactory.create(any())).thenReturn(brightnessController)
        whenever(shadeInteractorLazy.get()).thenReturn(shadeInteractor)
        whenever(shadeInteractor.isQsExpanded).thenReturn(MutableStateFlow(false))
    }

@@ -180,20 +180,6 @@ class BrightnessDialogTest : SysuiTestCase() {
        assertThat(activityRule.activity.isFinishing()).isFalse()
    }

    @OptIn(ExperimentalCoroutinesApi::class)
    @Test
    fun testFinishOnQSExpanded() = runTest {
        val isQSExpanded = MutableStateFlow(false)
        `when`(shadeInteractor.isQsExpanded).thenReturn(isQSExpanded)
        activityRule.launchActivity(Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG))

        assertThat(activityRule.activity.isFinishing()).isFalse()

        isQSExpanded.value = true
        advanceUntilIdle()
        assertThat(activityRule.activity.isFinishing()).isTrue()
    }

    class TestDialog(
        brightnessSliderControllerFactory: BrightnessSliderController.Factory,
        brightnessControllerFactory: BrightnessController.Factory,