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

Commit ab4105e3 authored by Derek Jedral's avatar Derek Jedral
Browse files

Revert of notifying suggestion space visible in UMO

Not able to figure out at the moment why there is a regression caused by
this change, despite this code path being flagged off. At this point it
seems safer to revert, and then to monitor whether the regression is
fixed.

Test: atest
Flag: com.android.systemui.enable_suggested_device_ui
Bug: 411049380
Change-Id: I8236cd3501d5c691a659d414d3c8626b44279011
parent 5e03056c
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.anyFloat
import org.mockito.Mock
import org.mockito.Mockito.anyInt
@@ -62,7 +61,6 @@ class MediaCarouselScrollHandlerTest : SysuiTestCase() {
    @Mock lateinit var seekBarUpdateListener: (visibleToUser: Boolean) -> Unit
    @Mock lateinit var closeGuts: (immediate: Boolean) -> Unit
    @Mock lateinit var falsingManager: FalsingManager
    @Mock lateinit var onCarouselVisibleToUser: () -> Unit
    @Mock lateinit var logger: MediaUiEventLogger
    @Mock lateinit var contentContainer: ViewGroup
    @Mock lateinit var settingsButton: View
@@ -92,7 +90,6 @@ class MediaCarouselScrollHandlerTest : SysuiTestCase() {
                seekBarUpdateListener,
                closeGuts,
                falsingManager,
                onCarouselVisibleToUser,
                logger,
            )
        mediaCarouselScrollHandler.playerWidthPlusPadding = carouselWidth
@@ -251,19 +248,6 @@ class MediaCarouselScrollHandlerTest : SysuiTestCase() {
        verify(mediaCarousel, never()).animationTargetX = anyFloat()
    }

    @Test
    fun testCarouselScrollToNewIndex_onCarouselVisibleToUser() {
        setupMediaContainer(visibleIndex = 0)
        whenever(mediaCarousel.relativeScrollX).thenReturn(carouselWidth)
        mediaCarouselScrollHandler.visibleToUser = true
        val captor = ArgumentCaptor.forClass(View.OnScrollChangeListener::class.java)
        verify(mediaCarousel).setOnScrollChangeListener(captor.capture())

        captor.value.onScrollChange(null, 0, 0, 0, 0)

        verify(onCarouselVisibleToUser).invoke()
    }

    private fun setupMediaContainer(visibleIndex: Int, showsSettingsButton: Boolean = true) {
        whenever(contentContainer.childCount).thenReturn(2)
        val child1: View = mock()
+0 −1
Original line number Diff line number Diff line
@@ -237,7 +237,6 @@ constructor(
            bgExecutor.execute {
                if (!started) {
                    // Fetch in case a suggestion already exists before registering for suggestions
                    onSuggestedDeviceUpdated(localMediaManager.getSuggestedDevice())
                    localMediaManager.registerCallback(this)
                    if (!Flags.removeUnnecessaryRouteScanning()) {
                        localMediaManager.startScan()
+0 −13
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import com.android.keyguard.KeyguardUpdateMonitor
import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.systemui.Dumpable
import com.android.systemui.Flags
import com.android.systemui.Flags.enableSuggestedDeviceUi
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
@@ -353,7 +352,6 @@ constructor(
                this::updateSeekbarListening,
                this::closeGuts,
                falsingManager,
                this::onCarouselVisibleToUser,
                logger,
            )
        carouselLocale = context.resources.configuration.locales.get(0)
@@ -1216,17 +1214,6 @@ constructor(
        }
    }

    fun onCarouselVisibleToUser() {
        if (!enableSuggestedDeviceUi() || !mediaCarouselScrollHandler.visibleToUser) {
            return
        }
        val visibleMediaIndex = mediaCarouselScrollHandler.visibleMediaIndex
        if (MediaPlayerData.players().size > visibleMediaIndex) {
            val mediaControlPanel = MediaPlayerData.getMediaControlPanel(visibleMediaIndex)
            mediaControlPanel?.onSuggestionSpaceVisible()
        }
    }

    @VisibleForTesting
    fun onSwipeToDismiss() {
        if (SceneContainerFlag.isEnabled) {
+0 −12
Original line number Diff line number Diff line
@@ -240,7 +240,6 @@ public class MediaControlPanel {
    private TurbulenceNoiseAnimationConfig mTurbulenceNoiseAnimationConfig;
    private boolean mWasPlaying = false;
    private boolean mButtonClicked = false;
    @Nullable private Runnable mOnSuggestionSpaceVisibleRunnable = null;

    private final PaintDrawCallback mNoiseDrawCallback =
            new PaintDrawCallback() {
@@ -630,16 +629,6 @@ public class MediaControlPanel {
        Trace.endSection();
    }

    /**
     * Should be called when the space that holds device suggestions becomes visible to the user.
     */
    public void onSuggestionSpaceVisible() {
        @Nullable Runnable onSuggestionVisibleRunnable = mOnSuggestionSpaceVisibleRunnable;
        if (onSuggestionVisibleRunnable != null) {
            onSuggestionVisibleRunnable.run();
        }
    }

    private void bindDeviceSuggestion(@NonNull MediaData data) {
        if (!Flags.enableSuggestedDeviceUi()) {
            return;
@@ -648,7 +637,6 @@ public class MediaControlPanel {
        TextView deviceText = mMediaViewHolder.getSeamlessText();
        @Nullable SuggestionData suggestionData = data.getSuggestionData();
        if (suggestionData != null) {
            mOnSuggestionSpaceVisibleRunnable = suggestionData.getOnSuggestionSpaceVisible();
            @Nullable
            SuggestedMediaDeviceData suggestionDeviceData =
                    suggestionData.getSuggestedMediaDeviceData();
+0 −3
Original line number Diff line number Diff line
@@ -1328,9 +1328,6 @@ constructor(
        logger.logUserVisibilityChange(shadeVisible, mediaVisible)
        val carouselVisible = shadeVisible && mediaVisible
        mediaCarouselController.mediaCarouselScrollHandler.visibleToUser = carouselVisible
        if (carouselVisible) {
            mediaCarouselController.onCarouselVisibleToUser()
        }
    }

    private fun isLockScreenVisibleToUser(): Boolean {
Loading