diff options
| author | 2025-02-21 10:53:54 -0800 | |
|---|---|---|
| committer | 2025-02-21 11:44:40 -0800 | |
| commit | 15ea401f724ce694d1686771f2bcad8dcbccdd5d (patch) | |
| tree | 26628c253c220382cb412a1e3df45edd740b2f47 | |
| parent | e3ac890d841b42fd803b781f4f12a5c2cfebd34b (diff) | |
Close idle database connections in the background
Idle database connections are now closed on the background thread
instead of the main thread. Closing a database connection can be IO
intensive if it triggers a WAL checkpoint; do not do this on the main
thread.
Idle timeouts are deprecated as of API level 29, so this may not have
much of an effect.
Flag: EXEMPT bug-fix
Bug: 397982577
Test: atest
* FrameworksCoreTests:android.database
* CtsDatabaseTestCases
Change-Id: I7bd49075f978ece5b33bc491487e69c9237843df
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteConnectionPool.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/java/android/database/sqlite/SQLiteConnectionPool.java b/core/java/android/database/sqlite/SQLiteConnectionPool.java index 505905f5aa16..86480fd7b472 100644 --- a/core/java/android/database/sqlite/SQLiteConnectionPool.java +++ b/core/java/android/database/sqlite/SQLiteConnectionPool.java @@ -31,6 +31,7 @@ import android.util.Printer; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.os.BackgroundThread; import dalvik.annotation.optimization.NeverCompile; import dalvik.system.CloseGuard; @@ -187,7 +188,8 @@ public final class SQLiteConnectionPool implements Closeable { // In case of MAX_VALUE - idle connections are never closed if (mConfiguration.idleConnectionTimeoutMs != Long.MAX_VALUE) { setupIdleConnectionHandler( - Looper.getMainLooper(), mConfiguration.idleConnectionTimeoutMs, null); + BackgroundThread.getHandler().getLooper(), + mConfiguration.idleConnectionTimeoutMs, null); } } |