Skip to content

Commit

Permalink
[devicelock] Do not apply lock-immediately in lpm state. Fixes JB#43703
Browse files Browse the repository at this point in the history
From regular applications point of view lpm display state is equivalent
with display off state. However in device locking context this creates
logical problem in the form of: Unlocking in lpm is allowed. If device
is unlocked while in lpm, it must be locked immediately. The resulting
short living locked-unlocked-locked transitions cause misbehavior at
device unlock view.

Do not apply immediate locking while in lpm.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Nov 2, 2018
1 parent 9107d36 commit 8a98337
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/nemo-devicelock/host/mcedevicelock.cpp
Expand Up @@ -68,6 +68,7 @@ MceDeviceLock::MceDeviceLock(Authenticator::Methods allowedMethods, QObject *par
, m_displayOn(true)
, m_tklockActive(true)
, m_userActivity(true)
, m_lpmMode(false)
{
connect(&m_hbTimer, &BackgroundActivity::running, this, &MceDeviceLock::lock);

Expand Down Expand Up @@ -102,6 +103,15 @@ MceDeviceLock::MceDeviceLock(Authenticator::Methods allowedMethods, QObject *par
handleInactivityStateChanged(state);
});

/* Note: LPM mode can't be queried at the time of writing */
systemBus().connectToSignal(
QString(),
QStringLiteral(MCE_SIGNAL_PATH),
QStringLiteral(MCE_SIGNAL_IF),
QStringLiteral(MCE_LPM_UI_MODE_SIG),
this,
SLOT(handleLpmModeChanged(const QString &)));

systemBus().registerObject(QStringLiteral("/devicelock"), this);
}

Expand Down Expand Up @@ -129,7 +139,6 @@ void MceDeviceLock::trackMceProperty(
});
}


/** Handle tklock state signal/reply from mce
*/
void MceDeviceLock::handleTklockStateChanged(const QString &state)
Expand Down Expand Up @@ -186,6 +195,20 @@ void MceDeviceLock::handleInactivityStateChanged(const bool state)
}
}

/** Handle LPM UI Mode signal from mce
*/
void MceDeviceLock::handleLpmModeChanged(const QString &state)
{
bool lpmMode = (state == MCE_LPM_UI_ENABLED);

if (m_lpmMode != lpmMode) {
qCDebug(daemon, "MCE LPM mode is now %s", lpmMode ? "true" : "false");

m_lpmMode = lpmMode;
setStateAndSetupLockTimer();
}
}

/** Helper for producing human readable devicelock state logging
*/
static const char *reprLockState(bool locked)
Expand All @@ -211,7 +234,7 @@ bool MceDeviceLock::getRequiredLockState()
if (automaticLocking() < 0) {
/* Device locking is disabled */
locked = false;
} else if (automaticLocking() == 0 && !m_displayOn && !m_callActive) {
} else if (automaticLocking() == 0 && !m_displayOn && !m_lpmMode && !m_callActive) {
/* Display is off in immediate lock mode */
locked = true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/nemo-devicelock/host/mcedevicelock.h
Expand Up @@ -100,6 +100,7 @@ protected slots:
void handleCallStateChanged(const QString &state);
void handleDisplayStateChanged(const QString &state);
void handleInactivityStateChanged(const bool state);
void handleLpmModeChanged(const QString &state);

private:
void trackMceProperty(
Expand All @@ -122,6 +123,7 @@ protected slots:
bool m_displayOn;
bool m_tklockActive;
bool m_userActivity;
bool m_lpmMode;

friend class MceDeviceLockAdaptor;

Expand Down

0 comments on commit 8a98337

Please sign in to comment.