clean up hosted mode flow

This commit is contained in:
bunnie 2022-01-07 23:33:53 +08:00
parent 904847fc89
commit 00ce905088
2 changed files with 51 additions and 30 deletions

View file

@ -171,7 +171,7 @@ impl PddbOs {
self.pddb_mr.dump_fs(&name);
let mut export = Vec::<KeyExport>::new();
if let Some(key) = self.system_basis_key {
log::info!("written key: {:x?}", key);
log::info!("(hosted mode debug) written key: {:x?}", key);
let mut name = [0 as u8; 64];
for (&src, dst) in PDDB_DEFAULT_SYSTEM_BASIS.as_bytes().iter().zip(name.iter_mut()) {
*dst = src;
@ -1205,7 +1205,9 @@ impl PddbOs {
let mut checkblock_a = [0u8; BLOCK_SIZE];
self.rootkeys.decrypt_block(GenericArray::from_mut_slice(&mut checkblock_a));
#[cfg(any(target_os = "none", target_os = "xous"))] // skip this dialog in hosted mode
modals.show_notification(t!("pddb.checkpass", xous::LANG)).expect("notification failed");
self.clear_password();
let mut checkblock_b = [0u8; BLOCK_SIZE];
self.rootkeys.decrypt_block(GenericArray::from_mut_slice(&mut checkblock_b));

View file

@ -486,44 +486,63 @@ fn xmain() -> ! {
log::info!("PDDB mount operation finished successfully");
basis_cache.basis_add(sys_basis);
} else {
log::debug!("PDDB did not mount; requesting format");
modals.add_list_item(t!("pddb.okay", xous::LANG)).expect("couldn't build radio item list");
modals.add_list_item(t!("pddb.cancel", xous::LANG)).expect("couldn't build radio item list");
let do_format: bool;
match modals.get_radiobutton(t!("pddb.requestformat", xous::LANG)) {
Ok(response) => {
if response.as_str() == t!("pddb.okay", xous::LANG) {
do_format = true;
} else if response.as_str() == t!("pddb.cancel", xous::LANG) {
log::info!("PDDB format aborted by user");
do_format = false;
} else {
panic!("Got unexpected return from radiobutton");
}
}
_ => panic!("get_radiobutton failed"),
}
if do_format {
modals.add_list_item(t!("pddb.no", xous::LANG)).expect("couldn't build radio item list");
modals.add_list_item(t!("pddb.yes", xous::LANG)).expect("couldn't build radio item list");
let fast: bool;
match modals.get_radiobutton(t!("pddb.devbypass", xous::LANG)) {
#[cfg(any(target_os = "none", target_os = "xous"))]
{
log::debug!("PDDB did not mount; requesting format");
modals.add_list_item(t!("pddb.okay", xous::LANG)).expect("couldn't build radio item list");
modals.add_list_item(t!("pddb.cancel", xous::LANG)).expect("couldn't build radio item list");
let do_format: bool;
match modals.get_radiobutton(t!("pddb.requestformat", xous::LANG)) {
Ok(response) => {
if response.as_str() == t!("pddb.yes", xous::LANG) {
fast = true;
} else if response.as_str() == t!("pddb.no", xous::LANG) {
fast = false;
if response.as_str() == t!("pddb.okay", xous::LANG) {
do_format = true;
} else if response.as_str() == t!("pddb.cancel", xous::LANG) {
log::info!("PDDB format aborted by user");
do_format = false;
} else {
panic!("Got unexpected return from radiobutton");
}
}
_ => panic!("get_radiobutton failed"),
}
pddb_os.pddb_format(fast, Some(&modals)).expect("couldn't format PDDB");
if do_format {
let fast: bool;
if false {
modals.add_list_item(t!("pddb.no", xous::LANG)).expect("couldn't build radio item list");
modals.add_list_item(t!("pddb.yes", xous::LANG)).expect("couldn't build radio item list");
match modals.get_radiobutton(t!("pddb.devbypass", xous::LANG)) {
Ok(response) => {
if response.as_str() == t!("pddb.yes", xous::LANG) {
fast = true;
} else if response.as_str() == t!("pddb.no", xous::LANG) {
fast = false;
} else {
panic!("Got unexpected return from radiobutton");
}
}
_ => panic!("get_radiobutton failed"),
}
} else {
fast = false;
}
#[cfg(not(any(target_os = "none", target_os = "xous")))]
pddb_os.pddb_format(fast, Some(&modals)).expect("couldn't format PDDB");
if let Some(sys_basis) = pddb_os.pddb_mount() {
log::info!("PDDB mount operation finished successfully");
basis_cache.basis_add(sys_basis);
} else {
log::error!("Despite formatting, no PDDB was found!");
let mut err = String::from(t!("pddb.internalerror", xous::LANG));
err.push_str(" #1"); // punt and leave an error code, because this "should" be rare
modals.show_notification(err.as_str()).expect("notification failed");
}
}
}
#[cfg(not(any(target_os = "none", target_os = "xous")))]
{
pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB");
pddb_os.dbg_dump(Some("full".to_string()), None);
if let Some(sys_basis) = pddb_os.pddb_mount() {
log::info!("PDDB mount operation finished successfully");
basis_cache.basis_add(sys_basis);