Skip to content

Commit

Permalink
[sailfish-utilities] Add a Restart Fingerprint button. Fixes JB#57941
Browse files Browse the repository at this point in the history
Adds a button for restarting the fingerprint service. In practice, it
restarts, waits 3 seconds and then restarts again.

In some situations where the fingerprint cache gets messed up, which
prevents fingerprints from being recognised, this sequence resolves the
issue.
  • Loading branch information
llewelld committed Apr 22, 2022
1 parent 02bff40 commit da8ea3a
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 2 deletions.
5 changes: 5 additions & 0 deletions plugin/utiltools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ void UtilTools::restartLipstick(QJSValue successCallback, QJSValue errorCallback
execute(SystemTool, QStringList("restart_lipstick"), successCallback, errorCallback);
}

void UtilTools::restartFingerprint(QJSValue successCallback, QJSValue errorCallback)
{
execute(SystemTool, QStringList("restart_fingerprint"), successCallback, errorCallback);
}

void UtilTools::handleProcessExit(int exitCode, QProcess::ExitStatus status)
{
QProcess *process = qobject_cast<QProcess*>(sender());
Expand Down
3 changes: 3 additions & 0 deletions plugin/utiltools.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class UtilTools: public QObject
Q_INVOKABLE void restartLipstick(QJSValue successCallback = QJSValue::UndefinedValue,
QJSValue errorCallback = QJSValue::UndefinedValue);

Q_INVOKABLE void restartFingerprint(QJSValue successCallback = QJSValue::UndefinedValue,
QJSValue errorCallback = QJSValue::UndefinedValue);

private slots:
void handleProcessExit(int exitCode, QProcess::ExitStatus status);

Expand Down
3 changes: 2 additions & 1 deletion qml/ActionList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Column {
plugins.append(info)
}
var names = [ "RestartNetwork", "RestartUI",
"CleanPackageCache", "CleanTracker" ]
"CleanPackageCache", "CleanTracker",
"RestartFingerprint"]
for (var i = 0; i < names.length; ++i)
justLoad(names[i])
}
Expand Down
19 changes: 19 additions & 0 deletions qml/plugins/RestartFingerprint.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Utilities 1.0

ActionItem {
//% "Fingerprint"
title: qsTrId("sailfish-tools-he-fingerprint")
//% "Restart"
actionName: qsTrId("sailfish-tools-bt-fingerprint_restart")
deviceLockRequired: false
//% "Restart fingerprint service. In some circumstancces this can "
//% "resolve issues where valid fingerprints are no longer being "
//% "recognised."
description: qsTrId("sailfish-utilities-restart-fingerprint_desc")

function action(on_reply, on_error) {
UtilTools.restartFingerprint(on_reply, on_error)
}
}
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ install(PROGRAMS
restart_network.sh
restart_lipstick.sh
tracker_reindex.sh
restart_fingerprint.sh
DESTINATION share/sailfish-utilities
)
18 changes: 18 additions & 0 deletions tools/restart_fingerprint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

warning() {
printf "%s: Warning: %s\n" "$(basename $0)" "${@}" 1>&2;
}

service_do() {
if systemctl "$1" "$2"; then
return 0;
else
warning "Status $? on" "${@}"
return 1;
fi
}

service_do restart sailfish-fpd
sleep 3
service_do restart sailfish-fpd
5 changes: 4 additions & 1 deletion tools/sailfish_tools_system_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ std::map<std::string, action_type> actions = {
}},
{ "tracker_reindex", [](action_ctx const *) {
return execute_own_utility("tracker_reindex.sh");
}},
{ "restart_fingerprint", [](action_ctx const *) {
return execute_own_utility("restart_fingerprint.sh");
}}
};

std::set<std::string> root_actions = {
"repair_rpm_db", "restart_network"
"repair_rpm_db", "restart_network", "restart_fingerprint"
};

class BecomeRoot
Expand Down

0 comments on commit da8ea3a

Please sign in to comment.