mirror of
https://github.com/samsonjs/media.git
synced 2026-04-07 11:35:46 +00:00
Catch exceptions when retrieving current device from audio manager
We can just continue to assume that we don't know the current device.
This case happens on the latest Robolectric release where this method
call isn't implemented yet. As we not generally assume that the
method can throw, this workaround can be removed once Robolectric
is updated again.
#minor-release
PiperOrigin-RevId: 600426851
(cherry picked from commit 81615dd5b5)
This commit is contained in:
parent
05b8e633e3
commit
6632531c4a
1 changed files with 12 additions and 4 deletions
|
|
@ -486,10 +486,18 @@ public final class AudioCapabilities {
|
|||
@DoNotInline
|
||||
public static AudioDeviceInfoApi23 getDefaultRoutedDeviceForAttributes(
|
||||
AudioManager audioManager, AudioAttributes audioAttributes) {
|
||||
List<AudioDeviceInfo> audioDevices =
|
||||
checkNotNull(audioManager)
|
||||
.getAudioDevicesForAttributes(
|
||||
audioAttributes.getAudioAttributesV21().audioAttributes);
|
||||
List<AudioDeviceInfo> audioDevices;
|
||||
try {
|
||||
audioDevices =
|
||||
checkNotNull(audioManager)
|
||||
.getAudioDevicesForAttributes(
|
||||
audioAttributes.getAudioAttributesV21().audioAttributes);
|
||||
} catch (RuntimeException e) {
|
||||
// Audio manager failed to retrieve devices.
|
||||
// TODO: b/306324391 - Remove once https://github.com/robolectric/robolectric/commit/442dff
|
||||
// is released.
|
||||
return null;
|
||||
}
|
||||
if (audioDevices.isEmpty()) {
|
||||
// Can't find current device.
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue