mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
resolve issue #267
This commit is contained in:
parent
4dc7135e0e
commit
80a1bd3654
5 changed files with 37 additions and 6 deletions
|
|
@ -201,6 +201,10 @@ pub(crate) enum Opcode {
|
|||
Bip39toBytes = 30,
|
||||
BytestoBip39 = 31,
|
||||
Bip39Suggestions = 32,
|
||||
|
||||
/// Allow main menu activation. Used by the PDDB to turn ungate the main menu once it is mounted.
|
||||
/// This resolves race conditions that depend upon the PDDB configurations.
|
||||
AllowMainMenu = 33,
|
||||
}
|
||||
|
||||
// small wart -- we have to reset the size of a modal to max size for resize computations
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ pub(crate) struct ContextManager {
|
|||
/// for internal generation of deface states
|
||||
pub trng: trng::Trng,
|
||||
tt: ticktimer_server::Ticktimer,
|
||||
/// used to suppress the main menu from activating until the boot PIN has been requested
|
||||
allow_mainmenu: bool,
|
||||
}
|
||||
impl ContextManager {
|
||||
pub fn new(xns: &xous_names::XousNames) -> Self {
|
||||
|
|
@ -122,6 +124,7 @@ impl ContextManager {
|
|||
main_menu_app_token: None,
|
||||
trng: trng::Trng::new(&xns).expect("couldn't connect to trng"),
|
||||
tt: ticktimer_server::Ticktimer::new().unwrap(),
|
||||
allow_mainmenu: false,
|
||||
}
|
||||
}
|
||||
pub(crate) fn claim_token(&mut self, name: &str) -> Option<[u32; 4]> {
|
||||
|
|
@ -582,6 +585,9 @@ impl ContextManager {
|
|||
}
|
||||
Err(xous::Error::ServerNotFound)
|
||||
}
|
||||
pub(crate) fn allow_mainmenu(&mut self) {
|
||||
self.allow_mainmenu = true;
|
||||
}
|
||||
pub(crate) fn key_event(&mut self, keys: [char; 4],
|
||||
gfx: &graphics_server::Gfx,
|
||||
canvases: &mut HashMap<Gid, Canvas>,
|
||||
|
|
@ -591,13 +597,19 @@ impl ContextManager {
|
|||
if keys[0] == '∴' {
|
||||
if let Some(context) = self.get_context_by_token(self.focused_context.unwrap()) {
|
||||
if context.layout.behavior() == LayoutBehavior::App {
|
||||
if let Some(menu_token) = self.find_app_token_by_name(MAIN_MENU_NAME) {
|
||||
// set the menu to the active context
|
||||
match self.activate(gfx, canvases, menu_token, false) {
|
||||
Ok(_) => (),
|
||||
Err(_) => log::warn!("Couldn't raise menu, user will have to try again."),
|
||||
log::info!("allow_mainmenu: {:?}", self.allow_mainmenu);
|
||||
if self.allow_mainmenu {
|
||||
if let Some(menu_token) = self.find_app_token_by_name(MAIN_MENU_NAME) {
|
||||
// set the menu to the active context
|
||||
match self.activate(gfx, canvases, menu_token, false) {
|
||||
Ok(_) => (),
|
||||
Err(_) => log::warn!("Couldn't raise menu, user will have to try again."),
|
||||
}
|
||||
// don't pass the initial key hit back to the menu app, just eat it and return
|
||||
return;
|
||||
}
|
||||
// don't pass the initial key hit back to the menu app, just eat it and return
|
||||
} else {
|
||||
// eat the key and return if it is hit before the boot PIN was entered
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,13 @@ impl Gam {
|
|||
).map(|_|())
|
||||
}
|
||||
|
||||
/// Inform the GAM that the main menu can be activated. This blocks until the message has been delivered to the GAM.
|
||||
pub fn allow_mainmenu(&self) -> Result<(), xous::Error> {
|
||||
send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::AllowMainMenu.to_usize().unwrap(), 0, 0, 0, 0)
|
||||
).map(|_|())
|
||||
}
|
||||
|
||||
pub fn powerdown_request(&self) -> Result<bool, xous::Error> {
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::PowerDownRequest.to_usize().unwrap(), 0, 0, 0, 0))?;
|
||||
|
|
|
|||
|
|
@ -664,6 +664,10 @@ fn wrapped_main() -> ! {
|
|||
}
|
||||
buffer.replace(spec).unwrap();
|
||||
}
|
||||
Some(Opcode::AllowMainMenu) => {
|
||||
context_mgr.allow_mainmenu();
|
||||
xous::return_scalar(msg.sender, 0).ok();
|
||||
}
|
||||
Some(Opcode::Quit) => break,
|
||||
None => {log::error!("unhandled message {:?}", msg);}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -701,6 +701,10 @@ fn wrapped_main() -> ! {
|
|||
failcount.min(u32::MAX as u64) as usize
|
||||
).expect("couldn't return scalar"),
|
||||
}
|
||||
// get a handle to the GAM and inform it that main menu should be allowed. The handle is dropped when this routine finishes.
|
||||
let gam = gam::Gam::new(&xns).unwrap();
|
||||
gam.allow_mainmenu().expect("coudln't allow main menu activation");
|
||||
// setup the heap
|
||||
initial_heap = heap_usage();
|
||||
latest_heap = initial_heap;
|
||||
latest_cache = basis_cache.cache_size();
|
||||
|
|
|
|||
Loading…
Reference in a new issue