Fix various issues related to music player service #397
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #162533648 as well as a few other miscellaneous issues related to communication between the player service and UI procress.
Testing Steps
In order of commit, the following changes have been made.
Reduction in the number of unexpected notifications from the service
There was a logic issue that would cause the playback notification to appear when Jockey was not in the foreground or had not yet begun to play music in this app session. This should reduce the frequency of unexpected playback notifications.
The playback notification gets stuck in the foreground state
On devices running Android Oreo and higher, there are changes to background execution limits that may cause the playback notification to get stuck in the playing state, leaving an playback notification that could not be dismissed.
To reproduce, play music without opening the app. You can do this by using a pair of headphones with an inline remote or with a bluetooth stereo that has media controls. Then, pause music. Music will stop playing, but the notification will not be updated and cannot be dismissed. Tapping the pause button will actually play music. Tapping the pause button in the notification will not cause this behavior and could be used to dismiss the notification.
The playback service may crash silently
There were a few fatal exceptions that were causing the player service to crash, but a user-facing alert was not shown because the app was not in the foreground. To reproduce, enable "Always Show Crash Dialog" in the developer settings (under "Apps" at the bottom of the list). This PR fixes crash dialogs that would appear after dismissing the playback notification.
Jockey would not correctly show the seek progress on app launch
This is actually a UI error, but it's a small change that I'm lumping it with these other issues. When launching Jockey from a cold start, it will now display the correct seek progress for the current song in the now playing toolbar at the bottom of the screen based on wherever playback was left off in the previous session. Previously, this seek bar would always indicate the song was starting from the beginning until the playback state changed.