Merge "Rename flag wal_db_journalmode" into main
diff --git a/keystore2/aconfig/flags.aconfig b/keystore2/aconfig/flags.aconfig
index 41e1a92..725df2a 100644
--- a/keystore2/aconfig/flags.aconfig
+++ b/keystore2/aconfig/flags.aconfig
@@ -1,7 +1,7 @@
 package: "android.security.keystore2"
 
 flag {
-  name: "wal_db_journalmode"
+  name: "wal_db_journalmode_v2"
   namespace: "hardware_backed_security"
   description: "This flag controls changing journalmode to wal"
   bug: "191777960"
diff --git a/keystore2/legacykeystore/Android.bp b/keystore2/legacykeystore/Android.bp
index 505b165..accc8b2 100644
--- a/keystore2/legacykeystore/Android.bp
+++ b/keystore2/legacykeystore/Android.bp
@@ -32,6 +32,7 @@
         "libanyhow",
         "libbinder_rs",
         "liblog_rust",
+        "libkeystore2_flags_rust",
         "librusqlite",
         "librustutils",
         "libthiserror",
@@ -58,6 +59,7 @@
         "libanyhow",
         "libbinder_rs",
         "libkeystore2",
+        "libkeystore2_flags_rust",
         "libkeystore2_test_utils",
         "liblog_rust",
         "librusqlite",
diff --git a/keystore2/legacykeystore/lib.rs b/keystore2/legacykeystore/lib.rs
index 55224f7..edc530a 100644
--- a/keystore2/legacykeystore/lib.rs
+++ b/keystore2/legacykeystore/lib.rs
@@ -46,6 +46,12 @@
             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 63dbf7f..93de484 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -1036,7 +1036,7 @@
             break;
         }
 
-        if keystore2_flags::wal_db_journalmode() {
+        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")?;