summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaquille Johnson <ssjohnson@google.com>2023-11-23 11:12:18 +0000
committerShaquille Johnson <ssjohnson@google.com>2023-11-27 12:17:13 +0000
commitd28f5cbe9b53e493fa6f8a4eb0081f39afb904c0 (patch)
treec350f3c7de23703d9bf2680e4617352bf8bdc528
parent39b7af2fcdce144cda6377533b3374423f85008a (diff)
downloadsecurity-d28f5cbe9b53e493fa6f8a4eb0081f39afb904c0.tar.gz
Rename flag wal_db_journalmode
This flag was defined as a regular flag and then was later changed to a fixed_read_only flag. This scenario is currently "unsupported" by the flags infrastructure; an error occurs when trying to advance the flag to staging. Work around this by renaming the flag so that the flags infrastructure sees it as an entirely new flag. This cl adds this flag to the legacykeystore code as well. Bug: 296464083 Bug: 311648623 Test: m keystore2 Change-Id: If62a5fac2404113ca0bbc0807f154401c4241bf1
-rw-r--r--keystore2/aconfig/flags.aconfig2
-rw-r--r--keystore2/legacykeystore/Android.bp2
-rw-r--r--keystore2/legacykeystore/lib.rs6
-rw-r--r--keystore2/src/database.rs2
4 files changed, 10 insertions, 2 deletions
diff --git a/keystore2/aconfig/flags.aconfig b/keystore2/aconfig/flags.aconfig
index 41e1a92b..725df2a9 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 505b1653..accc8b2c 100644
--- a/keystore2/legacykeystore/Android.bp
+++ b/keystore2/legacykeystore/Android.bp
@@ -32,6 +32,7 @@ rust_defaults {
"libanyhow",
"libbinder_rs",
"liblog_rust",
+ "libkeystore2_flags_rust",
"librusqlite",
"librustutils",
"libthiserror",
@@ -58,6 +59,7 @@ rust_test {
"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 55224f72..edc530a8 100644
--- a/keystore2/legacykeystore/lib.rs
+++ b/keystore2/legacykeystore/lib.rs
@@ -46,6 +46,12 @@ 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 63dbf7f4..93de4844 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -1036,7 +1036,7 @@ impl KeystoreDB {
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")?;