Fix flaky media key event related CTS tests
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
This commit is contained in:
@@ -404,7 +404,7 @@ public class MediaSession2 implements AutoCloseable {
|
||||
mCallback.onPostConnect(MediaSession2.this, controllerInfo);
|
||||
connected = true;
|
||||
} finally {
|
||||
if (!connected) {
|
||||
if (!connected || isClosed()) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Rejecting connection or notifying that session is closed"
|
||||
+ ", controllerInfo=" + controllerInfo);
|
||||
|
||||
Reference in New Issue
Block a user