Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15ea401f authored by Lee Shombert's avatar Lee Shombert
Browse files

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
parent e3ac890d
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);
        }
    }