mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
catch and handle fat-finger UX events better
they used to panic, now they just print a warning
This commit is contained in:
parent
43a5749ee1
commit
b35f2a1d3e
3 changed files with 50 additions and 42 deletions
|
|
@ -96,7 +96,7 @@ fn xmain() -> ! {
|
|||
RendererOp::Gutter.to_u32().unwrap()
|
||||
);
|
||||
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
|
||||
);
|
||||
let mut last_percentage = 0;
|
||||
|
|
@ -299,7 +299,7 @@ fn xmain() -> ! {
|
|||
*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.");
|
||||
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();
|
||||
match *mutex_op {
|
||||
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);
|
||||
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();
|
||||
*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.");
|
||||
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();
|
||||
*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.");
|
||||
panic!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
|
||||
|
|
|
|||
|
|
@ -125,14 +125,18 @@ pub(crate) fn password_ux_manager(
|
|||
pddb_modal.activate();
|
||||
}
|
||||
Some(PwRendererOpcode::PwReturn) => {
|
||||
let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let mut pw = buf.to_original::<gam::modal::TextEntryPayload, _>().unwrap();
|
||||
if renderer_active.load(Ordering::SeqCst) {
|
||||
let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let mut pw = buf.to_original::<gam::modal::TextEntryPayload, _>().unwrap();
|
||||
|
||||
plaintext_pw.lock().unwrap().clear();
|
||||
write!(plaintext_pw.lock().unwrap(), "{}", pw.as_str()).expect("couldn't transfer password to local buffer");
|
||||
plaintext_pw.lock().unwrap().clear();
|
||||
write!(plaintext_pw.lock().unwrap(), "{}", pw.as_str()).expect("couldn't transfer password to local buffer");
|
||||
|
||||
pw.volatile_clear(); // ensure the data is destroyed after sending to the keys enclave
|
||||
buf.volatile_clear();
|
||||
pw.volatile_clear(); // ensure the data is destroyed after sending to the keys enclave
|
||||
buf.volatile_clear();
|
||||
} else {
|
||||
log::warn!("Fat finger event received from Ux, ignoring");
|
||||
}
|
||||
|
||||
// this resumes the waiting Ux Manager thread
|
||||
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, {
|
||||
let keys = [
|
||||
if let Some(a) = core::char::from_u32(k1 as u32) {a} else {'\u{0000}'},
|
||||
if let Some(a) = core::char::from_u32(k2 as u32) {a} else {'\u{0000}'},
|
||||
if let Some(a) = core::char::from_u32(k3 as u32) {a} else {'\u{0000}'},
|
||||
if let Some(a) = core::char::from_u32(k4 as u32) {a} else {'\u{0000}'},
|
||||
core::char::from_u32(k1 as u32).unwrap_or('\u{0000}'),
|
||||
core::char::from_u32(k2 as u32).unwrap_or('\u{0000}'),
|
||||
core::char::from_u32(k3 as u32).unwrap_or('\u{0000}'),
|
||||
core::char::from_u32(k4 as u32).unwrap_or('\u{0000}'),
|
||||
];
|
||||
pddb_modal.key_event(keys);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -896,38 +896,38 @@ fn xmain() -> ! {
|
|||
rootkeys_modal.activate();
|
||||
},
|
||||
Some(Opcode::UxAesEnsureReturn) => {
|
||||
#[cfg(feature = "policy-menu")]
|
||||
{ // in case we want to bring back the policy check
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let payload = buffer.to_original::<RadioButtonPayload, _>().unwrap();
|
||||
if payload.as_str() == t!("rootkeys.policy_keep", xous::LANG) {
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::AlwaysKeep));
|
||||
} else if payload.as_str() == t!("rootkeys.policy_suspend", xous::LANG) {
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::EraseOnSuspend));
|
||||
} else if payload.as_str() == "no change" {
|
||||
// don't change the policy
|
||||
} else {
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::AlwaysPurge)); // default to the most paranoid level
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let mut plaintext_pw = buf.to_original::<gam::modal::TextEntryPayload, _>().unwrap();
|
||||
|
||||
keys.hash_and_save_password(plaintext_pw.as_str());
|
||||
plaintext_pw.volatile_clear(); // ensure the data is destroyed after sending to the keys enclave
|
||||
buf.volatile_clear();
|
||||
|
||||
// this is a reasonable default policy -- don't bother the user to answer this question all the time.
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::EraseOnSuspend));
|
||||
}
|
||||
|
||||
keys.set_ux_password_type(None);
|
||||
if let Some(sender) = aes_sender.take() {
|
||||
xous::return_scalar(sender, 1).unwrap();
|
||||
#[cfg(feature = "policy-menu")]
|
||||
{ // in case we want to bring back the policy check
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let payload = buffer.to_original::<RadioButtonPayload, _>().unwrap();
|
||||
if payload.as_str() == t!("rootkeys.policy_keep", xous::LANG) {
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::AlwaysKeep));
|
||||
} else if payload.as_str() == t!("rootkeys.policy_suspend", xous::LANG) {
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::EraseOnSuspend));
|
||||
} else if payload.as_str() == "no change" {
|
||||
// don't change the policy
|
||||
} else {
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::AlwaysPurge)); // default to the most paranoid level
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut buf = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let mut plaintext_pw = buf.to_original::<gam::modal::TextEntryPayload, _>().unwrap();
|
||||
|
||||
keys.hash_and_save_password(plaintext_pw.as_str());
|
||||
plaintext_pw.volatile_clear(); // ensure the data is destroyed after sending to the keys enclave
|
||||
buf.volatile_clear();
|
||||
|
||||
// this is a reasonable default policy -- don't bother the user to answer this question all the time.
|
||||
keys.update_policy(Some(PasswordRetentionPolicy::EraseOnSuspend));
|
||||
}
|
||||
|
||||
keys.set_ux_password_type(None);
|
||||
} else {
|
||||
log::error!("entered a UxAesEnsureReturn but the flow was not set up correctly!");
|
||||
panic!("entered a UxAesEnsureReturn but the flow was not set up correctly!")
|
||||
xous::return_scalar(msg.sender, 0).unwrap();
|
||||
log::warn!("UxAesEnsureReturn detected a fat-finger event. Ignoring.");
|
||||
}
|
||||
}
|
||||
Some(Opcode::AesOracle) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue