Mark enableAutoClose as Experimental and remove the library restricted annotation.

Bug: 137223459
Relnote: This change enables auto-closing for databases. When enabled, database connections are closed after the specified timeout and are re-opened automatically on next access.
Test: See parent cls
Change-Id: I9fb6b3bc02b9fb76dba6ebaa1edb12f724a82c1a
diff --git a/room/runtime/api/current.txt b/room/runtime/api/current.txt
index 061b0ad..460a85c 100644
--- a/room/runtime/api/current.txt
+++ b/room/runtime/api/current.txt
@@ -86,6 +86,7 @@
     method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationFrom(int...);
     method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationOnDowngrade();
     method public androidx.room.RoomDatabase.Builder<T!> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory?);
+    method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(long, java.util.concurrent.TimeUnit);
     method public androidx.room.RoomDatabase.Builder<T!> setJournalMode(androidx.room.RoomDatabase.JournalMode);
     method public androidx.room.RoomDatabase.Builder<T!> setQueryCallback(androidx.room.RoomDatabase.QueryCallback, java.util.concurrent.Executor);
     method public androidx.room.RoomDatabase.Builder<T!> setQueryExecutor(java.util.concurrent.Executor);
diff --git a/room/runtime/api/public_plus_experimental_current.txt b/room/runtime/api/public_plus_experimental_current.txt
index e1cefb2..5813624 100644
--- a/room/runtime/api/public_plus_experimental_current.txt
+++ b/room/runtime/api/public_plus_experimental_current.txt
@@ -87,6 +87,7 @@
     method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationFrom(int...);
     method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationOnDowngrade();
     method public androidx.room.RoomDatabase.Builder<T!> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory?);
+    method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(long, java.util.concurrent.TimeUnit);
     method public androidx.room.RoomDatabase.Builder<T!> setJournalMode(androidx.room.RoomDatabase.JournalMode);
     method public androidx.room.RoomDatabase.Builder<T!> setQueryCallback(androidx.room.RoomDatabase.QueryCallback, java.util.concurrent.Executor);
     method public androidx.room.RoomDatabase.Builder<T!> setQueryExecutor(java.util.concurrent.Executor);
diff --git a/room/runtime/api/restricted_current.txt b/room/runtime/api/restricted_current.txt
index 4b2d12a..31ff929 100644
--- a/room/runtime/api/restricted_current.txt
+++ b/room/runtime/api/restricted_current.txt
@@ -129,6 +129,7 @@
     method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationFrom(int...);
     method public androidx.room.RoomDatabase.Builder<T!> fallbackToDestructiveMigrationOnDowngrade();
     method public androidx.room.RoomDatabase.Builder<T!> openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory?);
+    method public androidx.room.RoomDatabase.Builder<T!> setAutoCloseTimeout(long, java.util.concurrent.TimeUnit);
     method public androidx.room.RoomDatabase.Builder<T!> setJournalMode(androidx.room.RoomDatabase.JournalMode);
     method public androidx.room.RoomDatabase.Builder<T!> setQueryCallback(androidx.room.RoomDatabase.QueryCallback, java.util.concurrent.Executor);
     method public androidx.room.RoomDatabase.Builder<T!> setQueryExecutor(java.util.concurrent.Executor);
diff --git a/room/runtime/build.gradle b/room/runtime/build.gradle
index fbce4b2..2d0c65c 100644
--- a/room/runtime/build.gradle
+++ b/room/runtime/build.gradle
@@ -42,6 +42,7 @@
     implementation("androidx.arch.core:core-runtime:2.0.1")
     compileOnly(projectOrArtifact(":paging:paging-common"))
     compileOnly("androidx.lifecycle:lifecycle-livedata-core:2.0.0")
+    implementation project(":annotation:annotation-experimental")
 
     testImplementation("androidx.arch.core:core-testing:2.0.1")
     testImplementation(JUNIT)
