Loading android/app/src/com/android/bluetooth/mcp/MediaControlProfile.java +8 −5 Original line number Diff line number Diff line Loading @@ -345,13 +345,15 @@ public class MediaControlProfile implements MediaControlServiceCallbacks { long actions = mCurrentData.state.getActions(); switch (request.getOpcode()) { case Request.Opcodes.PLAY: if ((actions & PlaybackState.ACTION_PLAY) != 0) { if ((actions & PlaybackState.ACTION_PLAY) != 0 || (actions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { mMediaPlayerList.getActivePlayer().playCurrent(); status = Request.Results.SUCCESS; } break; case Request.Opcodes.PAUSE: if ((actions & PlaybackState.ACTION_PAUSE) != 0) { if ((actions & PlaybackState.ACTION_PAUSE) != 0 || (actions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { // Notice: Pause may function as Pause/Play toggle switch when triggered on // a Media Player which is already in Paused state. if (mCurrentData.state.getState() != PlaybackState.STATE_PAUSED) { Loading Loading @@ -465,11 +467,13 @@ public class MediaControlProfile implements MediaControlServiceCallbacks { opcodesSupported |= Request.SupportedOpcodes.STOP; } if ((supportedPlayerActions & PlaybackState.ACTION_PAUSE) != 0) { if ((supportedPlayerActions & PlaybackState.ACTION_PAUSE) != 0 || (supportedPlayerActions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { opcodesSupported |= Request.SupportedOpcodes.PAUSE; } if ((supportedPlayerActions & PlaybackState.ACTION_PLAY) != 0) { if ((supportedPlayerActions & PlaybackState.ACTION_PLAY) != 0 || (supportedPlayerActions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { opcodesSupported |= Request.SupportedOpcodes.PLAY; } Loading @@ -495,7 +499,6 @@ public class MediaControlProfile implements MediaControlServiceCallbacks { // This Android media session actions can't be mapped to LE Audio: // PlaybackState.ACTION_SET_RATING // PlaybackState.ACTION_PLAY_PAUSE // PlaybackState.ACTION_PLAY_FROM_MEDIA_ID // PlaybackState.ACTION_PLAY_FROM_SEARCH // PlaybackState.ACTION_SKIP_TO_QUEUE_ITEM Loading android/app/tests/unit/src/com/android/bluetooth/mcp/MediaControlProfileTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -368,6 +368,20 @@ public class MediaControlProfileTest { Request.Opcodes.MOVE_RELATIVE, 100); mMcpServiceCallbacks.onMediaControlRequest(request); verify(mMockMediaPlayerWrapper, timeout(100)).seekTo(duration); // Verify toggle-style play/pause control support clearInvocations(mMockMediaPlayerWrapper); actions = PlaybackState.ACTION_PLAY_PAUSE; bob = new PlaybackState.Builder(mMockMediaData.state); bob.setActions(actions); mMockMediaData.state = bob.build(); request = new Request(Request.Opcodes.PLAY, 0); mMcpServiceCallbacks.onMediaControlRequest(request); verify(mMockMediaPlayerWrapper, timeout(100)).playCurrent(); request = new Request(Request.Opcodes.PAUSE, 0); mMcpServiceCallbacks.onMediaControlRequest(request); verify(mMockMediaPlayerWrapper, timeout(100)).pauseCurrent(); } @Test Loading @@ -387,6 +401,14 @@ public class MediaControlProfileTest { Assert.assertEquals( mMediaControlProfile.playerActions2McsSupportedOpcodes(actions), opcodes_supported); // Verify toggle-style play/pause control support actions = PlaybackState.ACTION_PLAY_PAUSE; opcodes_supported = Request.SupportedOpcodes.PAUSE | Request.SupportedOpcodes.PLAY; Assert.assertEquals( mMediaControlProfile.playerActions2McsSupportedOpcodes(actions), opcodes_supported); } @Test Loading Loading
android/app/src/com/android/bluetooth/mcp/MediaControlProfile.java +8 −5 Original line number Diff line number Diff line Loading @@ -345,13 +345,15 @@ public class MediaControlProfile implements MediaControlServiceCallbacks { long actions = mCurrentData.state.getActions(); switch (request.getOpcode()) { case Request.Opcodes.PLAY: if ((actions & PlaybackState.ACTION_PLAY) != 0) { if ((actions & PlaybackState.ACTION_PLAY) != 0 || (actions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { mMediaPlayerList.getActivePlayer().playCurrent(); status = Request.Results.SUCCESS; } break; case Request.Opcodes.PAUSE: if ((actions & PlaybackState.ACTION_PAUSE) != 0) { if ((actions & PlaybackState.ACTION_PAUSE) != 0 || (actions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { // Notice: Pause may function as Pause/Play toggle switch when triggered on // a Media Player which is already in Paused state. if (mCurrentData.state.getState() != PlaybackState.STATE_PAUSED) { Loading Loading @@ -465,11 +467,13 @@ public class MediaControlProfile implements MediaControlServiceCallbacks { opcodesSupported |= Request.SupportedOpcodes.STOP; } if ((supportedPlayerActions & PlaybackState.ACTION_PAUSE) != 0) { if ((supportedPlayerActions & PlaybackState.ACTION_PAUSE) != 0 || (supportedPlayerActions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { opcodesSupported |= Request.SupportedOpcodes.PAUSE; } if ((supportedPlayerActions & PlaybackState.ACTION_PLAY) != 0) { if ((supportedPlayerActions & PlaybackState.ACTION_PLAY) != 0 || (supportedPlayerActions & PlaybackState.ACTION_PLAY_PAUSE) != 0) { opcodesSupported |= Request.SupportedOpcodes.PLAY; } Loading @@ -495,7 +499,6 @@ public class MediaControlProfile implements MediaControlServiceCallbacks { // This Android media session actions can't be mapped to LE Audio: // PlaybackState.ACTION_SET_RATING // PlaybackState.ACTION_PLAY_PAUSE // PlaybackState.ACTION_PLAY_FROM_MEDIA_ID // PlaybackState.ACTION_PLAY_FROM_SEARCH // PlaybackState.ACTION_SKIP_TO_QUEUE_ITEM Loading
android/app/tests/unit/src/com/android/bluetooth/mcp/MediaControlProfileTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -368,6 +368,20 @@ public class MediaControlProfileTest { Request.Opcodes.MOVE_RELATIVE, 100); mMcpServiceCallbacks.onMediaControlRequest(request); verify(mMockMediaPlayerWrapper, timeout(100)).seekTo(duration); // Verify toggle-style play/pause control support clearInvocations(mMockMediaPlayerWrapper); actions = PlaybackState.ACTION_PLAY_PAUSE; bob = new PlaybackState.Builder(mMockMediaData.state); bob.setActions(actions); mMockMediaData.state = bob.build(); request = new Request(Request.Opcodes.PLAY, 0); mMcpServiceCallbacks.onMediaControlRequest(request); verify(mMockMediaPlayerWrapper, timeout(100)).playCurrent(); request = new Request(Request.Opcodes.PAUSE, 0); mMcpServiceCallbacks.onMediaControlRequest(request); verify(mMockMediaPlayerWrapper, timeout(100)).pauseCurrent(); } @Test Loading @@ -387,6 +401,14 @@ public class MediaControlProfileTest { Assert.assertEquals( mMediaControlProfile.playerActions2McsSupportedOpcodes(actions), opcodes_supported); // Verify toggle-style play/pause control support actions = PlaybackState.ACTION_PLAY_PAUSE; opcodes_supported = Request.SupportedOpcodes.PAUSE | Request.SupportedOpcodes.PLAY; Assert.assertEquals( mMediaControlProfile.playerActions2McsSupportedOpcodes(actions), opcodes_supported); } @Test Loading