mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
start to lay in suspend/resume automation for vault
it doesn't work yet -- but we need to get a push into CI for other testing now.
This commit is contained in:
parent
99f58db8e9
commit
3e70dea0f8
4 changed files with 30 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -3940,6 +3940,7 @@ dependencies = [
|
|||
"sha2",
|
||||
"sntpc",
|
||||
"subtle",
|
||||
"susres",
|
||||
"ticktimer-server",
|
||||
"trng",
|
||||
"tts-frontend",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ usbd-human-interface-device = "0.2.1"
|
|||
pddb = {path = "../../services/pddb" }
|
||||
modals = {path = "../../services/modals" }
|
||||
trng = {path="../../services/trng"}
|
||||
susres = {path = "../../services/susres"}
|
||||
|
||||
ime-plugin-api = {path = "../../services/ime-plugin-api"}
|
||||
content-plugin-api = {path = "../../services/content-plugin-api"} # all content canvas providers must provide this API
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#![cfg_attr(target_os = "none", no_main)]
|
||||
|
||||
mod ux;
|
||||
use susres::SuspendOrder;
|
||||
use ux::*;
|
||||
use num_traits::*;
|
||||
use xous_ipc::Buffer;
|
||||
|
|
@ -132,6 +133,9 @@ pub(crate) enum VaultOp {
|
|||
/// PDDB basis change
|
||||
BasisChange,
|
||||
|
||||
/// Suspend/resume notifications
|
||||
SuspendResume,
|
||||
|
||||
/// Nop while waiting for prerequisites to be filled
|
||||
Nop,
|
||||
|
||||
|
|
@ -263,6 +267,12 @@ 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 {
|
||||
|
|
@ -270,6 +280,16 @@ fn main() -> ! {
|
|||
let opcode: Option<VaultOp> = 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");
|
||||
|
|
|
|||
|
|
@ -182,6 +182,14 @@ 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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue