summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kiryanov <rkir@google.com>2024-03-19 13:27:17 -0700
committerRoman Kiryanov <rkir@google.com>2024-03-19 15:17:14 -0700
commit536235f21f9a5de0cab7feabb9b8a4fe5b187a92 (patch)
tree21194d2c20cd0417962a4ce40dca43c3a2ee8339
parent0b14de6a5913440f2dd08f23a6f8e3944163412e (diff)
downloadgoldfish-536235f21f9a5de0cab7feabb9b8a4fe5b187a92.tar.gz
Use libdebug in the fingerprint HAL
for more consistent errror logging Bug: 330377365 Test: presubmit Change-Id: I87cc64fb62ead80aa5fdc3b506b1c81fcac79b4c Signed-off-by: Roman Kiryanov <rkir@google.com>
-rw-r--r--fingerprint/Android.bp1
-rw-r--r--fingerprint/main.cpp6
-rw-r--r--fingerprint/session.cpp6
-rw-r--r--fingerprint/storage.cpp21
4 files changed, 16 insertions, 18 deletions
diff --git a/fingerprint/Android.bp b/fingerprint/Android.bp
index eace3916..d57b40e5 100644
--- a/fingerprint/Android.bp
+++ b/fingerprint/Android.bp
@@ -46,6 +46,7 @@ cc_binary {
],
header_libs: [
"libutils_headers",
+ "libdebug.ranchu",
],
cflags: [
"-DLOG_TAG=\"fingerprint-service.ranchu\"",
diff --git a/fingerprint/main.cpp b/fingerprint/main.cpp
index edc90d34..9ff81ea2 100644
--- a/fingerprint/main.cpp
+++ b/fingerprint/main.cpp
@@ -17,7 +17,7 @@
#include <memory>
#include <android/binder_manager.h>
#include <android/binder_process.h>
-#include <log/log.h>
+#include <debug.h>
#include <utils/Errors.h>
#include "hal.h"
@@ -33,8 +33,8 @@ int main() {
const std::string instance = std::string(Hal::descriptor) + "/default";
if (AServiceManager_registerLazyService(hal->asBinder().get(),
instance.c_str()) != STATUS_OK) {
- ALOGE("%s:%d: Could not register '%s'", __func__, __LINE__, instance.c_str());
- return android::NO_INIT;
+ return FAILURE_V(android::NO_INIT,
+ "Could not register '%s'", instance.c_str());
}
}
diff --git a/fingerprint/session.cpp b/fingerprint/session.cpp
index 3539ed2c..0793ae83 100644
--- a/fingerprint/session.cpp
+++ b/fingerprint/session.cpp
@@ -22,6 +22,7 @@
#include <limits>
#include <aidl/android/hardware/biometrics/common/BnCancellationSignal.h>
#include <android-base/unique_fd.h>
+#include <debug.h>
#include <log/log.h>
#include <qemud.h>
#include <utils/Timers.h>
@@ -332,11 +333,12 @@ ndk::ScopedAStatus Session::close() {
Session::ErrorCode Session::validateHat(const keymaster::HardwareAuthToken& hat) const {
if (hat.mac.empty()) {
- return ErrorCode::E_HAT_MAC_EMPTY;
+ return FAILURE(ErrorCode::E_HAT_MAC_EMPTY);
}
if (!mChallenges.count(hat.challenge)) {
- return ErrorCode::E_HAT_WRONG_CHALLENGE;
+ return FAILURE_V(ErrorCode::E_HAT_WRONG_CHALLENGE,
+ "unexpected challenge: %" PRId64, hat.challenge);
}
return ErrorCode::OK;
diff --git a/fingerprint/storage.cpp b/fingerprint/storage.cpp
index c256294b..ff2b2b34 100644
--- a/fingerprint/storage.cpp
+++ b/fingerprint/storage.cpp
@@ -19,7 +19,7 @@
#include <unistd.h>
#include <cstdio>
#include <android-base/unique_fd.h>
-#include <log/log.h>
+#include <debug.h>
#include "storage.h"
namespace aidl::android::hardware::biometrics::fingerprint {
@@ -44,9 +44,8 @@ unique_fd openFile(const int32_t sensorId, const int32_t userId, const bool outp
if (fd >= 0) {
return unique_fd(fd);
} else {
- ALOGE("%s:%d open('%s', output=%d) failed with errno=%d",
- __func__, __LINE__, filename, output, errno);
- return {};
+ return FAILURE_V(unique_fd(), "open('%s', output=%d) failed with errno=%d",
+ filename, output, errno);
}
}
@@ -61,9 +60,8 @@ std::vector<uint8_t> loadFile(const int fd) {
if (n > 0) {
size += n;
} else if (n < 0) {
- ALOGE("%s:%d error reading from a file, errno=%d",
- __func__, __LINE__, errno);
- return {};
+ decltype(result) empty;
+ return FAILURE_V(empty, "error reading from a file, errno=%d", errno);
} else {
result.resize(size);
return result;
@@ -78,13 +76,10 @@ bool saveFile(const int fd, const uint8_t* i, size_t size) {
i += n;
size -= n;
} else if (n < 0) {
- ALOGE("%s:%d error writing to a file, errno=%d",
- __func__, __LINE__, errno);
- return false;
+ return FAILURE_V(false, "error writing to a file, errno=%d", errno);
} else {
- ALOGE("%s:%d `write` returned zero, size=%zu, errno=%d",
- __func__, __LINE__, size, errno);
- return false;
+ return FAILURE_V(false, "`write` returned zero, size=%zu, errno=%d",
+ size, errno);
}
}
return true;