Skip to content

Commit 1a2b650

Browse files
committed
Update notification when device info changes
Device info determines whether we have cast or normal media notification. It decides whether we can enable playback resumption. To ensure the state is correct, notify SystemUI when device info changed.
1 parent a9fff38 commit 1a2b650

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libraries/session/src/main/java/androidx/media3/session/MediaSessionLegacyStub.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,10 @@ public void onAudioAttributesChanged(int seq, AudioAttributes audioAttributes) {
16731673
int playbackType = sessionImpl.getPlayerWrapper().getDeviceInfo().playbackType;
16741674
if (playbackType == DeviceInfo.PLAYBACK_TYPE_LOCAL) {
16751675
postOrRunForCompatSession(
1676-
() -> sessionCompat.setPlaybackToLocal(audioAttributes.getStreamType()));
1676+
() -> {
1677+
sessionCompat.setPlaybackToLocal(audioAttributes.getStreamType());
1678+
sessionImpl.onNotificationRefreshRequired();
1679+
});
16771680
}
16781681
}
16791682

@@ -1683,9 +1686,15 @@ public void onDeviceInfoChanged(int seq, DeviceInfo deviceInfo) {
16831686
volumeProviderCompat = createVolumeProviderCompat(player);
16841687
if (volumeProviderCompat == null) {
16851688
int streamType = player.getAudioAttributesWithCommandCheck().getStreamType();
1686-
postOrRunForCompatSession(() -> sessionCompat.setPlaybackToLocal(streamType));
1689+
postOrRunForCompatSession(() -> {
1690+
sessionCompat.setPlaybackToLocal(streamType);
1691+
sessionImpl.onNotificationRefreshRequired();
1692+
});
16871693
} else {
1688-
postOrRunForCompatSession(() -> sessionCompat.setPlaybackToRemote(volumeProviderCompat));
1694+
postOrRunForCompatSession(() -> {
1695+
sessionCompat.setPlaybackToRemote(volumeProviderCompat);
1696+
sessionImpl.onNotificationRefreshRequired();
1697+
});
16891698
}
16901699
}
16911700

0 commit comments

Comments
 (0)