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

Commit 7b04c417 authored by Vasu Nori's avatar Vasu Nori
Browse files

make disableWriteAheadLogging method public so apps can disable WAL

music2 app has the weird situation where it embeds the jumper C++ code
and that code uses its own version of sqlite.
so, java side may want to disable WAL to make c++ code work well with java
usage of sqlite.
since WAL is made default option for all apps, this CL makes it possible for
music2 app to disable WAL.

Change-Id: I39ddbc9b4648f12b206ff3e76d30341da5955bd4
parent 3f15301c
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -400,6 +400,7 @@ public class SQLiteDatabase extends SQLiteClosable {
     * @see #unlock()
     */
    /* package */ void lock() {
        verifyDbIsOpen();
        if (!mLockingEnabled) return;
        mLock.lock();
        if (SQLiteDebug.DEBUG_LOCK_TIME_TRACKING) {
@@ -420,6 +421,7 @@ public class SQLiteDatabase extends SQLiteClosable {
     * @see #unlockForced()
     */
    private void lockForced() {
        verifyDbIsOpen();
        mLock.lock();
        if (SQLiteDebug.DEBUG_LOCK_TIME_TRACKING) {
            if (mLock.getHoldCount() == 1) {
@@ -952,7 +954,10 @@ public class SQLiteDatabase extends SQLiteClosable {
        //STOPSHIP - uncomment the following line
        //sqliteDatabase.setJournalMode(path, "TRUNCATE");
        // STOPSHIP remove the following lines
        if (!path.equalsIgnoreCase(MEMORY_DB_PATH)) {
            sqliteDatabase.enableWriteAheadLogging();
        }
        // END STOPSHIP

        // add this database to the list of databases opened in this process
        ActiveDatabases.addActiveDatabase(sqliteDatabase);
@@ -2406,14 +2411,18 @@ public class SQLiteDatabase extends SQLiteClosable {
    }

    /**
     * package visibility only for testing purposes
     * This method disables the features enabled by {@link #enableWriteAheadLogging()}.
     * @hide
     */
    /* package */ synchronized void disableWriteAheadLogging() {
    public void disableWriteAheadLogging() {
        synchronized (this) {
            if (mConnectionPool == null) {
                return;
            }
            mConnectionPool.close();
            mConnectionPool = null;
            setJournalMode(mPath, "TRUNCATE");
        }
    }

    /**