Rename db entry name

This commit is contained in:
topjohnwu
2024-05-15 12:24:03 +08:00
committed by John Wu
parent dd3b9980e7
commit 6c27ba6b88
5 changed files with 15 additions and 15 deletions

View File

@@ -122,14 +122,13 @@ static bool check_key_combo() {
}
static bool check_safe_mode() {
int safe_mode;
int bootloop_cnt;
db_settings dbs;
get_db_settings(dbs, SAFEMODE_CONFIG);
safe_mode = dbs[SAFEMODE_CONFIG];
set_db_settings(SAFEMODE_CONFIG, safe_mode + 1);
return safe_mode >= 2 || get_prop("persist.sys.safemode", true) == "1" ||
get_db_settings(dbs, BOOTLOOP_COUNT);
bootloop_cnt = dbs[BOOTLOOP_COUNT];
// Increment the bootloop counter
set_db_settings(BOOTLOOP_COUNT, bootloop_cnt + 1);
return bootloop_cnt >= 2 || get_prop("persist.sys.safemode", true) == "1" ||
get_prop("ro.sys.safemode") == "1" || check_key_combo();
}
@@ -197,7 +196,8 @@ void MagiskD::boot_complete() const {
LOGI("** boot-complete triggered\n");
set_db_settings(SAFEMODE_CONFIG, 0);
// Reset the bootloop counter once we have boot-complete
set_db_settings(BOOTLOOP_COUNT, 0);
// At this point it's safe to create the folder
if (access(SECURE_DIR, F_OK) != 0)

View File

@@ -117,7 +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;
data[BOOTLOOP_COUNT] = 0;
}
int db_settings::get_idx(string_view key) const {

View File

@@ -40,7 +40,7 @@ constexpr const char *DB_SETTING_KEYS[] = {
"mnt_ns",
"denylist",
"zygisk",
"safemode",
"bootloop",
};
// Settings key indices
@@ -50,7 +50,7 @@ enum {
SU_MNT_NS,
DENYLIST_CONFIG,
ZYGISK_CONFIG,
SAFEMODE_CONFIG,
BOOTLOOP_COUNT,
};
// Values for root_access