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
17 changes: 12 additions & 5 deletions open_wearable/lib/widgets/fota/stepper_view/update_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ class _UpdateStepViewState extends State<UpdateStepView> {
_verificationResult != null &&
(_isVerificationReset(state) || _isNativeSuccess(state));

bool _canAbortUpdate(UpdateState state) =>
state is UpdateFirmwareStateHistory &&
!state.isComplete &&
!_isVerificationReset(state) &&
!_isVerificationPending;

bool _isUpdateInProgress(UpdateState state) {
if (state is UpdateInitial || _hasVerificationResult(state)) return false;
if (state is UpdateFirmwareStateHistory) {
Expand Down Expand Up @@ -397,7 +403,8 @@ class _UpdateStepViewState extends State<UpdateStepView> {
),
);

if (!mounted || shouldAbort != true) {
// The earphone may have started rebooting while confirmation was open.
if (!mounted || shouldAbort != true || !_canAbortUpdate(updateBloc.state)) {
return;
}

Expand Down Expand Up @@ -510,14 +517,14 @@ class _UpdateStepViewState extends State<UpdateStepView> {
_currentStatePanel(context, state),
const SizedBox(height: 10),
],
if (!state.isComplete && !verificationFinished) ...[
_abortButton(context),
const SizedBox(height: 10),
],
if (_isVerificationPending) ...[
_successPanel(context),
const SizedBox(height: 10),
],
if (_canAbortUpdate(state)) ...[
_abortButton(context),
const SizedBox(height: 10),
],
if (verificationFinished) ...[
_completedStep(
context,
Expand Down
16 changes: 16 additions & 0 deletions open_wearable/test/models/fota_post_update_verification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ void main() {
expect(armedIds, isNull,
reason: 'Recovery resets before upload must not verify',);
expect(find.textContaining('Verification in progress'), findsNothing);
expect(find.text('Abort Update'), findsOneWidget);
if (outcome == 'verified') {
bloc.show(UpdateFirmwareStateHistory(UpdateFirmware('Test'), [
UpdateProgressFirmware('Upload', 100, 1),
]),);
await tester.pump();
await tester.tap(find.text('Abort Update'));
await tester.pump(const Duration(milliseconds: 300));
}
bloc.show(
UpdateFirmwareStateHistory(UpdateFirmware('Reset'), [
UpdateProgressFirmware('Upload', 100, 1),
Expand All @@ -301,6 +310,11 @@ void main() {
);
await tester.pump();
await tester.pump();
if (outcome == 'verified') {
// A confirmation opened before reboot must no longer abort it.
await tester.tap(find.text('Abort Update').last);
await tester.pump(const Duration(milliseconds: 300));
}
expect(
armedIds,
isNotNull,
Expand All @@ -309,6 +323,7 @@ void main() {
final id = armedIds!.single;
expect(find.text('Reset and verify'), findsOneWidget);
expect(find.textContaining('Verification in progress'), findsOneWidget);
expect(find.text('Abort Update'), findsNothing);
expect(find.textContaining(RegExp(r'0[23]:[0-5][0-9]')), findsOneWidget);
expect(banners.activeBanners, hasLength(1));
expect(running.last, isTrue);
Expand Down Expand Up @@ -439,6 +454,7 @@ void main() {
);
await tester.pump();
expect(find.text('Upload firmware'), findsNothing);
expect(find.text('Abort Update'), findsOneWidget);
expect(
find.text(
'Uploading ${image == 0 ? 'application' : 'network'} core ${50 + image}%',
Expand Down
Loading