Media key events had been incorrectly dispatched to the
MediaSession2, which is closed from the app side, but
MediaSessionService didn't get the notification for it.
It may happen if MediaController2 from the MediaSession2 was
connecting and also MediaSession2 was closing. This fix ensures
that closing session is always propagated to the controller in
onConnect().
Test: Run following tests 10 times (previously flaky ~50%)
$ atest CtsMediaTestCases:android.media.cts.MediaSessionTest
Bug: 159865360
Change-Id: If16f8c665214614961f28f9406225af19fdad1a8