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

@ -40,7 +40,7 @@ object Config : PreferenceConfig, DBConfig {
const val SU_MNT_NS = "mnt_ns" const val SU_MNT_NS = "mnt_ns"
const val SU_BIOMETRIC = "su_biometric" const val SU_BIOMETRIC = "su_biometric"
const val ZYGISK = "zygisk" const val ZYGISK = "zygisk"
const val SAFEMODE = "safemode" const val BOOTLOOP = "bootloop"
const val DENYLIST = "denylist" const val DENYLIST = "denylist"
const val SU_MANAGER = "requester" const val SU_MANAGER = "requester"
const val KEYSTORE = "keystore" const val KEYSTORE = "keystore"
@ -167,7 +167,7 @@ object Config : PreferenceConfig, DBConfig {
suBiometric = value suBiometric = value
} }
var zygisk by dbSettings(Key.ZYGISK, false) var zygisk by dbSettings(Key.ZYGISK, false)
var safemode by dbSettings(Key.SAFEMODE, 0) var bootloop by dbSettings(Key.BOOTLOOP, 0)
var denyList by BoolDBPropertyNoWrite(Key.DENYLIST, false) var denyList by BoolDBPropertyNoWrite(Key.DENYLIST, false)
var suManager by dbStrings(Key.SU_MANAGER, "", true) var suManager by dbStrings(Key.SU_MANAGER, "", true)
var keyStoreRaw by dbStrings(Key.KEYSTORE, "", true) var keyStoreRaw by dbStrings(Key.KEYSTORE, "", true)

View File

@ -25,7 +25,7 @@ object RebootMenu {
R.id.action_reboot_safe_mode -> { R.id.action_reboot_safe_mode -> {
val status = !item.isChecked val status = !item.isChecked
item.isChecked = status item.isChecked = status
Config.safemode = if (status) 2 else 0 Config.bootloop = if (status) 2 else 0
} }
else -> Unit else -> Unit
} }
@ -42,7 +42,7 @@ object RebootMenu {
menu.menu.findItem(R.id.action_reboot_userspace).isVisible = true menu.menu.findItem(R.id.action_reboot_userspace).isVisible = true
} }
if (Const.APP_IS_CANARY) { if (Const.APP_IS_CANARY) {
menu.menu.findItem(R.id.action_reboot_safe_mode).isChecked = Config.safemode >= 2 menu.menu.findItem(R.id.action_reboot_safe_mode).isChecked = Config.bootloop >= 2
} else { } else {
menu.menu.findItem(R.id.action_reboot_safe_mode).isVisible = false menu.menu.findItem(R.id.action_reboot_safe_mode).isVisible = false
} }

View File

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

View File

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