core: add safe mode config to db

This commit is contained in:
vvb2060
2024-01-06 04:00:37 +08:00
committed by John Wu
parent 72b8d12ee4
commit 02e189a029
5 changed files with 38 additions and 24 deletions
+11
View File
@@ -117,6 +117,7 @@ db_settings::db_settings() {
data[SU_MNT_NS] = NAMESPACE_MODE_REQUESTER;
data[DENYLIST_CONFIG] = false;
data[ZYGISK_CONFIG] = MagiskD::get()->is_emulator();
data[SAFEMODE_CONFIG] = false;
}
int db_settings::get_idx(string_view key) const {
@@ -341,6 +342,16 @@ int get_db_settings(db_settings &cfg, int key) {
return 0;
}
int set_db_settings(int key, int value) {
char *err;
char sql[128];
ssprintf(sql, sizeof(sql), "INSERT OR REPLACE INTO settings VALUES ('%s', %d)",
DB_SETTING_KEYS[key], value);
err = db_exec(sql);
db_err_cmd(err, return 1)
return 0;
}
int get_db_strings(db_strings &str, int key) {
char *err = nullptr;
auto string_cb = [&](db_row &row) -> bool {