Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb43703_immediate_lock_lpm' into 'master'
Do not apply lock-immediately in lpm state

See merge request mer-core/nemo-qml-plugin-devicelock!36
  • Loading branch information
spiiroin committed Nov 5, 2018
2 parents 9107d36 + 8a98337 commit 3451c2f
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 3451c2f

Please sign in to comment.