Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ is on main, the release is published with that section as its notes (AGENTS.md,

### Installer and launcher

- Choosing Dopamine in the Options after a start with palera1n didn't work
now switches to Dopamine: the installer finds the device again as it is,
and Continue installs the helper app. Before, it kept sending the device
back into DFU mode for palera1n.

- Installing the helper app with an Apple ID (xtool, on Linux and on a Mac
without Xcode) shows what xtool says, line by line, in the installer's
Details and the run log, like palera1n's output, and gets through
Expand Down
21 changes: 18 additions & 3 deletions crates/flow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,16 @@ fn step_inner(app: App, mut flow: Flow, event: Event) -> (Flow, Vec<Effect>) {
flow.welcome = false;
return (flow, out);
}
Event::SetOptions(options) => {
flow.options = options;
return (flow, out);
Event::SetOptions(ref options) => {
flow.options = options.clone();
// Dopamine, chosen during a round into DFU mode for the split,
// ends that round (update_plain); any other choice waits for
// the next step.
let leaves_round = matches!(&flow.state, State::DfuAgain { device, why: Again::Prepare | Again::RetryPrepare, .. }
if rules::helper(&flow.options, device) == Some(Helper::Dopamine));
if !leaves_round {
return (flow, out);
}
}
// The tools of what was chosen, in place of the ones fetched for
// what was in effect before (the same ones are there at once).
Expand Down Expand Up @@ -1558,6 +1565,14 @@ fn update_plain(app: App, ctx: &Ctx, state: State, event: Event) -> (State, Vec<
(_, E::SplitRunning { device, omarchy_gb }) => (S::Splitting { device, omarchy_gb, link: Link::Lost, reopened: true }, none()),

// ---- A round into DFU mode ----
// Dopamine chosen in its Options (palera1n's start didn't work, say):
// the helper app needs iOS, not DFU mode. The device is found again
// as it is, and Continue takes the app.
(S::DfuAgain { device, why: Again::Prepare | Again::RetryPrepare, .. }, E::SetOptions(_))
if rules::helper(&ctx.options, &device) == Some(Helper::Dopamine) =>
{
start_over(device, ctx.at)
}
(S::DfuAgain { device: d, why, .. }, E::Attached { device, mode: UsbMode::Dfu }) if d.id == device.id => reached_dfu(app, ctx, carried(&d, device), why),
// Pwned DFU mode starts an install or a system, never the helper.
(S::DfuAgain { device: d, why, .. }, E::Attached { device, mode: UsbMode::PwnedDfu })
Expand Down
37 changes: 37 additions & 0 deletions crates/flow/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,43 @@ fn dopamine_needs_ios_running_the_installer_leaves_recovery_but_not_dfu() {
assert_eq!(kind(app, &s), ScreenKind::HelperInstalling);
}

#[test]
fn dopamine_chosen_after_palera1n_failed_leaves_the_round_into_dfu() {
let app = App::Installer;
let ipad = on(ipad6(), "15.8.6");
let palera1n_failed = |flow: Flow| {
// palera1n by default: into DFU mode, its start, and iPadOS again.
let (flow, _) = step(app, flow, seen(ipad.clone(), UsbMode::Normal));
let (flow, _) = step(app, flow, Event::Continue);
let (flow, _) = step(app, flow, dfu(ipad6()));
assert_eq!(kind(app, &flow.state), ScreenKind::WaitingForIpados);
let (flow, _) = step(app, flow, Event::ChainFailed("it restarted normally instead".into()));
let (flow, _) = step(app, flow, seen(ipad.clone(), UsbMode::Normal));
assert!(matches!(flow.state, State::DfuAgain { why: Again::RetryPrepare, .. }));
flow
};
let dopamine = Options { helper: Some(Helper::Dopamine), ..Options::default() };
// Another choice there changes nothing yet.
let flow = palera1n_failed(Flow::new());
let (flow, e) = step(app, flow, Event::SetOptions(Options { helper: Some(Helper::Checkra1n), ..Options::default() }));
assert!(e.is_empty() && matches!(flow.state, State::DfuAgain { .. }));
// Dopamine: found again as it is (iPadOS), and Continue takes the app.
let (flow, e) = step(app, palera1n_failed(Flow::new()), Event::SetOptions(dopamine.clone()));
assert!(e.is_empty() && flow.start_problem.is_none());
assert!(matches!(&flow.state, State::Found { mode: UsbMode::Normal, restart: false, .. }));
let (flow, e) = step(app, flow, Event::Continue);
assert_eq!(e, vec![Effect::InstallHelper(ipad.id.clone())]);
assert_eq!(kind(app, &flow.state), ScreenKind::HelperInstalling);
// Already in recovery mode: the installer restarts it for the app.
let (flow, _) = step(app, palera1n_failed(Flow::new()), recovery(ipad6()));
let (flow, _) = step(app, flow, Event::SetOptions(dopamine.clone()));
assert!(matches!(&flow.state, State::Found { mode: UsbMode::Recovery, .. }));
let (flow, e) = step(app, flow, Event::Continue);
assert_eq!(e, vec![Effect::PrepareRecovery(ipad.id.clone()), Effect::RestartFromRecovery(ipad.id.clone())]);
// The choice stays through Start over.
assert_eq!(flow.options, dopamine);
}

#[test]
fn a_version_dopamine_does_not_take_is_caught_once_ios_tells_it() {
let app = App::Installer;
Expand Down
Loading