mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-05-13 05:40:42 +01:00
fingerprint: allow fprint to suspend and cancel verify for us
This commit is contained in:
parent
d9a1625315
commit
b92b14592b
2 changed files with 13 additions and 28 deletions
|
@ -65,18 +65,12 @@ void CFingerprint::init() {
|
||||||
// When entering sleep, the wake signal will trigger startVerify().
|
// When entering sleep, the wake signal will trigger startVerify().
|
||||||
if (m_sDBUSState.sleeping)
|
if (m_sDBUSState.sleeping)
|
||||||
return;
|
return;
|
||||||
inhibitSleep();
|
|
||||||
startVerify();
|
startVerify();
|
||||||
});
|
});
|
||||||
m_sDBUSState.login->uponSignal("PrepareForSleep").onInterface(LOGIN_MANAGER).call([this](bool start) {
|
m_sDBUSState.login->uponSignal("PrepareForSleep").onInterface(LOGIN_MANAGER).call([this](bool start) {
|
||||||
Debug::log(LOG, "fprint: PrepareForSleep (start: {})", start);
|
Debug::log(LOG, "fprint: PrepareForSleep (start: {})", start);
|
||||||
if (start) {
|
m_sDBUSState.sleeping = start;
|
||||||
m_sDBUSState.sleeping = true;
|
if (!m_sDBUSState.sleeping && !m_sDBUSState.verifying) {
|
||||||
stopVerify();
|
|
||||||
m_sDBUSState.inhibitLock.reset();
|
|
||||||
} else {
|
|
||||||
m_sDBUSState.sleeping = false;
|
|
||||||
inhibitSleep();
|
|
||||||
startVerify();
|
startVerify();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -111,18 +105,6 @@ std::shared_ptr<sdbus::IConnection> CFingerprint::getConnection() {
|
||||||
return m_sDBUSState.connection;
|
return m_sDBUSState.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFingerprint::inhibitSleep() {
|
|
||||||
m_sDBUSState.login->callMethodAsync("Inhibit")
|
|
||||||
.onInterface(LOGIN_MANAGER)
|
|
||||||
.withArguments("sleep", "hyprlock", "Fingerprint verifcation must be stopped before sleep", "delay")
|
|
||||||
.uponReplyInvoke([this](std::optional<sdbus::Error> e, sdbus::UnixFd fd) {
|
|
||||||
if (e)
|
|
||||||
Debug::log(WARN, "fprint: could not inhibit sleep: {}", e->what());
|
|
||||||
else
|
|
||||||
m_sDBUSState.inhibitLock = fd;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CFingerprint::createDeviceProxy() {
|
bool CFingerprint::createDeviceProxy() {
|
||||||
auto proxy = sdbus::createProxy(*m_sDBUSState.connection, FPRINT, sdbus::ObjectPath{"/net/reactivated/Fprint/Manager"});
|
auto proxy = sdbus::createProxy(*m_sDBUSState.connection, FPRINT, sdbus::ObjectPath{"/net/reactivated/Fprint/Manager"});
|
||||||
|
|
||||||
|
@ -163,8 +145,11 @@ void CFingerprint::handleVerifyStatus(const std::string& result, bool done) {
|
||||||
auto matchResult = s_mapStringToTestType[result];
|
auto matchResult = s_mapStringToTestType[result];
|
||||||
bool authenticated = false;
|
bool authenticated = false;
|
||||||
bool retry = false;
|
bool retry = false;
|
||||||
if (m_sDBUSState.sleeping && matchResult != MATCH_DISCONNECTED)
|
if (m_sDBUSState.sleeping) {
|
||||||
|
stopVerify();
|
||||||
|
Debug::log(LOG, "fprint: device suspended");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
switch (matchResult) {
|
switch (matchResult) {
|
||||||
case MATCH_INVALID: Debug::log(WARN, "fprint: unknown status: {}", result); break;
|
case MATCH_INVALID: Debug::log(WARN, "fprint: unknown status: {}", result); break;
|
||||||
case MATCH_NO_MATCH:
|
case MATCH_NO_MATCH:
|
||||||
|
@ -229,6 +214,7 @@ void CFingerprint::claimDevice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFingerprint::startVerify(bool isRetry) {
|
void CFingerprint::startVerify(bool isRetry) {
|
||||||
|
m_sDBUSState.verifying = true;
|
||||||
if (!m_sDBUSState.device) {
|
if (!m_sDBUSState.device) {
|
||||||
if (!createDeviceProxy())
|
if (!createDeviceProxy())
|
||||||
return;
|
return;
|
||||||
|
@ -256,6 +242,7 @@ void CFingerprint::startVerify(bool isRetry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CFingerprint::stopVerify() {
|
bool CFingerprint::stopVerify() {
|
||||||
|
m_sDBUSState.verifying = false;
|
||||||
if (!m_sDBUSState.device)
|
if (!m_sDBUSState.device)
|
||||||
return false;
|
return false;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -29,12 +29,12 @@ class CFingerprint : public IAuthImplementation {
|
||||||
std::shared_ptr<sdbus::IConnection> connection;
|
std::shared_ptr<sdbus::IConnection> connection;
|
||||||
std::unique_ptr<sdbus::IProxy> login;
|
std::unique_ptr<sdbus::IProxy> login;
|
||||||
std::unique_ptr<sdbus::IProxy> device;
|
std::unique_ptr<sdbus::IProxy> device;
|
||||||
sdbus::UnixFd inhibitLock;
|
|
||||||
|
|
||||||
bool abort = false;
|
bool abort = false;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int retries = 0;
|
int retries = 0;
|
||||||
bool sleeping = false;
|
bool sleeping = false;
|
||||||
|
bool verifying = false;
|
||||||
} m_sDBUSState;
|
} m_sDBUSState;
|
||||||
|
|
||||||
std::string m_sFingerprintReady;
|
std::string m_sFingerprintReady;
|
||||||
|
@ -45,8 +45,6 @@ class CFingerprint : public IAuthImplementation {
|
||||||
|
|
||||||
void handleVerifyStatus(const std::string& result, const bool done);
|
void handleVerifyStatus(const std::string& result, const bool done);
|
||||||
|
|
||||||
void inhibitSleep();
|
|
||||||
|
|
||||||
bool createDeviceProxy();
|
bool createDeviceProxy();
|
||||||
void claimDevice();
|
void claimDevice();
|
||||||
void startVerify(bool isRetry = false);
|
void startVerify(bool isRetry = false);
|
||||||
|
|
Loading…
Reference in a new issue