diff options
-rw-r--r-- | keystore2/aconfig/flags.aconfig | 2 | ||||
-rw-r--r-- | keystore2/legacykeystore/lib.rs | 6 | ||||
-rw-r--r-- | keystore2/src/database.rs | 13 |
3 files changed, 9 insertions, 12 deletions
diff --git a/keystore2/aconfig/flags.aconfig b/keystore2/aconfig/flags.aconfig index 7bdb0074..133c4abe 100644 --- a/keystore2/aconfig/flags.aconfig +++ b/keystore2/aconfig/flags.aconfig @@ -1,7 +1,7 @@ package: "android.security.keystore2" flag { - name: "wal_db_journalmode_v2" + name: "wal_db_journalmode_v3" namespace: "hardware_backed_security" description: "This flag controls changing journalmode to wal" bug: "191777960" diff --git a/keystore2/legacykeystore/lib.rs b/keystore2/legacykeystore/lib.rs index a665405e..f7a81983 100644 --- a/keystore2/legacykeystore/lib.rs +++ b/keystore2/legacykeystore/lib.rs @@ -46,12 +46,6 @@ impl DB { conn: Connection::open(db_file).context("Failed to initialize SQLite connection.")?, }; - if keystore2_flags::wal_db_journalmode_v2() { - // Update journal mode to WAL - db.conn - .pragma_update(None, "journal_mode", "WAL") - .context("Failed to connect in WAL mode for persistent db")?; - } db.init_tables().context("Trying to initialize legacy keystore db.")?; Ok(db) } diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs index 93de4844..15ceed60 100644 --- a/keystore2/src/database.rs +++ b/keystore2/src/database.rs @@ -1014,6 +1014,14 @@ impl KeystoreDB { let mut persistent_path_str = "file:".to_owned(); persistent_path_str.push_str(&persistent_path.to_string_lossy()); + // Connect to database in specific mode + let persistent_path_mode = if keystore2_flags::wal_db_journalmode_v3() { + "?journal_mode=WAL".to_owned() + } else { + "?journal_mode=DELETE".to_owned() + }; + persistent_path_str.push_str(&persistent_path_mode); + Ok(persistent_path_str) } @@ -1036,11 +1044,6 @@ impl KeystoreDB { break; } - if keystore2_flags::wal_db_journalmode_v2() { - // Update journal mode to WAL - conn.pragma_update(None, "journal_mode", "WAL") - .context("Failed to connect in WAL mode for persistent db")?; - } // Drop the cache size from default (2M) to 0.5M conn.execute("PRAGMA persistent.cache_size = -500;", params![]) .context("Failed to decrease cache size for persistent db")?; |