catch and handle fat-finger UX events better

they used to panic, now they just print a warning
This commit is contained in:
bunnie 2022-02-04 18:22:17 +08:00
parent 43a5749ee1
commit b35f2a1d3e
3 changed files with 50 additions and 42 deletions

View file

@ -96,7 +96,7 @@ fn xmain() -> ! {
RendererOp::Gutter.to_u32().unwrap() RendererOp::Gutter.to_u32().unwrap()
); );
gutter.set_manual_dismiss(false); gutter.set_manual_dismiss(false);
let mut progress_action = Slider::new(renderer_cid, RendererOp::NotificationReturn.to_u32().unwrap(), let mut progress_action = Slider::new(renderer_cid, RendererOp::Gutter.to_u32().unwrap(),
0, 100, 1, Some("%"), 0, true, true 0, 100, 1, Some("%"), 0, true, true
); );
let mut last_percentage = 0; let mut last_percentage = 0;
@ -299,7 +299,7 @@ fn xmain() -> ! {
*mutex_op = RendererState::ResponseText(text); *mutex_op = RendererState::ResponseText(text);
} }
} }
RendererState::None => log::info!("Text entry got multiple key hits to close the dialog box"), RendererState::None => log::warn!("Text entry detected a fat finger event, ignoring."),
_ => { _ => {
log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error."); log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
panic!("UX return opcode does not match our current operation in flight. This is a serious internal error."); panic!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
@ -310,7 +310,7 @@ fn xmain() -> ! {
let mut mutex_op = op.lock().unwrap(); let mut mutex_op = op.lock().unwrap();
match *mutex_op { match *mutex_op {
RendererState::RunNotification(_) => *mutex_op = RendererState::None, RendererState::RunNotification(_) => *mutex_op = RendererState::None,
RendererState::None => log::info!("Notification got multiple key hits to close the dialog box"), RendererState::None => log::warn!("Notification detected a fat finger event, ignoring."),
_ => { _ => {
log::error!("UX return opcode does not match our current operation in flight: {:?}", mutex_op); log::error!("UX return opcode does not match our current operation in flight: {:?}", mutex_op);
panic!("UX return opcode does not match our current operation in flight. This is a serious internal error."); panic!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
@ -333,6 +333,8 @@ fn xmain() -> ! {
let item = buffer.to_original::<RadioButtonPayload, _>().unwrap(); let item = buffer.to_original::<RadioButtonPayload, _>().unwrap();
*mutex_op = RendererState::ResponseRadio(item.0); *mutex_op = RendererState::ResponseRadio(item.0);
} }
RendererState::ResponseRadio(_) => log::warn!("Radio buttons detected a fat finger event, ignoring."),
RendererState::None => log::warn!("Radio buttons detected a fat finger event, ignoring."),
_ => { _ => {
log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error."); log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
panic!("UX return opcode does not match our current operation in flight. This is a serious internal error."); panic!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
@ -347,6 +349,8 @@ fn xmain() -> ! {
let item = buffer.to_original::<CheckBoxPayload, _>().unwrap(); let item = buffer.to_original::<CheckBoxPayload, _>().unwrap();
*mutex_op = RendererState::ResponseCheckBox(item); *mutex_op = RendererState::ResponseCheckBox(item);
} }
RendererState::ResponseCheckBox(_) => log::warn!("Check boxes detected a fat finger event, ignoring."),
RendererState::None => log::warn!("Check boxes detected a fat finger event, ignoring."),
_ => { _ => {
log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error."); log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
panic!("UX return opcode does not match our current operation in flight. This is a serious internal error."); panic!("UX return opcode does not match our current operation in flight. This is a serious internal error.");

View file

@ -125,6 +125,7 @@ pub(crate) fn password_ux_manager(
pddb_modal.activate(); pddb_modal.activate();
} }
Some(PwRendererOpcode::PwReturn) => { Some(PwRendererOpcode::PwReturn) => {
if renderer_active.load(Ordering::SeqCst) {
let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) }; let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
let mut pw = buf.to_original::<gam::modal::TextEntryPayload, _>().unwrap(); let mut pw = buf.to_original::<gam::modal::TextEntryPayload, _>().unwrap();
@ -133,6 +134,9 @@ pub(crate) fn password_ux_manager(
pw.volatile_clear(); // ensure the data is destroyed after sending to the keys enclave pw.volatile_clear(); // ensure the data is destroyed after sending to the keys enclave
buf.volatile_clear(); buf.volatile_clear();
} else {
log::warn!("Fat finger event received from Ux, ignoring");
}
// this resumes the waiting Ux Manager thread // this resumes the waiting Ux Manager thread
renderer_active.store(false, Ordering::SeqCst); renderer_active.store(false, Ordering::SeqCst);
@ -142,10 +146,10 @@ pub(crate) fn password_ux_manager(
}, },
Some(PwRendererOpcode::ModalKeypress) => msg_scalar_unpack!(msg, k1, k2, k3, k4, { Some(PwRendererOpcode::ModalKeypress) => msg_scalar_unpack!(msg, k1, k2, k3, k4, {
let keys = [ let keys = [
if let Some(a) = core::char::from_u32(k1 as u32) {a} else {'\u{0000}'}, core::char::from_u32(k1 as u32).unwrap_or('\u{0000}'),
if let Some(a) = core::char::from_u32(k2 as u32) {a} else {'\u{0000}'}, core::char::from_u32(k2 as u32).unwrap_or('\u{0000}'),
if let Some(a) = core::char::from_u32(k3 as u32) {a} else {'\u{0000}'}, core::char::from_u32(k3 as u32).unwrap_or('\u{0000}'),
if let Some(a) = core::char::from_u32(k4 as u32) {a} else {'\u{0000}'}, core::char::from_u32(k4 as u32).unwrap_or('\u{0000}'),
]; ];
pddb_modal.key_event(keys); pddb_modal.key_event(keys);
}), }),

View file

@ -896,6 +896,8 @@ fn xmain() -> ! {
rootkeys_modal.activate(); rootkeys_modal.activate();
}, },
Some(Opcode::UxAesEnsureReturn) => { Some(Opcode::UxAesEnsureReturn) => {
if let Some(sender) = aes_sender.take() {
xous::return_scalar(sender, 1).unwrap();
#[cfg(feature = "policy-menu")] #[cfg(feature = "policy-menu")]
{ // in case we want to bring back the policy check { // in case we want to bring back the policy check
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) }; let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
@ -923,11 +925,9 @@ fn xmain() -> ! {
} }
keys.set_ux_password_type(None); keys.set_ux_password_type(None);
if let Some(sender) = aes_sender.take() {
xous::return_scalar(sender, 1).unwrap();
} else { } else {
log::error!("entered a UxAesEnsureReturn but the flow was not set up correctly!"); xous::return_scalar(msg.sender, 0).unwrap();
panic!("entered a UxAesEnsureReturn but the flow was not set up correctly!") log::warn!("UxAesEnsureReturn detected a fat-finger event. Ignoring.");
} }
} }
Some(Opcode::AesOracle) => { Some(Opcode::AesOracle) => {