mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00

The legacy custom layout doesn't support disabled buttons or buttons with non-custom actions. These are currently filtered out, but in inconsistent ways: - MediaControllerImplBase doesn't filter at all. - DefaultNotificationProvider filters before converting mediaButtonPreferences, PlayerWrapper filters after the conversion. - PlayerWrapper doesn't disable buttons that are unavailable. To ensure it's consistent, we can add these checks to the existing util method in CommandButton and also make sure PlayerWrapper disables unavailable buttons before triggering the util method. This also means we can simplify some of the tests that rely on the mediaButtonPreference to customLayout conversion in MediaController. This change also includes two bug fixes in PlayerWrapper that became evident in the tests: The extras need to be copied to avoid modifying a Bundle instance that be used elsewhere and we need to update the custom layout and potentially the session extras when the available commands change, as they depend on them. PiperOrigin-RevId: 704678404