Add/use watchdog with standard timeout
Almost all uses of the watchdog use the same 500ms timeout, so add a new
method that assumes that.
Test: CtsKeystoreTestCases
Change-Id: Idf7852400a58ba954e4a71e5e2282734a0960072
diff --git a/keystore2/src/watchdog_helper.rs b/keystore2/src/watchdog_helper.rs
index 92a0abc..03c7740 100644
--- a/keystore2/src/watchdog_helper.rs
+++ b/keystore2/src/watchdog_helper.rs
@@ -23,6 +23,11 @@
pub use watchdog_rs::WatchPoint;
use watchdog_rs::Watchdog;
+ /// Default timeout interval, in milliseconds.
+ pub const DEFAULT_TIMEOUT_MS: u64 = 500;
+
+ const DEFAULT_TIMEOUT: Duration = Duration::from_millis(DEFAULT_TIMEOUT_MS);
+
lazy_static! {
/// A Watchdog thread, that can be used to create watch points.
static ref WD: Arc<Watchdog> = Watchdog::new(Duration::from_secs(10));
@@ -33,6 +38,11 @@
Watchdog::watch(&WD, id, Duration::from_millis(millis))
}
+ /// Sets a watch point with `id` and a default timeout of [`DEFAULT_TIMEOUT_MS`] milliseconds.
+ pub fn watch(id: &'static str) -> Option<WatchPoint> {
+ Watchdog::watch(&WD, id, DEFAULT_TIMEOUT)
+ }
+
/// Like `watch_millis` but with a callback that is called every time a report
/// is printed about this watch point.
pub fn watch_millis_with(
@@ -53,6 +63,10 @@
fn watch_millis(_: &'static str, _: u64) -> Option<WatchPoint> {
None
}
+ /// Sets a Noop watch point.
+ fn watch(_: &'static str) -> Option<WatchPoint> {
+ None
+ }
pub fn watch_millis_with(
_: &'static str,