Update main.rs

This is how I'd do the app switch. It's a special case going to the shellchat. shellchat is aliased to `INITIAL_APP_FOCUS`, so you can refer to that constant directly in this call, instead of using a more generic app-lookup mechanism. 

Also, because the idea is that we can allow *anyone* to call this method, there are no authorization tokens to check, unlike the SwitchToApp call, which can allow arbitrary apps to be foregrounded.

The security assumption is that "no harm" can be done if a malicious process can bring shellchat to the foreground. This might not be a good assumption, but, I can't think of a scenario where this helps someone trying to get control of a device.
This commit is contained in:
bunnie 2022-10-19 01:38:58 +08:00 committed by GitHub
parent 371d058941
commit e9b1e25ca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -665,8 +665,14 @@ fn wrapped_main() -> ! {
buffer.replace(spec).unwrap(); buffer.replace(spec).unwrap();
} }
Some(Opcode::DefaultApp) => { Some(Opcode::DefaultApp) => {
// FIXME: Switch to shellchat here if let Some(new_app_token) = context_mgr.find_app_token_by_name(INITIAL_APP_FOCUS) {
log::error!("not implemented yet, switch to shellchat: {:?}", msg); match context_mgr.activate(&gfx, &mut canvases, new_app_token, true) {
Ok(_) => (),
Err(_) => log::warn!("failed to switch to {}, silent error!", switchapp.app_name.as_str().unwrap()),
}
} else {
log::warn!("Request to switch to default app, but the default app has not registered itself yet!");
}
} }
Some(Opcode::Quit) => break, Some(Opcode::Quit) => break,
None => {log::error!("unhandled message {:?}", msg);} None => {log::error!("unhandled message {:?}", msg);}