Session tests: Log when no controllers are connected

While debugging various session tests failure I found that sometimes
this list was empty (e.g. when a controller had failed to connect, or
hadn't finished connecting yet) - resulting in these methods being
silent no-ops. I think it's basically never expected for there to be no
controllers connected when these methods are invoked, so this logs at
ERROR level to give a clue of what happened when looking at the test
logcat.

PiperOrigin-RevId: 564750969
This commit is contained in:
ibaker 2023-09-12 09:49:21 -07:00 committed by Copybara-Service
parent e2882c051b
commit 320a45f7d6

View file

@ -454,6 +454,11 @@ public class MediaSessionProviderService extends Service {
() -> {
MediaSession session = sessionMap.get(sessionId);
List<ControllerInfo> controllerInfos = MediaTestUtils.getTestControllerInfos(session);
if (controllerInfos.isEmpty()) {
Log.e(
TAG,
"No connected controllers to receive custom command. sessionId=" + sessionId);
}
for (ControllerInfo info : controllerInfos) {
session.sendCustomCommand(info, SessionCommand.CREATOR.fromBundle(command), args);
}
@ -476,6 +481,11 @@ public class MediaSessionProviderService extends Service {
() -> {
MediaSession session = sessionMap.get(sessionId);
List<ControllerInfo> controllerInfos = MediaTestUtils.getTestControllerInfos(session);
if (controllerInfos.isEmpty()) {
Log.e(
TAG,
"No connected controllers to receive available commands. sessionId=" + sessionId);
}
for (ControllerInfo info : controllerInfos) {
session.setAvailableCommands(
info,