Status Update
Comments
da...@google.com <da...@google.com> #2
Also consider removing internalInitInvalidationTracker(androidx.sqlite.SQLiteConnection connection)
and replacing it with an installed RoomDatabase.Callback
or with a OpenDelegate
such that the gen-code restricted API can be avoided.
ap...@google.com <ap...@google.com> #3
Branch: androidx-main
commit 93d98afa5bf2f4f9c0a5dbd4046bfbba167b4cae
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Fri Jan 26 10:22:38 2024
Partially commonize InvalidationTracker
Just enough commonization so that we can generate valid KMP code and remove the last remaining Java collections usages in the database writer.
Bug: 299168035
Bug: 309990302
Test: Existing
Change-Id: I9aa3909085d910d708ed84f21a813c242175c94b
M room/room-compiler/src/main/kotlin/androidx/room/writer/DatabaseWriter.kt
M room/room-compiler/src/test/test-data/databasewriter/output/ComplexDatabase.java
M room/room-compiler/src/test/test-data/kotlinCodeGen/database_internalVisibility.kt
M room/room-compiler/src/test/test-data/kotlinCodeGen/database_simple.kt
M room/room-compiler/src/test/test-data/kotlinCodeGen/database_withFtsAndView.kt
M room/room-runtime/api/restricted_current.txt
M room/room-runtime/src/androidMain/kotlin/androidx/room/InvalidationTracker.android.kt
M room/room-runtime/src/androidMain/kotlin/androidx/room/RoomDatabase.android.kt
M room/room-runtime/src/androidUnitTest/kotlin/androidx/room/InvalidationTrackerTest.kt
A room/room-runtime/src/commonMain/kotlin/androidx/room/InvalidationTracker.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/RoomDatabase.kt
A room/room-runtime/src/jvmMain/kotlin/androidx/room/InvalidationTracker.jvm.kt
M room/room-runtime/src/jvmMain/kotlin/androidx/room/RoomDatabase.jvm.kt
A room/room-runtime/src/nativeMain/kotlin/androidx/room/InvalidationTracker.native.kt
M room/room-runtime/src/nativeMain/kotlin/androidx/room/RoomDatabase.native.kt
M room/room-runtime/src/nativeTest/kotlin/androidx.room/BuilderTest_TestDatabase_Impl.kt
da...@google.com <da...@google.com>
da...@google.com <da...@google.com> #4
A design doc about Room + Coroutines:
The TL;DR is:
-
Room will accept a
CoroutineContext
to allow the developer to configure a dispatcher and to be used for Coroutine related things. Internally Room will likely create aCoroutineScope
based on the given context. The scope is cancelled when the database is closed. -
Room operations that use low-level SQLiteConnection internally and/or exposed to the user will be dispatched in the configured CoroutineContext.
ap...@google.com <ap...@google.com> #5
Branch: androidx-main
commit 5305f501aab1025df547b3b43fa1c19204a219bc
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Tue Mar 05 12:59:21 2024
Commonize InvalidationTracker's table observability state
Move the helper class that tracks whether a table needs to be observed or not based on register Observer into common code.
Bug: 299168035
Bug: 309990302
Test: ObservedTableStates + Existing
Change-Id: I1d4622ead35cdb08693addfe2ef02cc711da7c71
M room/room-runtime/src/androidMain/kotlin/androidx/room/InvalidationTracker.android.kt
A room/room-runtime/src/androidUnitTest/kotlin/androidx/room/ObservedTableStatesTest.kt
D room/room-runtime/src/androidUnitTest/kotlin/androidx/room/ObservedTableTrackerTest.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/InvalidationTracker.kt
ap...@google.com <ap...@google.com> #6
Branch: androidx-main
commit 213765d55d5bea60e1a4ca40228f661ef300e49b
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Tue Mar 05 13:25:31 2024
Commonize InvalidationTracker.Observer
Define the tracker's observer class in common and move the internal wrapper used for dispatching notifications to common source sets too.
Bug: 299168035
Bug: 309990302
Test: Existing
Change-Id: I7a95be774467c49d7a48ce9c56f467a2628fc211
M room/room-runtime/src/androidMain/kotlin/androidx/room/InvalidationTracker.android.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/InvalidationTracker.kt
M room/room-runtime/src/jvmNativeMain/kotlin/androidx/room/InvalidationTracker.jvmNative.kt
ap...@google.com <ap...@google.com> #7
Branch: androidx-main
commit 7058e53a8187fe9aa219ef6519eaad253a08cb46
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Tue Mar 05 20:07:14 2024
Commonize InvalidationTracker
Move the bulk of the TRIGGER logic in Room's InvalidationTracker to an internal class in the common source set called TriggerBasedInvalidationTracker. The public APIs of InvalidationTracker will then delegate to the internal implementation allowing functionality to be shared across platforms.
Asynchronous related logic has been migrated to Coroutines using Room's new CoroutineScope and provided CoroutineContext.
Two new APIs are added to the common version of the tracker (and available to Android too), 'subscribe' and 'unsubscribe' suspend functions to add and remove observers from the tracker.
Bug: 299168035
Bug: 309990302
Bug: 309996304
Test: Existing++
Relnote: "Add suspend APIs for subscribing and unsubscribing InvalidationTracker.Observer with the RoomDatabase tracker."
Change-Id: If2a1f5b2442c6772b67afcae92996d1a8a9ff2ac
D room/integration-tests/kotlintestapp/src/androidTest/java/InvalidationTrackerExt.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/FlowQueryTest.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/MultiTypedPagingSourceTest.kt
A room/integration-tests/multiplatformtestapp/src/androidInstrumentedTest/kotlin/androidx/room/integration/multiplatformtestapp/test/InvalidationTest.kt
A room/integration-tests/multiplatformtestapp/src/commonTest/kotlin/androidx/room/integration/multiplatformtestapp/test/BaseInvalidationTest.kt
M room/integration-tests/multiplatformtestapp/src/commonTest/kotlin/androidx/room/integration/multiplatformtestapp/test/BaseSimpleQueryTest.kt
A room/integration-tests/multiplatformtestapp/src/jvmTest/kotlin/androidx/room/integration/multiplatformtestapp/test/InvalidationTest.kt
A room/integration-tests/multiplatformtestapp/src/nativeTest/kotlin/androidx/room/integration/multiplatformtestapp/test/InvalidationTest.kt
D room/integration-tests/testapp/src/androidTest/java/androidx/room/InvalidationTrackerTrojan.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/AutoClosingRoomOpenHelperTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/LiveDataQueryTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/MultiInstanceInvalidationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/QueryTransactionTest.java
D room/room-paging/src/androidTest/kotlin/androidx/room/InvalidationTrackerExtRoomPaging.kt
M room/room-paging/src/androidTest/kotlin/androidx/room/paging/LimitOffsetPagingSourceTest.kt
M room/room-runtime/api/restricted_current.txt
M room/room-runtime/src/androidInstrumentedTest/kotlin/androidx/room/CoroutineRoomCancellationTest.kt
A room/room-runtime/src/androidInstrumentedTest/kotlin/androidx/room/support/AutoClosingDatabaseTest.kt
M room/room-runtime/src/androidMain/kotlin/androidx/room/InvalidationTracker.android.kt
M room/room-runtime/src/androidMain/kotlin/androidx/room/MultiInstanceInvalidationClient.android.kt
M room/room-runtime/src/androidMain/kotlin/androidx/room/RoomDatabase.android.kt
M room/room-runtime/src/androidMain/kotlin/androidx/room/util/DBUtil.android.kt
M room/room-runtime/src/androidUnitTest/kotlin/androidx/room/InvalidationTrackerTest.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/InvalidationTracker.kt
M room/room-runtime/src/commonMain/kotlin/androidx/room/util/DBUtil.kt
M room/room-runtime/src/jvmNativeMain/kotlin/androidx/room/InvalidationTracker.jvmNative.kt
M room/room-runtime/src/jvmNativeMain/kotlin/androidx/room/RoomDatabase.jvmNative.kt
M room/room-runtime/src/jvmNativeMain/kotlin/androidx/room/util/DBUtil.jvmNative.kt
Description