Make userCursor public (but restricted) to be able to use it from test apps.
Bug: 225391870
Test: ./gradlew :room:integration-tests:room-testapp-kotlin:lintWithKspDebug
Change-Id: I9bb43a852a4a40c0de7c2e02bb4be48772542c77
diff --git a/room/integration-tests/kotlintestapp/src/androidTestWithKsp/java/androidx/room/integration/kotlintestapp/NullabilityAwareTypeConversionTest.kt b/room/integration-tests/kotlintestapp/src/androidTestWithKsp/java/androidx/room/integration/kotlintestapp/NullabilityAwareTypeConversionTest.kt
index 85c86ea..5078594 100644
--- a/room/integration-tests/kotlintestapp/src/androidTestWithKsp/java/androidx/room/integration/kotlintestapp/NullabilityAwareTypeConversionTest.kt
+++ b/room/integration-tests/kotlintestapp/src/androidTestWithKsp/java/androidx/room/integration/kotlintestapp/NullabilityAwareTypeConversionTest.kt
@@ -28,6 +28,7 @@
import androidx.room.RoomDatabase
import androidx.room.TypeConverter
import androidx.room.TypeConverters
+import androidx.room.util.useCursor
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -295,7 +296,7 @@
*/
fun getRawData(): String {
return buildString {
- getUsers().use {
+ getUsers().useCursor {
if (it.moveToNext()) {
append(it.getInt(0))
append("-")
diff --git a/room/room-runtime/api/restricted_current.txt b/room/room-runtime/api/restricted_current.txt
index d26a5ed..4900922 100644
--- a/room/room-runtime/api/restricted_current.txt
+++ b/room/room-runtime/api/restricted_current.txt
@@ -253,6 +253,7 @@
method public static android.database.Cursor copyAndClose(android.database.Cursor c);
method public static int getColumnIndex(android.database.Cursor c, String name);
method public static int getColumnIndexOrThrow(android.database.Cursor c, String name);
+ method public static inline <R> R! useCursor(android.database.Cursor, kotlin.jvm.functions.Function1<? super android.database.Cursor,? extends R> block);
}
@RestrictTo({androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public final class DBUtil {
diff --git a/room/room-runtime/src/main/java/androidx/room/util/CursorUtil.kt b/room/room-runtime/src/main/java/androidx/room/util/CursorUtil.kt
index 1969ad0..4402623 100644
--- a/room/room-runtime/src/main/java/androidx/room/util/CursorUtil.kt
+++ b/room/room-runtime/src/main/java/androidx/room/util/CursorUtil.kt
@@ -140,7 +140,7 @@
* Backwards compatible function that executes the given block function on this Cursor and then
* closes the Cursor.
*/
-internal inline fun <R> Cursor.useCursor(block: (Cursor) -> R): R {
+inline fun <R> Cursor.useCursor(block: (Cursor) -> R): R {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
return this.use(block)
} else {