summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Cutts <hcutts@google.com>2023-02-21 16:36:12 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-02-23 16:00:27 +0000
commit747ba9ac9cd7aeb2f478e94654fa8c629edcdb68 (patch)
tree2d05febcaaa7c465a7920aed24fb9196300278ed
parent72b9a85bcd1d30071106a23701c7a67f6d50a1e5 (diff)
downloadlibchrome-gestures-747ba9ac9cd7aeb2f478e94654fa8c629edcdb68.tar.gz
Only complain about missing timer provider once
On Android we currently don't use a timer provider. The library is still working well, but reports a "No timer!" error for every hardware state that's pushed, which rather spams the Android logcat. It only really needs to be reported the first time. BUG=b:251196347 TEST=Watch logcat "Gestures" tag on Android while using the touchpad for the first time, check the new error message appears only once Change-Id: I94556a9d5ef5c0e14284a807b9337ac8e8aeb686 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/gestures/+/4275522 Code-Coverage: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Harry Cutts <hcutts@chromium.org> Reviewed-by: Sean O'Brien <seobrien@chromium.org> Tested-by: Harry Cutts <hcutts@chromium.org>
-rw-r--r--include/logging.h9
-rw-r--r--src/gestures.cc2
2 files changed, 10 insertions, 1 deletions
diff --git a/include/logging.h b/include/logging.h
index 4ae7bf6..ca64b27 100644
--- a/include/logging.h
+++ b/include/logging.h
@@ -36,6 +36,15 @@
gestures_log(GESTURES_LOG_ERROR, "ERROR:%s:%d:" format "\n", \
__FILE__, __LINE__, ## __VA_ARGS__)
+#define ErrOnce(format, ...) \
+ do { \
+ static bool written = false; \
+ if (!written) { \
+ Err(format, ## __VA_ARGS__); \
+ written = true; \
+ } \
+ } while(false)
+
#define MTStatSample(key, value, timestamp) \
gestures_log(GESTURES_LOG_INFO, "MTStat:%f:%s:%s\n", \
(timestamp), (key), (value))
diff --git a/src/gestures.cc b/src/gestures.cc
index 13aac23..475b4f5 100644
--- a/src/gestures.cc
+++ b/src/gestures.cc
@@ -470,7 +470,7 @@ void GestureInterpreter::PushHardwareState(HardwareState* hwstate) {
Log("Setting timer for %f s out.", timeout);
}
} else {
- Err("No timer!");
+ ErrOnce("No timer provider has been set, so some features won't work.");
}
}