Fix to allow `app-loader' to switch app

`EXPECTED_APP_CONTEXTS' was added to the list of authorized
switchers. I don't think this is ideal, but I think it would be
difficult to come up with a better solution that doesn't make
`app-loader' "special" in some way.
This commit is contained in:
Vihaan Jim 2023-08-05 09:59:20 -04:00
parent 1e645a4b94
commit 2d6e12f6b3
2 changed files with 3 additions and 2 deletions

View file

@ -87,7 +87,7 @@ fn main() -> ! {
xous::send_message(spawn.cid, xous::Message::new_lend(1, buf, None, None)).expect("Couldn't send a message to spawn");
menu.add_item(MenuItem { name: load_app_req.name,
action_conn: Some(self_conn),
action_conn: Some(self_conn),
action_opcode: Opcode::DispatchApp.to_u32().unwrap(),
action_payload: gam::MenuPayload::Scalar([apps.len().try_into().unwrap(), 0, 0, 0]),
close_on_select: true });
@ -98,6 +98,7 @@ fn main() -> ! {
let index = msg.body.scalar_message().expect("Not a scalar").arg1;
if index < apps.len() {
let name: xous_ipc::String<64> = apps[index];
log::info!("Switching to app `{}'", name);
gam.switch_to_app(name.as_ref(), auth).expect(&format!("Could not dispatch app `{}'", name));
} else {
panic!("Unrecognized app index");

View file

@ -565,7 +565,7 @@ fn wrapped_main() -> ! {
// set before the leaving state due to interior-mutability issues (see the block under the debug statement
// titled "resolving visibility rules"). The fix is to simply not issue a context switch if it's the same app.
// It saves CPU thrashing and also works around this problem. (see issue #145)
let authorized_switchers = vec![MAIN_MENU_NAME, ROOTKEY_MODAL_NAME, gam::STATUS_BAR_NAME];
let authorized_switchers = [&[MAIN_MENU_NAME, ROOTKEY_MODAL_NAME, gam::STATUS_BAR_NAME], gam::EXPECTED_APP_CONTEXTS].concat().to_vec();
for switchers in authorized_switchers {
if let Some(auth_token) = context_mgr.find_app_token_by_name(switchers) {
if auth_token == switchapp.token {