diff --git a/app/lib/modules/login/service/login_service.dart b/app/lib/modules/login/service/login_service.dart index 7f9c6d79d..fc34bcb1c 100644 --- a/app/lib/modules/login/service/login_service.dart +++ b/app/lib/modules/login/service/login_service.dart @@ -15,11 +15,29 @@ final class LoginService { static const isDeviceSupportKey = 'is-device-support-key'; static const biometricAuthStateKey = 'biometric-auth-state'; + static const oldBiometricAuthStateKey = 'biometric-auth-enabled'; static const pinStorageKey = 'pin-key'; BiometricAuthState? get getBiometricAuthState { final biometricAuthState = preferences.getString(biometricAuthStateKey); - return biometricAuthState != null ? BiometricAuthState.fromString(biometricAuthState) : null; + if (biometricAuthState != null) return BiometricAuthState.fromString(biometricAuthState); + + // See if we had set a state in earlier app versions + final biometricAuthenticationEnabledOld = preferences.getBool(oldBiometricAuthStateKey); + if (biometricAuthenticationEnabledOld == null) return null; + + // migrate old storage to new one and return state + final biometricAuthStateOld = switch (biometricAuthenticationEnabledOld) { + true => BiometricAuthState.enabled, + false => BiometricAuthState.disabled, + }; + + // migrate the old storage to the new one + setBiometricAuthState(biometricAuthStateOld); + // clear the old storage + preferences.remove(oldBiometricAuthStateKey); + + return biometricAuthStateOld; } Future setBiometricAuthState(BiometricAuthState biometricAuthState) async { diff --git a/app/lib/modules/settings/service/app_service.dart b/app/lib/modules/settings/service/app_service.dart index d034a8662..c5bd19031 100644 --- a/app/lib/modules/settings/service/app_service.dart +++ b/app/lib/modules/settings/service/app_service.dart @@ -9,7 +9,6 @@ class AppService { final SharedPreferences storage; static const localStorageLocaleKey = 'locale'; - static const biometricAuthStateKey = 'biometric-auth-state'; Locale get getLocale { final code = storage.getString(localStorageLocaleKey); @@ -24,6 +23,4 @@ class AppService { await storage.setString(localStorageLocaleKey, languageCode); return Locale(languageCode); } - - String? get getBiometricAuthState => storage.getString(biometricAuthStateKey); } diff --git a/app/test_driver/helpers/command/app_functions.dart b/app/test_driver/helpers/command/app_functions.dart index ff0d408cc..1ca591c01 100644 --- a/app/test_driver/helpers/command/app_functions.dart +++ b/app/test_driver/helpers/command/app_functions.dart @@ -13,5 +13,5 @@ String toggleDeveloperMode(AppSettings appSettings, bool devMode) { } String getBiometricAuthState(AppService appService) { - return appService.getBiometricAuthState ?? ''; + return Platform.isAndroid ? 'Device not supported' : ''; }