Public method to check if sleeping is allowed (#674)

This commit is contained in:
kaczmarczyck
2024-01-09 21:04:47 +01:00
committed by GitHub
parent ba0d717d88
commit 298db9ea99
3 changed files with 22 additions and 0 deletions

View File

@@ -116,6 +116,10 @@ impl<E: Env> Ctap<E> {
self.hid.should_wink(&mut self.env)
}
pub fn can_sleep(&mut self) -> bool {
!self.should_wink() && self.state.can_sleep(&mut self.env)
}
#[cfg(feature = "with_ctap1")]
pub fn u2f_grant_user_presence(&mut self) {
self.state.u2f_grant_user_presence(&mut self.env)
@@ -201,6 +205,7 @@ mod test {
fn test_hard_reset() {
let env = TestEnv::default();
let mut ctap = Ctap::<TestEnv>::new(env);
assert!(!ctap.can_sleep());
// Send Init, receive Init response.
let mut init_response = ctap.process_hid_packet(&init_packet(), Transport::MainHid);
@@ -223,6 +228,7 @@ mod test {
let mut env = TestEnv::default();
env.set_boots_after_soft_reset(true);
let mut ctap = Ctap::<TestEnv>::new(env);
assert!(ctap.can_sleep());
// Send Init, receive Init response.
let mut init_response = ctap.process_hid_packet(&init_packet(), Transport::MainHid);