mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-05-12 21:30:37 +01:00
fingerprint: allow fprint to suspend and cancel verify for us (#722)
* fingerprint: allow fprint to suspend and cancel verify for us * fingerprint: fix formatting
This commit is contained in:
parent
0b1f2a97ef
commit
dd4c1d5034
2 changed files with 13 additions and 29 deletions
|
@ -65,20 +65,13 @@ void CFingerprint::init() {
|
|||
// When entering sleep, the wake signal will trigger startVerify().
|
||||
if (m_sDBUSState.sleeping)
|
||||
return;
|
||||
inhibitSleep();
|
||||
startVerify();
|
||||
});
|
||||
m_sDBUSState.login->uponSignal("PrepareForSleep").onInterface(LOGIN_MANAGER).call([this](bool start) {
|
||||
Debug::log(LOG, "fprint: PrepareForSleep (start: {})", start);
|
||||
if (start) {
|
||||
m_sDBUSState.sleeping = true;
|
||||
stopVerify();
|
||||
m_sDBUSState.inhibitLock.reset();
|
||||
} else {
|
||||
m_sDBUSState.sleeping = false;
|
||||
inhibitSleep();
|
||||
m_sDBUSState.sleeping = start;
|
||||
if (!m_sDBUSState.sleeping && !m_sDBUSState.verifying)
|
||||
startVerify();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -111,18 +104,6 @@ std::shared_ptr<sdbus::IConnection> CFingerprint::getConnection() {
|
|||
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() {
|
||||
auto proxy = sdbus::createProxy(*m_sDBUSState.connection, FPRINT, sdbus::ObjectPath{"/net/reactivated/Fprint/Manager"});
|
||||
|
||||
|
@ -163,8 +144,11 @@ void CFingerprint::handleVerifyStatus(const std::string& result, bool done) {
|
|||
auto matchResult = s_mapStringToTestType[result];
|
||||
bool authenticated = false;
|
||||
bool retry = false;
|
||||
if (m_sDBUSState.sleeping && matchResult != MATCH_DISCONNECTED)
|
||||
if (m_sDBUSState.sleeping) {
|
||||
stopVerify();
|
||||
Debug::log(LOG, "fprint: device suspended");
|
||||
return;
|
||||
}
|
||||
switch (matchResult) {
|
||||
case MATCH_INVALID: Debug::log(WARN, "fprint: unknown status: {}", result); break;
|
||||
case MATCH_NO_MATCH:
|
||||
|
@ -229,6 +213,7 @@ void CFingerprint::claimDevice() {
|
|||
}
|
||||
|
||||
void CFingerprint::startVerify(bool isRetry) {
|
||||
m_sDBUSState.verifying = true;
|
||||
if (!m_sDBUSState.device) {
|
||||
if (!createDeviceProxy())
|
||||
return;
|
||||
|
@ -256,6 +241,7 @@ void CFingerprint::startVerify(bool isRetry) {
|
|||
}
|
||||
|
||||
bool CFingerprint::stopVerify() {
|
||||
m_sDBUSState.verifying = false;
|
||||
if (!m_sDBUSState.device)
|
||||
return false;
|
||||
try {
|
||||
|
|
|
@ -29,12 +29,12 @@ class CFingerprint : public IAuthImplementation {
|
|||
std::shared_ptr<sdbus::IConnection> connection;
|
||||
std::unique_ptr<sdbus::IProxy> login;
|
||||
std::unique_ptr<sdbus::IProxy> device;
|
||||
sdbus::UnixFd inhibitLock;
|
||||
|
||||
bool abort = false;
|
||||
bool done = false;
|
||||
int retries = 0;
|
||||
bool sleeping = false;
|
||||
bool abort = false;
|
||||
bool done = false;
|
||||
int retries = 0;
|
||||
bool sleeping = false;
|
||||
bool verifying = false;
|
||||
} m_sDBUSState;
|
||||
|
||||
std::string m_sFingerprintReady;
|
||||
|
@ -45,8 +45,6 @@ class CFingerprint : public IAuthImplementation {
|
|||
|
||||
void handleVerifyStatus(const std::string& result, const bool done);
|
||||
|
||||
void inhibitSleep();
|
||||
|
||||
bool createDeviceProxy();
|
||||
void claimDevice();
|
||||
void startVerify(bool isRetry = false);
|
||||
|
|
Loading…
Reference in a new issue