diff --git a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java index e04f05524c..4a2404e260 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java +++ b/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java @@ -81,8 +81,6 @@ import org.webrtc.voiceengine.WebRtcAudioUtils; import org.whispersystems.libsignal.logging.SignalProtocolLoggerProvider; import java.security.Security; -import java.util.HashSet; -import java.util.Set; import java.util.concurrent.TimeUnit; /** @@ -322,31 +320,11 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr private void initializeRingRtc() { try { - Set HARDWARE_AEC_BLACKLIST = new HashSet() {{ - add("Pixel"); - add("Pixel XL"); - add("Moto G5"); - add("Moto G (5S) Plus"); - add("Moto G4"); - add("TA-1053"); - add("Mi A1"); - add("Mi A2"); - add("E5823"); // Sony z5 compact - add("Redmi Note 5"); - add("FP2"); // Fairphone FP2 - add("MI 5"); - }}; - - Set OPEN_SL_ES_WHITELIST = new HashSet() {{ - add("Pixel"); - add("Pixel XL"); - }}; - - if (HARDWARE_AEC_BLACKLIST.contains(Build.MODEL)) { + if (RtcDeviceLists.hardwareAECBlocked()) { WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true); } - if (!OPEN_SL_ES_WHITELIST.contains(Build.MODEL)) { + if (!RtcDeviceLists.openSLESAllowed()) { WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/RtcDeviceLists.java b/app/src/main/java/org/thoughtcrime/securesms/RtcDeviceLists.java new file mode 100644 index 0000000000..e7e6bf9e15 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/RtcDeviceLists.java @@ -0,0 +1,48 @@ +package org.thoughtcrime.securesms; + +import android.os.Build; + +import java.util.HashSet; +import java.util.Set; + +/** + * Device hardware capability lists. + *

+ * Moved outside of ApplicationContext as the indirection was important for API19 support with desugaring: https://issuetracker.google.com/issues/183419297 + */ +final class RtcDeviceLists { + + private RtcDeviceLists() {} + + static Set hardwareAECBlockList() { + return new HashSet() {{ + add("Pixel"); + add("Pixel XL"); + add("Moto G5"); + add("Moto G (5S) Plus"); + add("Moto G4"); + add("TA-1053"); + add("Mi A1"); + add("Mi A2"); + add("E5823"); // Sony z5 compact + add("Redmi Note 5"); + add("FP2"); // Fairphone FP2 + add("MI 5"); + }}; + } + + static Set openSlEsAllowList() { + return new HashSet() {{ + add("Pixel"); + add("Pixel XL"); + }}; + } + + static boolean hardwareAECBlocked() { + return hardwareAECBlockList().contains(Build.MODEL); + } + + static boolean openSLESAllowed() { + return openSlEsAllowList().contains(Build.MODEL); + } +}