Skip to content

Commit

Permalink
Don't set negative values to setWhen()
Browse files Browse the repository at this point in the history
When the 'when' timer of the notification is disabled
`DefaultMediaNotificationProvider` may set `C.TIME_UNSET`
as the time. Users reported problems on some devices with
this and the docs ask for an event time that probably
shouldn't be a negative number.

This change sets `0L` instead of `C.TIME_UNSET` when the
timer is disabled.

Issue: #903

#minor-release

PiperOrigin-RevId: 594451074
  • Loading branch information
marcbaechinger authored and copybara-github committed Dec 29, 2023
1 parent 846ace1 commit 426bc94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
[#802](https://github.com/androidx/media/issues/802)).
* Fix broadcasting `notifyChildrenChanged` for legacy controllers
([#644](https://github.com/androidx/media/issues/644)).
* Fix a bug where setting a negative time for a disabled `setWhen` timer
of the notification caused a crash on some devices
([#903](https://github.com/androidx/media/issues/903)).
* UI:
* Fix issue where forward and rewind buttons are not visible when used
with Material Design in a BottomSheetDialogFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public final MediaNotification createNotification(
long playbackStartTimeMs = getPlaybackStartTimeEpochMs(player);
boolean displayElapsedTimeWithChronometer = playbackStartTimeMs != C.TIME_UNSET;
builder
.setWhen(playbackStartTimeMs)
.setWhen(displayElapsedTimeWithChronometer ? playbackStartTimeMs : 0L)
.setShowWhen(displayElapsedTimeWithChronometer)
.setUsesChronometer(displayElapsedTimeWithChronometer);

Expand Down

0 comments on commit 426bc94

Please sign in to comment.