dvDecideKioskUpdate function
DVKioskUpdateDecision
dvDecideKioskUpdate({
- required DVKioskUpdateApply apply,
- required DVMaintenanceWindow? window,
- required DVUpdateInfo update,
- required DVKioskState state,
- required DateTime now,
The decision itself, shared by device and display scope.
Implementation
DVKioskUpdateDecision dvDecideKioskUpdate({
required DVKioskUpdateApply apply,
required DVMaintenanceWindow? window,
required DVUpdateInfo update,
required DVKioskState state,
required DateTime now,
}) {
if (!update.available) {
return const DVKioskUpdateDecision(
action: DVKioskUpdateAction.none,
reason: 'no update was offered',
);
}
if (apply == DVKioskUpdateApply.immediate) {
return const DVKioskUpdateDecision(
action: DVKioskUpdateAction.apply,
reason: 'updates.apply is immediate',
);
}
final bool allowed = switch (apply) {
DVKioskUpdateApply.immediate => true,
DVKioskUpdateApply.staffMode => state == DVKioskState.staffMode,
DVKioskUpdateApply.maintenanceWindow => window?.contains(now) ?? false,
};
if (allowed) {
return DVKioskUpdateDecision(
action: DVKioskUpdateAction.apply,
reason: apply == DVKioskUpdateApply.staffMode
? 'staff are present'
: 'inside the maintenance window $window',
);
}
if (update.required) {
// The specification is explicit: a forced update outside the window shows
// the generated update UI and resets the session first. Holding a minimum
// supported version until two in the morning would leave the fleet on a
// version somebody has already decided is not fit to run.
return const DVKioskUpdateDecision(
action: DVKioskUpdateAction.resetThenApply,
reason: 'the update is required, so it does not wait for the window',
);
}
if (apply == DVKioskUpdateApply.staffMode) {
return const DVKioskUpdateDecision(
action: DVKioskUpdateAction.defer,
reason: 'waiting for staff mode',
);
}
return DVKioskUpdateDecision(
action: DVKioskUpdateAction.defer,
reason: 'outside the maintenance window $window',
notBefore: window?.nextOpening(now),
);
}