getting and setting audio devices on Android 14 when not integrated should go to fallback

This commit is contained in:
Daniel Gultsch 2024-04-20 10:51:31 +02:00
parent cfc22ba2af
commit ed2e0ab73c
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -139,7 +139,7 @@ public class CallIntegration extends Connection {
@Override @Override
public void onCallAudioStateChanged(final CallAudioState state) { public void onCallAudioStateChanged(final CallAudioState state) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { if (selfManaged() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
Log.d(Config.LOGTAG, "ignoring onCallAudioStateChange() on Upside Down Cake"); Log.d(Config.LOGTAG, "ignoring onCallAudioStateChange() on Upside Down Cake");
return; return;
} }
@ -148,36 +148,45 @@ public class CallIntegration extends Connection {
} }
public Set<AudioDevice> getAudioDevices() { public Set<AudioDevice> getAudioDevices() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { if (notSelfManaged(context)) {
return getAudioDevicesFallback();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
return getAudioDevicesUpsideDownCake(); return getAudioDevicesUpsideDownCake();
} else if (selfManaged()) { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return getAudioDevicesOreo(); return getAudioDevicesOreo();
} else { } else {
return getAudioDevicesFallback(); throw new AssertionError("Trying to get audio devices on unsupported version");
}
} }
} }
public AudioDevice getSelectedAudioDevice() { public AudioDevice getSelectedAudioDevice() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { if (notSelfManaged(context)) {
return getAudioDeviceFallback();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
return getAudioDeviceUpsideDownCake(); return getAudioDeviceUpsideDownCake();
} else if (selfManaged()) { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return getAudioDeviceOreo(); return getAudioDeviceOreo();
} else { } else {
return getAudioDeviceFallback(); throw new AssertionError(
"Trying to get selected audio device on unsupported version");
}
} }
} }
public void setAudioDevice(final AudioDevice audioDevice) { public void setAudioDevice(final AudioDevice audioDevice) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { if (notSelfManaged(context)) {
setAudioDeviceFallback(audioDevice);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
setAudioDeviceUpsideDownCake(audioDevice); setAudioDeviceUpsideDownCake(audioDevice);
} else if (selfManaged()) { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setAudioDeviceOreo(audioDevice); setAudioDeviceOreo(audioDevice);
} else { } else {
throw new AssertionError("Trying to set audio devices on unsupported version"); throw new AssertionError("Trying to set audio devices on unsupported version");
} }
} else {
setAudioDeviceFallback(audioDevice);
} }
} }