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

Commit 5ce77165 authored by Orhan Uysal's avatar Orhan Uysal Committed by Thales Lima
Browse files

Use flag to determine which thread to use...

for persistence repository transform work.

Flag: com.android.window.flags.repository_based_persistence_bg_thread
Test: m && perfetto
Bug: 436785583
Change-Id: Ib1fc574814828ec1a4a9a028dd0bc9dd40367ea3
parent bbb4c36f
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import androidx.tracing.Trace
import com.android.app.tracing.traceSection
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.protolog.ProtoLog
import com.android.window.flags.Flags
import com.android.wm.shell.common.WorkSerializer
import com.android.wm.shell.desktopmode.DisplayDeskState
import com.android.wm.shell.desktopmode.data.persistence.DesktopPersistentRepository
@@ -67,8 +68,14 @@ class DesktopRepository(
    private val activeTasksListeners = ArraySet<ActiveTasksListener>()
    private val visibleTasksListeners = ArrayMap<VisibleTasksListener, Executor>()

    private val persistentUpdateQueue = WorkSerializer(bgCoroutineScope)

    private val persistentUpdateQueue =
        WorkSerializer(
            if (Flags.repositoryBasedPersistenceBgThread()) {
                bgCoroutineScope
            } else {
                mainCoroutineScope
            }
        )
    /* Tracks corner/caption regions of desktop tasks, used to determine gesture exclusion. */
    private val desktopExclusionRegions = SparseArray<Region>()

+10 −2
Original line number Diff line number Diff line
@@ -51,7 +51,9 @@ import com.android.wm.shell.sysui.ShellInit
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.util.StubTransaction
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.cancel
import kotlinx.coroutines.test.TestScope
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -89,6 +91,7 @@ class DesktopImmersiveControllerTest : ShellTestCase() {

    private lateinit var controller: DesktopImmersiveController
    private lateinit var desktopRepository: DesktopRepository
    private val testScope = TestScope()

    @Before
    fun setUp() {
@@ -100,8 +103,8 @@ class DesktopImmersiveControllerTest : ShellTestCase() {
                mock(),
                mock(),
                mock(),
                mock(),
                TestScope(),
                testScope.backgroundScope,
                testScope.backgroundScope,
                mock(),
                desktopState,
                desktopConfig,
@@ -128,6 +131,11 @@ class DesktopImmersiveControllerTest : ShellTestCase() {
        desktopRepository.setActiveDesk(DEFAULT_DISPLAY, DEFAULT_DESK_ID)
    }

    @After
    fun tearDown() {
        testScope.cancel()
    }

    @Test
    fun enterImmersive_transitionReady_updatesRepository() {
        val task = createFreeformTask()
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ class DesksTransitionObserverTest : ShellTestCase() {
                /* shellController= */ mockShellController,
                /* persistentRepository= */ mock(),
                /* repositoryInitializer= */ mock(),
                testScope,
                testScope.backgroundScope,
                testScope.backgroundScope,
                /* userManager= */ mock(),
                desktopState,
+5 −2
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.wm.shell.sysui.ShellInit
import com.android.wm.shell.windowdecor.additionalviewcontainer.AdditionalSystemViewContainer
import com.google.common.truth.Truth.assertThat
import kotlin.test.assertNotNull
import kotlinx.coroutines.cancel
import kotlinx.coroutines.test.TestScope
import org.junit.After
import org.junit.Assert.fail
@@ -71,6 +72,7 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() {
    private lateinit var desktopConfig: FakeDesktopConfig

    private var menu: DesktopHeaderManageWindowsMenu? = null
    private val testScope = TestScope()

    @Before
    fun setUp() {
@@ -92,8 +94,8 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() {
                shellController = mock(),
                persistentRepository = mock(),
                repositoryInitializer = mock(),
                mainCoroutineScope = mock(),
                bgCoroutineScope = TestScope(),
                mainCoroutineScope = testScope.backgroundScope,
                bgCoroutineScope = testScope.backgroundScope,
                userManager = mockUserManager,
                desktopState = desktopState,
                desktopConfig = desktopConfig,
@@ -108,6 +110,7 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() {
    fun tearDown() {
        menu?.removeFromContainer()
        mockitoSession.finishMocking()
        testScope.cancel()
    }

    @Test