diff --git a/room/runtime/src/androidTest/java/androidx/room/AutoCloserTest.kt b/room/runtime/src/androidTest/java/androidx/room/AutoCloserTest.kt
index bee72dd..1a6147b 100644
--- a/room/runtime/src/androidTest/java/androidx/room/AutoCloserTest.kt
+++ b/room/runtime/src/androidTest/java/androidx/room/AutoCloserTest.kt
@@ -23,7 +23,7 @@
 import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
 import androidx.test.core.app.ApplicationProvider
 import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
+import androidx.test.filters.MediumTest
 import androidx.testutils.assertThrows
 import com.google.common.truth.Truth.assertThat
 import org.junit.After
@@ -35,7 +35,7 @@
 import java.util.concurrent.TimeUnit
 
 @RunWith(AndroidJUnit4::class)
-@SmallTest
+@MediumTest
 public class AutoCloserTest {
 
     @get:Rule
diff --git a/room/runtime/src/main/java/androidx/room/ExperimentalRoomApi.java b/room/runtime/src/main/java/androidx/room/ExperimentalRoomApi.java
new file mode 100644
index 0000000..7396429
--- /dev/null
+++ b/room/runtime/src/main/java/androidx/room/ExperimentalRoomApi.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package androidx.room;
+
+import androidx.annotation.RequiresOptIn;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+
+/**
+ * APIs marked with ExperimentalRoomApi are experimental and may change.
+ */
+@Target({ElementType.METHOD})
+@RequiresOptIn()
+@interface ExperimentalRoomApi {}
diff --git a/room/runtime/src/main/java/androidx/room/RoomDatabase.java b/room/runtime/src/main/java/androidx/room/RoomDatabase.java
index f94bd74..d76e1c1 100644
--- a/room/runtime/src/main/java/androidx/room/RoomDatabase.java
+++ b/room/runtime/src/main/java/androidx/room/RoomDatabase.java
@@ -1211,29 +1211,29 @@
          * <p>
          * Also, temp tables and temp triggers will be cleared each time the database is
          * auto-closed. If you need to use them, please include them in your
-         * {@link RoomDatabase.Callback.OnOpen callback}.
+         * {@link RoomDatabase.Callback#onOpen callback}.
          * <p>
-         * All configuration should happen in your {@link RoomDatabase.Callback.onOpen}
+         * All configuration should happen in your {@link RoomDatabase.Callback#onOpen}
          * callback so it is re-applied every time the database is re-opened. Note that the
-         * {@link RoomDatabase.Callback.onOpen} will be called every time the database is re-opened.
+         * {@link RoomDatabase.Callback#onOpen} will be called every time the database is re-opened.
          * <p>
          * The auto-closing database operation runs on the query executor.
          * <p>
          * The database will not be reopened if the RoomDatabase or the
          * SupportSqliteOpenHelper is closed manually (by calling
-         * {@link RoomDatabase.close()} or {@link SupportSQLiteOpenHelper.close()}. If the
+         * {@link RoomDatabase#close()} or {@link SupportSQLiteOpenHelper#close()}. If the
          * database is closed manually, you must create a new database using
-         * {@link RoomDatabase.Builder.build()}.
+         * {@link RoomDatabase.Builder#build()}.
          *
          * @param autoCloseTimeout  the amount of time after the last usage before closing the
          *                          database
          * @param autoCloseTimeUnit the timeunit for autoCloseTimeout.
          * @return This {@link Builder} instance
-         *
-         * @hide until it's ready for use
          */
         @NonNull
-        @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+        @SuppressWarnings("MissingGetterMatchingBuilder")
+        @ExperimentalRoomApi // When experimental is removed, add these parameters to
+        // DatabaseConfiguration
         public Builder<T> setAutoCloseTimeout(long autoCloseTimeout,
                 @NonNull TimeUnit autoCloseTimeUnit) {
             if (autoCloseTimeout < 0) {