do not reset activity state in OnNewIntent if the activity hasn't even been initialized. closes #2869, closes #2888

This commit is contained in:
Philipp Crocoll
2025-06-17 14:04:15 +02:00
parent e1f26fb045
commit e2babde1fa

View File

@@ -131,6 +131,7 @@ namespace keepass2android
ISharedPreferences _prefs; ISharedPreferences _prefs;
private bool _starting; private bool _starting;
private bool _resumeCompleted;
private OtpInfo _otpInfo; private OtpInfo _otpInfo;
private IOConnectionInfo _otpAuxIoc; private IOConnectionInfo _otpAuxIoc;
private ChallengeInfo _chalInfo; private ChallengeInfo _chalInfo;
@@ -1569,6 +1570,8 @@ namespace keepass2android
} }
private bool hasRequestedKeyboardActivation = false; private bool hasRequestedKeyboardActivation = false;
protected override void OnStart() protected override void OnStart()
{ {
base.OnStart(); base.OnStart();
@@ -1688,15 +1691,20 @@ namespace keepass2android
//assume the key should be used as static password //assume the key should be used as static password
FindViewById<EditText>(Resource.Id.password_edit).Text += otp; FindViewById<EditText>(Resource.Id.password_edit).Text += otp;
} }
} }
else else
{ {
// if the activity is launched twice and the first initialization hasn't even finished, we cannot
// reset the state and re-initialize the activity.
// This can happen with autofill in some cases (#2869)
if (_resumeCompleted)
{
ResetState(); ResetState();
GetIocFromLaunchIntent(intent); GetIocFromLaunchIntent(intent);
InitializeAfterSetIoc(); InitializeAfterSetIoc();
OnStart(); OnStart();
}
} }
} }
@@ -1878,6 +1886,8 @@ namespace keepass2android
keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly); keyboard.HideSoftInputFromWindow(pwd.WindowToken, HideSoftInputFlags.ImplicitOnly);
}, 50); }, 50);
} }
_resumeCompleted = true;
} }
private void TryGetOtpFromClipboard() private void TryGetOtpFromClipboard()