From 943e45f17e66d01cc070cddc7283cb8a816b0759 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 28 Jun 2022 01:18:26 +0800 Subject: [PATCH] remove suspend/resume awareness from app In retrospect forcing apps to manage their suspend in resume crosses too many abstraction barriers. Instead, the app should specify the mode of the hardware, but then the driver should be responsible for restoring that state on resume, not the app. --- apps/vault/src/main.rs | 20 -------------------- apps/vault/src/ux/framework.rs | 8 -------- 2 files changed, 28 deletions(-) diff --git a/apps/vault/src/main.rs b/apps/vault/src/main.rs index d521ffea7..82118d9f3 100644 --- a/apps/vault/src/main.rs +++ b/apps/vault/src/main.rs @@ -2,7 +2,6 @@ #![cfg_attr(target_os = "none", no_main)] mod ux; -use susres::SuspendOrder; use ux::*; use num_traits::*; use xous_ipc::Buffer; @@ -133,9 +132,6 @@ pub(crate) enum VaultOp { /// PDDB basis change BasisChange, - /// Suspend/resume notifications - SuspendResume, - /// Nop while waiting for prerequisites to be filled Nop, @@ -267,12 +263,6 @@ fn main() -> ! { // starts a thread to keep NTP up-to-date ntp_updater(time_conn); - // register with the susres so we can enforce our USB policy - let mut susres = susres::Susres::new( - Some(SuspendOrder::Early), &xns, - VaultOp::SuspendResume as u32, conn - ).expect("couldn't create suspend/resume object"); - let modals = modals::Modals::new(&xns).unwrap(); let tt = ticktimer_server::Ticktimer::new().unwrap(); loop { @@ -280,16 +270,6 @@ fn main() -> ! { let opcode: Option = FromPrimitive::from_usize(msg.body.id()); log::debug!("{:?}", opcode); match opcode { - Some(VaultOp::SuspendResume) => xous::msg_scalar_unpack!(msg, token, _, _, _, { - vaultux.suspend(); - susres.suspend_until_resume(token).expect("couldn't execute suspend/resume"); - if allow_redraw { - // if we're in the foreground, we set the USB policy. This is a cooperative measure, - // nothing prevents other processes from being stupid about this, but see - // issue #178: https://github.com/betrusted-io/xous-core/issues/178 - vaultux.resume(); - } - }), Some(VaultOp::IncrementalLine) => { if action_active.load(Ordering::SeqCst) { log::trace!("action active, skipping incremental input"); diff --git a/apps/vault/src/ux/framework.rs b/apps/vault/src/ux/framework.rs index 0325bd5a2..590a067b4 100644 --- a/apps/vault/src/ux/framework.rs +++ b/apps/vault/src/ux/framework.rs @@ -182,14 +182,6 @@ impl VaultUx { } } - pub(crate) fn suspend(&self) { - // nothing to do in particular. PDDB should sync itself. - } - pub(crate) fn resume(&self) { - self.usb_dev.switch_to_core(usb_device_xous::UsbDeviceType::Hid).unwrap(); - self.usb_dev.restrict_debug_access(true).unwrap(); - } - pub(crate) fn update_mode(&mut self) { self.title_dirty = true; self.filtered_list.clear();