Skip to content

Commit 96309e3

Browse files
Paige McAuliffecopybara-androidxtest
authored andcommitted
Use MainScope for tracking window layout info in BaseSingleFoldDeviceAction
PiperOrigin-RevId: 548821296
1 parent ac75043 commit 96309e3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

espresso/device/java/androidx/test/espresso/device/action/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ kt_android_library(
2424
"//runner/monitor",
2525
"@maven//:androidx_window_window",
2626
"@maven//:androidx_window_window_java",
27+
"@maven//:org_jetbrains_kotlinx_kotlinx_coroutines_android",
2728
],
2829
)

espresso/device/java/androidx/test/espresso/device/action/BaseSingleFoldDeviceAction.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ import androidx.window.layout.WindowLayoutInfo
3030
import java.util.concurrent.CountDownLatch
3131
import java.util.concurrent.Executor
3232
import java.util.concurrent.TimeUnit
33-
import kotlinx.coroutines.CoroutineScope
34-
import kotlinx.coroutines.asCoroutineDispatcher
33+
import kotlinx.coroutines.MainScope
3534
import kotlinx.coroutines.flow.collect
3635
import kotlinx.coroutines.flow.distinctUntilChanged
3736
import kotlinx.coroutines.launch
@@ -62,7 +61,7 @@ internal open class BaseSingleFoldDeviceAction(
6261
val latch: CountDownLatch = CountDownLatch(1)
6362
val windowInfoTracker = WindowInfoTracker.getOrCreate(activity)
6463

65-
CoroutineScope(mainExecutor.asCoroutineDispatcher()).launch {
64+
MainScope().launch {
6665
windowInfoTracker.windowLayoutInfo(activity).distinctUntilChanged().collect {
6766
windowLayoutInfo: WindowLayoutInfo ->
6867
val foldingFeatures = windowLayoutInfo.displayFeatures.filterIsInstance<FoldingFeature>()

0 commit comments

Comments
 (0)