Commit 1fa86b11 authored by Tomi Leppänen's avatar Tomi Leppänen

[devicelock] Fix asynchronous unlocking. Contributes to JB#45370

Move Failure handling from enterSecurityCode to unlockFinished.
Signed-off-by: Tomi Leppänen's avatarTomi Leppänen <tomi.leppanen@jolla.com>
parent b65e6989
......@@ -146,7 +146,7 @@ public:
virtual void confirmAuthentication(Authenticator::Method method) = 0;
virtual void abortAuthentication(AuthenticationInput::Error error);
\
// Signals
void feedback(
AuthenticationInput::Feedback feedback,
......
......@@ -149,10 +149,6 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
break;
case Authenticating: {
switch (const int result = unlockWithCode(code)) {
case Evaluating:
case Success:
unlockFinished(result, Authenticator::SecurityCode);
break;
case SecurityCodeExpired:
m_state = EnteringNewSecurityCode;
m_currentCode = code;
......@@ -164,21 +160,10 @@ void HostDeviceLock::enterSecurityCode(const QString &code)
case LockedOut:
lockedOut();
break;
default: {
const int maximum = maximumAttempts();
if (maximum > 0) {
feedback(AuthenticationInput::IncorrectSecurityCode, qMax(0, maximum - result));
if (result >= maximum) {
lockedOut();
}
} else {
feedback(AuthenticationInput::IncorrectSecurityCode, -1);
}
default:
unlockFinished(result, Authenticator::SecurityCode);
break;
}
}
break;
}
case EnteringNewSecurityCode:
......@@ -255,7 +240,9 @@ void HostDeviceLock::unlockFinished(int result, Authenticator::Method method)
abortAuthentication(AuthenticationInput::SoftwareError);
}
break;
default:
case SecurityCodeExpired:
case SecurityCodeInHistory:
case LockedOut:
if (m_state == Canceled) {
m_state = Idle;
......@@ -266,6 +253,28 @@ void HostDeviceLock::unlockFinished(int result, Authenticator::Method method)
abortAuthentication(AuthenticationInput::SoftwareError);
}
break;
default: {
int attemptsRemaining = -1;
const int maximum = maximumAttempts();
if (maximum > 0) {
if (result >= maximum) {
feedback(AuthenticationInput::IncorrectSecurityCode, 0);
lockedOut();
break;
} else {
attemptsRemaining = maximum - result;
}
}
if (m_state == Unlocking) {
m_state = Authenticating;
authenticationResumed(AuthenticationInput::IncorrectSecurityCode, {{ QStringLiteral("attemptsRemaining"), attemptsRemaining }});
} else {
feedback(AuthenticationInput::IncorrectSecurityCode, attemptsRemaining);
}
break;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment