refactor: очистка AppPreferences от legacy-кода миграции
This commit is contained in:
1 parent
2ecd48eef0
commit
1b54e9cfc9
1 file changed
+4
-14
@@ -1,4 +1,4 @@
|
|||||||
@file:Suppress("DEPRECATION")
|
|
||||||
|
|
||||||
package com.freeturn.app.data
|
package com.freeturn.app.data
|
||||||
|
|
||||||
@@ -122,10 +122,6 @@ class AppPreferences(context: Context) {
|
|||||||
val TG_SUBSCRIBE_SHOWN = booleanPreferencesKey("tg_subscribe_shown")
|
val TG_SUBSCRIBE_SHOWN = booleanPreferencesKey("tg_subscribe_shown")
|
||||||
val PROFILES_JSON = stringPreferencesKey("profiles_json")
|
val PROFILES_JSON = stringPreferencesKey("profiles_json")
|
||||||
val ACTIVE_PROFILE_ID = stringPreferencesKey("active_profile_id")
|
val ACTIVE_PROFILE_ID = stringPreferencesKey("active_profile_id")
|
||||||
|
|
||||||
// Устаревшие ключи — используются только для миграции
|
|
||||||
private val SSH_PASS_LEGACY = stringPreferencesKey("ssh_pass")
|
|
||||||
private val SSH_KEY_LEGACY = stringPreferencesKey("ssh_key")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Шифрованное хранилище для SSH-пароля и ключа (Android Keystore + AES-256)
|
// Шифрованное хранилище для SSH-пароля и ключа (Android Keystore + AES-256)
|
||||||
@@ -151,12 +147,10 @@ class AppPreferences(context: Context) {
|
|||||||
ip = prefs[SSH_IP] ?: "",
|
ip = prefs[SSH_IP] ?: "",
|
||||||
port = prefs[SSH_PORT] ?: 22,
|
port = prefs[SSH_PORT] ?: 22,
|
||||||
username = prefs[SSH_USER] ?: "root",
|
username = prefs[SSH_USER] ?: "root",
|
||||||
// Читаем из зашифрованного хранилища; если пусто — берём из DataStore (миграция)
|
// Читаем из зашифрованного хранилища
|
||||||
password = encryptedPrefs.getString("ssh_pass", null)
|
password = encryptedPrefs.getString("ssh_pass", null) ?: "",
|
||||||
?: prefs[SSH_PASS_LEGACY] ?: "",
|
|
||||||
authType = prefs[SSH_AUTH_TYPE] ?: "PASSWORD",
|
authType = prefs[SSH_AUTH_TYPE] ?: "PASSWORD",
|
||||||
sshKey = encryptedPrefs.getString("ssh_key", null)
|
sshKey = encryptedPrefs.getString("ssh_key", null) ?: "",
|
||||||
?: prefs[SSH_KEY_LEGACY] ?: "",
|
|
||||||
hostFingerprint = prefs[SSH_HOST_FP] ?: ""
|
hostFingerprint = prefs[SSH_HOST_FP] ?: ""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -280,8 +274,6 @@ class AppPreferences(context: Context) {
|
|||||||
prefs[SSH_USER] = config.username
|
prefs[SSH_USER] = config.username
|
||||||
prefs[SSH_AUTH_TYPE] = config.authType
|
prefs[SSH_AUTH_TYPE] = config.authType
|
||||||
prefs[SSH_HOST_FP] = config.hostFingerprint
|
prefs[SSH_HOST_FP] = config.hostFingerprint
|
||||||
prefs.remove(SSH_PASS_LEGACY)
|
|
||||||
prefs.remove(SSH_KEY_LEGACY)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,8 +341,6 @@ class AppPreferences(context: Context) {
|
|||||||
context.dataStore.edit { it.clear() }
|
context.dataStore.edit { it.clear() }
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
encryptedPrefs.edit { clear() }
|
encryptedPrefs.edit { clear() }
|
||||||
// Чистим следы старого кастомного ядра, если оставались.
|
|
||||||
File(context.filesDir, "custom_vkturn").delete()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user