Loading core/java/android/database/sqlite/SQLiteConnection.java +3 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,9 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen private void setWalModeFromConfiguration() { if (!mConfiguration.isInMemoryDb() && !mIsReadOnlyConnection) { if ((mConfiguration.openFlags & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0) { boolean walEnabled = (mConfiguration.openFlags & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0; if (walEnabled || mConfiguration.useCompatibilityWal) { setJournalMode("WAL"); setSyncMode(SQLiteGlobal.getWALSyncMode()); } else { Loading core/java/android/database/sqlite/SQLiteDatabase.java +9 −2 Original line number Diff line number Diff line Loading @@ -285,6 +285,7 @@ public final class SQLiteDatabase extends SQLiteClosable { } } mConfigurationLocked.idleConnectionTimeoutMs = effectiveTimeoutMs; mConfigurationLocked.useCompatibilityWal = SQLiteGlobal.isCompatibilityWalSupported(); } @Override Loading Loading @@ -2070,15 +2071,21 @@ public final class SQLiteDatabase extends SQLiteClosable { synchronized (mLock) { throwIfNotOpenLocked(); if ((mConfigurationLocked.openFlags & ENABLE_WRITE_AHEAD_LOGGING) == 0) { final boolean oldUseCompatibilityWal = mConfigurationLocked.useCompatibilityWal; final int oldFlags = mConfigurationLocked.openFlags; if (!oldUseCompatibilityWal && (oldFlags & ENABLE_WRITE_AHEAD_LOGGING) == 0) { return; } mConfigurationLocked.openFlags &= ~ENABLE_WRITE_AHEAD_LOGGING; // If an app explicitly disables WAL, do not even use compatibility mode mConfigurationLocked.useCompatibilityWal = false; try { mConnectionPoolLocked.reconfigure(mConfigurationLocked); } catch (RuntimeException ex) { mConfigurationLocked.openFlags |= ENABLE_WRITE_AHEAD_LOGGING; mConfigurationLocked.openFlags = oldFlags; mConfigurationLocked.useCompatibilityWal = oldUseCompatibilityWal; throw ex; } } Loading core/java/android/database/sqlite/SQLiteDatabaseConfiguration.java +10 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,15 @@ public final class SQLiteDatabaseConfiguration { */ public long idleConnectionTimeoutMs = Long.MAX_VALUE; /** * Enables compatibility WAL mode. Applications cannot explicitly choose compatibility WAL mode, * therefore it is not exposed as a flag. * * <p>In this mode, only database journal mode will be changed, connection pool * size will still be limited to a single connection. */ public boolean useCompatibilityWal; /** * Creates a database configuration with the required parameters for opening a * database and default values for all other parameters. Loading Loading @@ -170,6 +179,7 @@ public final class SQLiteDatabaseConfiguration { lookasideSlotSize = other.lookasideSlotSize; lookasideSlotCount = other.lookasideSlotCount; idleConnectionTimeoutMs = other.idleConnectionTimeoutMs; useCompatibilityWal = other.useCompatibilityWal; } /** Loading core/java/android/database/sqlite/SQLiteGlobal.java +11 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,17 @@ public final class SQLiteGlobal { com.android.internal.R.string.db_default_journal_mode)); } /** * Returns true if compatibility WAL mode is supported. In this mode, only * database journal mode is changed. Connection pool will use at most one connection. * @hide */ public static boolean isCompatibilityWalSupported() { return SystemProperties.getBoolean("debug.sqlite.compatibility_wal_supported", Resources.getSystem().getBoolean( com.android.internal.R.bool.db_compatibility_wal_supported)); } /** * Gets the journal size limit in bytes. */ Loading core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1698,6 +1698,11 @@ a transaction, so it interacts poorly with SECURE_DELETE. --> <string name="db_default_journal_mode" translatable="false">TRUNCATE</string> <!-- Enables compatibility WAL mode. In this mode, only database journal mode will be changed, connection pool size will still be limited to a single connection. --> <bool name="db_compatibility_wal_supported">true</bool> <!-- Maximum size of the persistent journal file in bytes. If the journal file grows to be larger than this amount then SQLite will truncate it after committing the transaction. --> Loading Loading
core/java/android/database/sqlite/SQLiteConnection.java +3 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,9 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen private void setWalModeFromConfiguration() { if (!mConfiguration.isInMemoryDb() && !mIsReadOnlyConnection) { if ((mConfiguration.openFlags & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0) { boolean walEnabled = (mConfiguration.openFlags & SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING) != 0; if (walEnabled || mConfiguration.useCompatibilityWal) { setJournalMode("WAL"); setSyncMode(SQLiteGlobal.getWALSyncMode()); } else { Loading
core/java/android/database/sqlite/SQLiteDatabase.java +9 −2 Original line number Diff line number Diff line Loading @@ -285,6 +285,7 @@ public final class SQLiteDatabase extends SQLiteClosable { } } mConfigurationLocked.idleConnectionTimeoutMs = effectiveTimeoutMs; mConfigurationLocked.useCompatibilityWal = SQLiteGlobal.isCompatibilityWalSupported(); } @Override Loading Loading @@ -2070,15 +2071,21 @@ public final class SQLiteDatabase extends SQLiteClosable { synchronized (mLock) { throwIfNotOpenLocked(); if ((mConfigurationLocked.openFlags & ENABLE_WRITE_AHEAD_LOGGING) == 0) { final boolean oldUseCompatibilityWal = mConfigurationLocked.useCompatibilityWal; final int oldFlags = mConfigurationLocked.openFlags; if (!oldUseCompatibilityWal && (oldFlags & ENABLE_WRITE_AHEAD_LOGGING) == 0) { return; } mConfigurationLocked.openFlags &= ~ENABLE_WRITE_AHEAD_LOGGING; // If an app explicitly disables WAL, do not even use compatibility mode mConfigurationLocked.useCompatibilityWal = false; try { mConnectionPoolLocked.reconfigure(mConfigurationLocked); } catch (RuntimeException ex) { mConfigurationLocked.openFlags |= ENABLE_WRITE_AHEAD_LOGGING; mConfigurationLocked.openFlags = oldFlags; mConfigurationLocked.useCompatibilityWal = oldUseCompatibilityWal; throw ex; } } Loading
core/java/android/database/sqlite/SQLiteDatabaseConfiguration.java +10 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,15 @@ public final class SQLiteDatabaseConfiguration { */ public long idleConnectionTimeoutMs = Long.MAX_VALUE; /** * Enables compatibility WAL mode. Applications cannot explicitly choose compatibility WAL mode, * therefore it is not exposed as a flag. * * <p>In this mode, only database journal mode will be changed, connection pool * size will still be limited to a single connection. */ public boolean useCompatibilityWal; /** * Creates a database configuration with the required parameters for opening a * database and default values for all other parameters. Loading Loading @@ -170,6 +179,7 @@ public final class SQLiteDatabaseConfiguration { lookasideSlotSize = other.lookasideSlotSize; lookasideSlotCount = other.lookasideSlotCount; idleConnectionTimeoutMs = other.idleConnectionTimeoutMs; useCompatibilityWal = other.useCompatibilityWal; } /** Loading
core/java/android/database/sqlite/SQLiteGlobal.java +11 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,17 @@ public final class SQLiteGlobal { com.android.internal.R.string.db_default_journal_mode)); } /** * Returns true if compatibility WAL mode is supported. In this mode, only * database journal mode is changed. Connection pool will use at most one connection. * @hide */ public static boolean isCompatibilityWalSupported() { return SystemProperties.getBoolean("debug.sqlite.compatibility_wal_supported", Resources.getSystem().getBoolean( com.android.internal.R.bool.db_compatibility_wal_supported)); } /** * Gets the journal size limit in bytes. */ Loading
core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1698,6 +1698,11 @@ a transaction, so it interacts poorly with SECURE_DELETE. --> <string name="db_default_journal_mode" translatable="false">TRUNCATE</string> <!-- Enables compatibility WAL mode. In this mode, only database journal mode will be changed, connection pool size will still be limited to a single connection. --> <bool name="db_compatibility_wal_supported">true</bool> <!-- Maximum size of the persistent journal file in bytes. If the journal file grows to be larger than this amount then SQLite will truncate it after committing the transaction. --> Loading