Fix a bug and add a feature for media resumption
Fix a bug where media resumption would break if prepare() was called in onCreate()
Media resumption code relied on the assumption that if no media controller sends any commands, the player will stay in STATE_IDLE. This optimization however breaks if a developer calls prepare() in or shortly after (in my case, which caused this to be a race) onCreate(). Instead, use playWhenReady to determine whether we need to do a query with effort, because playWhenReady really shouldn't be set to true on device bootup. :) SystemUI asks for resumption support while a session is active and just started playing (playWhenReady=true), hence the optimization is still valid.
Formal API to allow apps to handle playback resumption themselves
This could previously be achieved by inspecting stack trace of onPlaybackResumption() and then returning settable future that will never be set, but this API adds a cleaner way and makes the caveats of this clearer.
Issue: https://github.com/androidx/media/issues/1764