Skip to content

Commit 6dd0c6d

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 dc5c1f9 commit 6dd0c6d

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
@@ -1674,7 +1674,10 @@ public void onAudioAttributesChanged(int seq, AudioAttributes audioAttributes) {
16741674
int playbackType = sessionImpl.getPlayerWrapper().getDeviceInfo().playbackType;
16751675
if (playbackType == DeviceInfo.PLAYBACK_TYPE_LOCAL) {
16761676
postOrRunForCompatSession(
1677-
() -> sessionCompat.setPlaybackToLocal(audioAttributes.getStreamType()));
1677+
() -> {
1678+
sessionCompat.setPlaybackToLocal(audioAttributes.getStreamType());
1679+
sessionImpl.onNotificationRefreshRequired();
1680+
});
16781681
}
16791682
}
16801683

@@ -1684,9 +1687,15 @@ public void onDeviceInfoChanged(int seq, DeviceInfo deviceInfo) {
16841687
volumeProviderCompat = createVolumeProviderCompat(player);
16851688
if (volumeProviderCompat == null) {
16861689
int streamType = player.getAudioAttributesWithCommandCheck().getStreamType();
1687-
postOrRunForCompatSession(() -> sessionCompat.setPlaybackToLocal(streamType));
1690+
postOrRunForCompatSession(() -> {
1691+
sessionCompat.setPlaybackToLocal(streamType);
1692+
sessionImpl.onNotificationRefreshRequired();
1693+
});
16881694
} else {
1689-
postOrRunForCompatSession(() -> sessionCompat.setPlaybackToRemote(volumeProviderCompat));
1695+
postOrRunForCompatSession(() -> {
1696+
sessionCompat.setPlaybackToRemote(volumeProviderCompat);
1697+
sessionImpl.onNotificationRefreshRequired();
1698+
});
16901699
}
16911700
}
16921701

0 commit comments

Comments
 (0)