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

Commit 8ba20891 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

New behavior of setSynchronousMode

setSynchronousMode is now applicable to any journal mode.
This can be useful for apps that want to use stricter durability
settings for their database.

Test: android.database.sqlite.cts.SQLiteDatabaseTest
Bug: 86953240
Change-Id: I7dbaa6d0bc0975da8067e87b402f63f51b4add10
parent 7c0e462b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -296,7 +296,9 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
            final boolean useCompatibilityWal = mConfiguration.useCompatibilityWal();
            if (walEnabled || useCompatibilityWal) {
                setJournalMode("WAL");
                if (useCompatibilityWal && SQLiteCompatibilityWalFlags.areFlagsSet()) {
                if (mConfiguration.syncMode != null) {
                    setSyncMode(mConfiguration.syncMode);
                } else if (useCompatibilityWal && SQLiteCompatibilityWalFlags.areFlagsSet()) {
                    setSyncMode(SQLiteCompatibilityWalFlags.getWALSyncMode());
                } else {
                    setSyncMode(SQLiteGlobal.getWALSyncMode());
+2 −3
Original line number Diff line number Diff line
@@ -2413,8 +2413,7 @@ public final class SQLiteDatabase extends SQLiteClosable {

        /**
         * Returns <a href="https://sqlite.org/pragma.html#pragma_synchronous">synchronous mode</a>.
         * This value will only be used when {@link SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING} flag
         * is not set, otherwise a system wide default will be used.
         * If not set, a system wide default will be used.
         * @see Builder#setSynchronousMode(String)
         */
        @Nullable
@@ -2601,7 +2600,7 @@ public final class SQLiteDatabase extends SQLiteClosable {

            /**
             * Sets <a href="https://sqlite.org/pragma.html#pragma_synchronous">synchronous mode</a>
             * to use when {@link SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING} flag is not set.
             * .
             * @return
             */
            @NonNull
+2 −1
Original line number Diff line number Diff line
@@ -117,8 +117,9 @@ public final class SQLiteDatabaseConfiguration {
    public String journalMode;

    /**
     * Synchronous mode to use when {@link SQLiteDatabase#ENABLE_WRITE_AHEAD_LOGGING} is not set.
     * Synchronous mode to use.
     * <p>Default is returned by {@link SQLiteGlobal#getDefaultSyncMode()}
     * or {@link SQLiteGlobal#getWALSyncMode()} depending on journal mode
     */
    public String syncMode;