Skip to content

Commit 7eecf2b

Browse files
committed
remove the initial wait from PDDB; move the pop-up modal location
The initial wait message is now rendered by the first app that owns the screen (currently shellchat). The location where the pop-up modal is rendered is also now bracketed directly around the mount call to avoid interference with other edge cases that may pop up modals.
1 parent 0d02415 commit 7eecf2b

File tree

2 files changed

+14
-40
lines changed

2 files changed

+14
-40
lines changed

services/pddb/locales/i18n.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
"ja": "パスワードを認証失敗でした。\n\nもう一度実行しください。",
1414
"zh": "密码错误。"
1515
},
16+
"pddb.waitmount": {
17+
"en": "Mounting PDDB, please wait...",
18+
"en-tts": "Mounting PDDB, please wait...",
19+
"fr": "Montage de PDDB, veuillez patienter...*MT*",
20+
"ja": "PDDB をマウントしています。お待ちください...",
21+
"zh": "正在挂载 PDDB,请稍候..."
22+
},
1623
"pddb.basisname": {
1724
"en": "Basis Name:",
1825
"en-tts": "Enter name of Basis",

services/pddb/src/main.rs

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ use std::collections::{HashMap, BTreeSet};
394394
use std::io::ErrorKind;
395395
use core::fmt::Write;
396396
use std::sync::atomic::{AtomicBool, Ordering};
397-
use std::sync::{Arc, Mutex};
397+
use std::sync::Arc;
398398

399399
use locales::t;
400400

@@ -490,34 +490,6 @@ fn wrapped_main() -> ! {
490490
}
491491
});
492492

493-
let hide_startingup_notif = Arc::new(Mutex::new(false));
494-
let hide_startingup_notif_clone = hide_startingup_notif.clone();
495-
496-
std::thread::spawn(move || {
497-
// For some weird reason spawning a dynamic notification without waiting 800ms in a separate thread
498-
// makes it impossible to read, because it gets covered by hundreds of those modal security lines (???).
499-
// This thread waits on hide_startingup_notif to become true, then disimsses the dynamic notification that it created
500-
// previously.
501-
// To allow other threads to do work, yield to kernel every time the variable is read as false.
502-
503-
let xns = xous_names::XousNames::new().unwrap();
504-
let modals = modals::Modals::new(&xns).expect("can't connect to Modals server");
505-
506-
std::thread::sleep(std::time::Duration::from_millis(1000));
507-
508-
modals.dynamic_notification(Some("Starting up..."), Some("Precursor is booting up, please wait.")).unwrap();
509-
510-
loop {
511-
if *hide_startingup_notif_clone.lock().unwrap() {
512-
modals.dynamic_notification_close().unwrap();
513-
break;
514-
}
515-
516-
xous::yield_slice();
517-
};
518-
});
519-
520-
521493
// OS-specific PDDB driver
522494
let mut pddb_os = PddbOs::new(Rc::clone(&entropy), pw_cid);
523495
// storage for the basis cache
@@ -684,8 +656,6 @@ fn wrapped_main() -> ! {
684656
// - code = 2 -> mount failed, because too many PINs were retried. `count` is the number of retries.
685657
// If we need more nuance out of this routine, consider creating a custom public enum type to help marshall this.
686658
Opcode::TryMount => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
687-
*hide_startingup_notif.lock().unwrap() = true;
688-
689659
if basis_cache.basis_count() > 0 {
690660
xous::return_scalar2(msg.sender, 0, 0).expect("couldn't return scalar");
691661
} else {
@@ -699,8 +669,6 @@ fn wrapped_main() -> ! {
699669
} else {
700670
match ensure_password(&modals, &mut pddb_os, pw_cid) {
701671
PasswordState::Correct => {
702-
modals.dynamic_notification(Some("Starting up..."), Some("Mounting PDDB, please wait.")).unwrap();
703-
704672
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Correct, time_resetter) {
705673
is_mounted.store(true, Ordering::SeqCst);
706674
for requester in mount_notifications.drain(..) {
@@ -712,12 +680,8 @@ fn wrapped_main() -> ! {
712680
} else {
713681
xous::return_scalar2(msg.sender, 1, 0).expect("couldn't return scalar");
714682
}
715-
716-
modals.dynamic_notification_close().unwrap();
717683
},
718684
PasswordState::Uninit => {
719-
modals.dynamic_notification(Some("Starting up..."), Some("Mounting PDDB, please wait.")).unwrap();
720-
721685
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Uninit, time_resetter) {
722686
for requester in mount_notifications.drain(..) {
723687
xous::return_scalar2(requester, 0, 0).expect("couldn't return scalar");
@@ -729,8 +693,6 @@ fn wrapped_main() -> ! {
729693
} else {
730694
xous::return_scalar2(msg.sender, 1, 0).expect("couldn't return scalar");
731695
}
732-
733-
modals.dynamic_notification_close().unwrap();
734696
},
735697
PasswordState::ForcedAbort(failcount) => {
736698
xous::return_scalar2(msg.sender, 2,
@@ -1965,11 +1927,14 @@ fn ensure_password(modals: &modals::Modals, pddb_os: &mut PddbOs, _pw_cid: xous:
19651927
fn try_mount_or_format(modals: &modals::Modals, pddb_os: &mut PddbOs, basis_cache: &mut BasisCache, pw_state: PasswordState, time_resetter: xous::CID) -> bool {
19661928
log::info!("Attempting to mount the PDDB");
19671929
if pw_state == PasswordState::Correct {
1930+
modals.dynamic_notification(Some(t!("pddb.waitmount", xous::LANG)), None).unwrap();
19681931
if let Some(sys_basis) = pddb_os.pddb_mount() {
19691932
log::info!("PDDB mount operation finished successfully");
19701933
basis_cache.basis_add(sys_basis);
1934+
modals.dynamic_notification_close().unwrap();
19711935
return true
19721936
}
1937+
modals.dynamic_notification_close().unwrap();
19731938
}
19741939
// correct password but no mount -> offer to format; uninit -> offer to format
19751940
if pw_state == PasswordState::Correct || pw_state == PasswordState::Uninit {
@@ -2026,12 +1991,14 @@ fn try_mount_or_format(modals: &modals::Modals, pddb_os: &mut PddbOs, basis_cach
20261991
0, 0, 0, 0
20271992
)
20281993
).expect("couldn't reset time");
2029-
1994+
modals.dynamic_notification(Some(t!("pddb.waitmount", xous::LANG)), None).unwrap();
20301995
if let Some(sys_basis) = pddb_os.pddb_mount() {
20311996
log::info!("PDDB mount operation finished successfully");
20321997
basis_cache.basis_add(sys_basis);
1998+
modals.dynamic_notification_close().unwrap();
20331999
true
20342000
} else {
2001+
modals.dynamic_notification_close().unwrap();
20352002
log::error!("Despite formatting, no PDDB was found!");
20362003
let mut err = String::from(t!("pddb.internalerror", xous::LANG));
20372004
err.push_str(" #1"); // punt and leave an error code, because this "should" be rare

0 commit comments

Comments
 (0)