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

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

Merge "Fix hasFocalArea is always true" into main

parents 0aab638d 4bbc7d33
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -51,8 +51,6 @@ import com.android.systemui.shade.domain.interactor.enableSingleShade
import com.android.systemui.shade.domain.interactor.enableSplitShade
import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.mock
import com.android.systemui.wallpapers.data.repository.wallpaperFocalAreaRepository
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -65,6 +63,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.spy
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever

@@ -77,7 +76,7 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
    lateinit var shadeRepository: ShadeRepository
    private lateinit var mockedResources: Resources
    private lateinit var underTest: WallpaperFocalAreaInteractor
    private var wallpaperInteractor: WallpaperInteractor = spy(kosmos.wallpaperInteractor)
    private var wallpaperInteractor: WallpaperInteractor = spy(kosmos.wallpaperInteractorFaked)

    @Before
    fun setup() {
@@ -113,7 +112,8 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
                backgroundScope = kosmos.backgroundScope,
                wallpaperInteractor = wallpaperInteractor,
            )
        kosmos.wallpaperFocalAreaRepository.hasFocalArea.value = true

        kosmos.fakeWallpaperRepository.setShouldSendFocalArea(true)
    }

    @Test
@@ -270,7 +270,7 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
        testScope.runTest {
            val shouldCollectFocalArea by collectLastValue(underTest.shouldCollectFocalArea)
            assertThat(shouldCollectFocalArea).isTrue()
            kosmos.wallpaperFocalAreaRepository.hasFocalArea.value = false
            kosmos.fakeWallpaperRepository.setShouldSendFocalArea(false)
            assertThat(shouldCollectFocalArea).isFalse()
        }

@@ -445,6 +445,22 @@ class WallpaperFocalAreaInteractorTest : SysuiTestCase() {
            assertThat(shouldCollectFocalArea).isFalse()
        }

    @Test
    fun lockscreenWallpaperNotHasFocalAreaTarget_hasFocalAreaIsTrue() =
        testScope.runTest {
            val hasFocalArea by collectLastValue(underTest.hasFocalArea)
            kosmos.fakeWallpaperRepository.setShouldSendFocalArea(true)
            assertThat(hasFocalArea).isTrue()
        }

    @Test
    fun lockscreenWallpaperHasFocalAreaTarget_hasFocalAreaIsFalse() =
        testScope.runTest {
            val hasFocalArea by collectLastValue(underTest.hasFocalArea)
            kosmos.fakeWallpaperRepository.setShouldSendFocalArea(false)
            assertThat(hasFocalArea).isFalse()
        }

    data class OverrideResources(
        val screenWidth: Int,
        val screenHeight: Int,
+0 −3
Original line number Diff line number Diff line
@@ -22,9 +22,6 @@ import kotlinx.coroutines.flow.MutableStateFlow

@SysUISingleton
class WallpaperFocalAreaRepository @Inject constructor() {
    /** It will be true when wallpaper requires focal area info. */
    val hasFocalArea = MutableStateFlow(true)

    /** The top of shortcut in screen, used by wallpaper to find remaining space in lockscreen */
    val shortcutAbsoluteTop = MutableStateFlow(-1F)

+0 −2
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
@@ -180,7 +179,6 @@ constructor(

    override val shouldSendFocalArea =
        lockscreenWallpaperInfo
            .filterNotNull()
            .map {
                val focalAreaTarget = context.resources.getString(SysUIR.string.focal_area_target)
                val shouldSendNotificationLayout = it?.component?.className == focalAreaTarget
+1 −2
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.emptyFlow
@@ -70,7 +69,7 @@ constructor(
    @Background private val backgroundScope: CoroutineScope,
    private val wallpaperInteractor: WallpaperInteractor,
) : CoreStartable {
    val hasFocalArea: StateFlow<Boolean> = wallpaperFocalAreaRepository.hasFocalArea
    val hasFocalArea = wallpaperInteractor.hasFocalArea

    @OptIn(ExperimentalCoroutinesApi::class)
    val shouldCollectFocalArea =
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ class WallpaperInteractor @Inject constructor(val wallpaperRepository: Wallpaper
    val wallpaperSupportsAmbientMode: Flow<Boolean> =
        wallpaperRepository.wallpaperSupportsAmbientMode

    val hasFocalArea = wallpaperRepository.shouldSendFocalArea

    fun sendWallpaperFocalAreaBounds(bounds: RectF) {
        wallpaperRepository.sendLockScreenLayoutChangeCommand(bounds)
    }
Loading