I've been looking through the code and I can see that doPlay is called on our MediaSessionCompat.Callback as registered in RemoteControlClientLP.
However, the same callback is called when someone presses the play button, and there's no contextual information for the event. So how do we know when to prevent playback, and when to allow it?
I've found that...
In AutoMediaBrowserService I can create a MediaBrowserCompat and register a MediaBrowserCompat.ConnectionCallback with that which tells us when Android Auto connects. This occurs before the doPlay().
If I remove the call in AutoMediaBrowserService to setSessionToken() with the RemoveControlClientLP's MediaSessionCompat then the auto play doesn't happen. I stepped through this code, but nothing seems to be done with that token directly from that call and I can't see any other requests on the session token, so I'm puzzled as to why that affects things.
When I run the Android Auto
desktop-head-unit
and connect it to a physical Android device running D-Sub, the playback seems to resume its last state.The trouble is that this contravenes the Android Auto quality guidelines (MA-1). Apps submitted to the Play Store may be rejected as a result.
I've been looking through the code and I can see that
doPlay
is called on ourMediaSessionCompat.Callback
as registered inRemoteControlClientLP
.However, the same callback is called when someone presses the play button, and there's no contextual information for the event. So how do we know when to prevent playback, and when to allow it?
I've found that...
In
AutoMediaBrowserService
I can create aMediaBrowserCompat
and register aMediaBrowserCompat.ConnectionCallback
with that which tells us when Android Auto connects. This occurs before thedoPlay()
.If I remove the call in
AutoMediaBrowserService
tosetSessionToken()
with theRemoveControlClientLP
'sMediaSessionCompat
then the auto play doesn't happen. I stepped through this code, but nothing seems to be done with that token directly from that call and I can't see any other requests on the session token, so I'm puzzled as to why that affects things.Anyone got any guidance about how to debug this?