Default to FULL synchronous mode for sqlite DBs in system server
Test: change pin and immediately crash the kernel with
adb shell 'su root sh -c "echo c >/proc/sysrq-trigger"' and boot
Bug: 112175067
Change-Id: Ia5f43f3118e2297fbea43c805ef2f4577bf8a9bf
(cherry picked from commit 50e00c8dc48849280410e38bb05a1f11ce24ef01)
diff --git a/core/java/android/database/sqlite/SQLiteGlobal.java b/core/java/android/database/sqlite/SQLiteGlobal.java
index d6d9764..e6b6acf 100644
--- a/core/java/android/database/sqlite/SQLiteGlobal.java
+++ b/core/java/android/database/sqlite/SQLiteGlobal.java
@@ -39,11 +39,18 @@
public final class SQLiteGlobal {
private static final String TAG = "SQLiteGlobal";
+ /** @hide */
+ public static final String SYNC_MODE_FULL = "FULL";
+
private static final Object sLock = new Object();
+
private static int sDefaultPageSize;
private static native int nativeReleaseMemory();
+ /** @hide */
+ public static volatile String sDefaultSyncMode;
+
private SQLiteGlobal() {
}
@@ -103,6 +110,11 @@
* Gets the default database synchronization mode when WAL is not in use.
*/
public static String getDefaultSyncMode() {
+ // Use the FULL synchronous mode for system processes by default.
+ String defaultMode = sDefaultSyncMode;
+ if (defaultMode != null) {
+ return defaultMode;
+ }
return SystemProperties.get("debug.sqlite.syncmode",
Resources.getSystem().getString(
com.android.internal.R.string.db_default_sync_mode));
@@ -112,6 +124,11 @@
* Gets the database synchronization mode when in WAL mode.
*/
public static String getWALSyncMode() {
+ // Use the FULL synchronous mode for system processes by default.
+ String defaultMode = sDefaultSyncMode;
+ if (defaultMode != null) {
+ return defaultMode;
+ }
return SystemProperties.get("debug.sqlite.wal.syncmode",
Resources.getSystem().getString(
com.android.internal.R.string.db_wal_sync_mode));
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 1880e9f..3c833d8 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -28,6 +28,7 @@
import android.content.res.Configuration;
import android.content.res.Resources.Theme;
import android.database.sqlite.SQLiteCompatibilityWalFlags;
+import android.database.sqlite.SQLiteGlobal;
import android.os.BaseBundle;
import android.os.Binder;
import android.os.Build;
@@ -346,6 +347,10 @@
Binder.setWarnOnBlocking(true);
// The system server should always load safe labels
PackageItemInfo.setForceSafeLabels(true);
+
+ // Default to FULL within the system server.
+ SQLiteGlobal.sDefaultSyncMode = SQLiteGlobal.SYNC_MODE_FULL;
+
// Deactivate SQLiteCompatibilityWalFlags until settings provider is initialized
SQLiteCompatibilityWalFlags.init(null);