Skip to content

Fix Android audiobook ended-state parsing for partial locators - #202

Draft
m-abs with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-integration-tests-android-emulator
Draft

Fix Android audiobook ended-state parsing for partial locators#202
m-abs with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-integration-tests-android-emulator

Conversation

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

The Android integration job was failing in the audiobook end-of-playback path. The terminal TimebasedState.ended event could carry a currentLocator without progression / totalProgression, and Dart-side normalization crashed while rebuilding Locations.

  • Root cause

    • ReadiumTimebasedState.fromJson() normalizes ended-state locators to 1.0 progress.
    • That path called Locator.copyWithLocations() / Locations.copyWith() with partially populated location data and hit a null-unsafe branch.
  • Change

    • Reworked shared Locator / Locations copy helpers to preserve existing values via explicit sentinel checks instead of the failing nullable helper path.
    • Keeps ended-state normalization intact: missing progress fields are still normalized to 1.0 when the player reports ended.
  • Regression coverage

    • Added a model test for an ended audiobook locator that only includes stable fields such as position and time fragment, with no progression fields.
  • Changelog

    • Added an Unreleased entry in flutter_readium_platform_interface/CHANGELOG.md.
final state = ReadiumTimebasedState.fromJson({
  'state': 'ended',
  'currentLocator': {
    'href': 'last.mp3',
    'type': 'audio/mpeg',
    'locations': {
      'position': 3,
      'fragments': ['t=123.45'],
    },
  },
});

expect(state.currentLocator?.locations?.progression, 1.0);
expect(state.currentLocator?.locations?.totalProgression, 1.0);

Co-authored-by: m-abs <1348705+m-abs@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job for integration tests on Android Fix Android audiobook ended-state parsing for partial locators Aug 12, 2026
Copilot AI requested a review from m-abs August 12, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants