Skip to content

Commit 888da15

Browse files
author
Jeff Brown
committed
Enable SQLite configuration to be set with system properties.
This change does not alter the behavior of the system except to enable the use of system properties to override SQLite configuration options for debugging. Bug: 6484633 Change-Id: I8908a3ba07910a1193396e2e45791e9faa7be349
1 parent 8a90e6e commit 888da15

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

core/java/android/database/sqlite/SQLiteGlobal.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.content.res.Resources;
2020
import android.os.StatFs;
21+
import android.os.SystemProperties;
2122

2223
/**
2324
* Provides access to SQLite functions that affect all database connection,
@@ -62,55 +63,63 @@ public static int getDefaultPageSize() {
6263
if (sDefaultPageSize == 0) {
6364
sDefaultPageSize = new StatFs("/data").getBlockSize();
6465
}
65-
return sDefaultPageSize;
66+
return SystemProperties.getInt("debug.sqlite.pagesize", sDefaultPageSize);
6667
}
6768
}
6869

6970
/**
7071
* Gets the default journal mode when WAL is not in use.
7172
*/
7273
public static String getDefaultJournalMode() {
73-
return Resources.getSystem().getString(
74-
com.android.internal.R.string.db_default_journal_mode);
74+
return SystemProperties.get("debug.sqlite.journalmode",
75+
Resources.getSystem().getString(
76+
com.android.internal.R.string.db_default_journal_mode));
7577
}
7678

7779
/**
7880
* Gets the journal size limit in bytes.
7981
*/
8082
public static int getJournalSizeLimit() {
81-
return Resources.getSystem().getInteger(
82-
com.android.internal.R.integer.db_journal_size_limit);
83+
return SystemProperties.getInt("debug.sqlite.journalsizelimit",
84+
Resources.getSystem().getInteger(
85+
com.android.internal.R.integer.db_journal_size_limit));
8386
}
8487

8588
/**
8689
* Gets the default database synchronization mode when WAL is not in use.
8790
*/
8891
public static String getDefaultSyncMode() {
89-
return Resources.getSystem().getString(
90-
com.android.internal.R.string.db_default_sync_mode);
92+
return SystemProperties.get("debug.sqlite.syncmode",
93+
Resources.getSystem().getString(
94+
com.android.internal.R.string.db_default_sync_mode));
9195
}
9296

9397
/**
9498
* Gets the database synchronization mode when in WAL mode.
9599
*/
96100
public static String getWALSyncMode() {
97-
return Resources.getSystem().getString(
98-
com.android.internal.R.string.db_wal_sync_mode);
101+
return SystemProperties.get("debug.sqlite.wal.syncmode",
102+
Resources.getSystem().getString(
103+
com.android.internal.R.string.db_wal_sync_mode));
99104
}
100105

101106
/**
102107
* Gets the WAL auto-checkpoint integer in database pages.
103108
*/
104109
public static int getWALAutoCheckpoint() {
105-
return Math.max(1, Resources.getSystem().getInteger(
110+
int value = SystemProperties.getInt("debug.sqlite.wal.autocheckpoint",
111+
Resources.getSystem().getInteger(
106112
com.android.internal.R.integer.db_wal_autocheckpoint));
113+
return Math.max(1, value);
107114
}
108115

109116
/**
110117
* Gets the connection pool size when in WAL mode.
111118
*/
112119
public static int getWALConnectionPoolSize() {
113-
return Math.max(2, Resources.getSystem().getInteger(
120+
int value = SystemProperties.getInt("debug.sqlite.wal.poolsize",
121+
Resources.getSystem().getInteger(
114122
com.android.internal.R.integer.db_connection_pool_size));
123+
return Math.max(2, value);
115124
}
116125
}

0 commit comments

Comments
 (0)