Use the Oboe ADM for some custom roms

This commit is contained in:
Jim Gustafson 2024-08-26 16:57:39 -07:00 committed by Nicholas Tinsley
parent 659e36673b
commit 643f64e181
8 changed files with 60 additions and 15 deletions

View file

@ -17,7 +17,6 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.events.WebRtcViewModel
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.ringrtc.RemotePeer
import org.thoughtcrime.securesms.service.webrtc.RingRtcDynamicConfiguration.getAudioProcessingMethod
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState
import org.thoughtcrime.securesms.util.NetworkUtil
import java.io.IOException
@ -62,8 +61,8 @@ class CallLinkPreJoinActionProcessor(
callLink.credentials.adminPassBytes,
ByteArray(0),
AUDIO_LEVELS_INTERVAL,
getAudioProcessingMethod(),
SignalStore.internal.callingEnableOboeAdm(),
RingRtcDynamicConfiguration.getAudioProcessingMethod(),
RingRtcDynamicConfiguration.shouldUseOboeAdm(),
webRtcInteractor.groupCallObserver
)
} catch (e: InvalidInputException) {

View file

@ -53,7 +53,7 @@ public class GroupNetworkUnavailableActionProcessor extends WebRtcActionProcesso
new byte[0],
null,
RingRtcDynamicConfiguration.getAudioProcessingMethod(),
SignalStore.internal().callingEnableOboeAdm(),
RingRtcDynamicConfiguration.shouldUseOboeAdm(),
webRtcInteractor.getGroupCallObserver());
return currentState.builder()

View file

@ -51,7 +51,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
new byte[0],
AUDIO_LEVELS_INTERVAL,
RingRtcDynamicConfiguration.getAudioProcessingMethod(),
SignalStore.internal().callingEnableOboeAdm(),
RingRtcDynamicConfiguration.shouldUseOboeAdm(),
webRtcInteractor.getGroupCallObserver());
try {

View file

@ -102,7 +102,7 @@ public class IncomingCallActionProcessor extends DeviceAwareActionProcessor {
context,
videoState.getLockableEglBase().require(),
RingRtcDynamicConfiguration.getAudioProcessingMethod(),
SignalStore.internal().callingEnableOboeAdm(),
RingRtcDynamicConfiguration.shouldUseOboeAdm(),
videoState.requireLocalSink(),
callParticipant.getVideoSink(),
videoState.requireCamera(),

View file

@ -185,7 +185,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
new byte[0],
AUDIO_LEVELS_INTERVAL,
RingRtcDynamicConfiguration.getAudioProcessingMethod(),
SignalStore.internal().callingEnableOboeAdm(),
RingRtcDynamicConfiguration.shouldUseOboeAdm(),
webRtcInteractor.getGroupCallObserver());
try {

View file

@ -152,7 +152,7 @@ public class OutgoingCallActionProcessor extends DeviceAwareActionProcessor {
context,
videoState.getLockableEglBase().require(),
RingRtcDynamicConfiguration.getAudioProcessingMethod(),
SignalStore.internal().callingEnableOboeAdm(),
RingRtcDynamicConfiguration.shouldUseOboeAdm(),
videoState.requireLocalSink(),
callParticipant.getVideoSink(),
videoState.requireCamera(),

View file

@ -19,12 +19,19 @@ object RingRtcDynamicConfiguration {
return SignalStore.internal.callingAudioProcessingMethod()
}
return when {
isHardwareBlocklisted() || isKnownFaultyHardwareImplementation() -> AudioProcessingMethod.ForceSoftwareAec3
isSoftwareBlocklisted() -> AudioProcessingMethod.ForceHardware
Build.VERSION.SDK_INT < 29 && RemoteConfig.useHardwareAecIfOlderThanApi29 -> AudioProcessingMethod.ForceHardware
Build.VERSION.SDK_INT < 29 -> AudioProcessingMethod.ForceSoftwareAec3
else -> AudioProcessingMethod.ForceHardware
return if (shouldUseOboeAdm()) {
when {
shouldUseSoftwareAecForOboe() -> AudioProcessingMethod.ForceSoftwareAec3
else -> AudioProcessingMethod.ForceHardware
}
} else {
when {
isHardwareBlocklisted() || isKnownFaultyHardwareImplementation() -> AudioProcessingMethod.ForceSoftwareAec3
isSoftwareBlocklisted() -> AudioProcessingMethod.ForceHardware
Build.VERSION.SDK_INT < 29 && RemoteConfig.useHardwareAecIfOlderThanApi29 -> AudioProcessingMethod.ForceHardware
Build.VERSION.SDK_INT < 29 -> AudioProcessingMethod.ForceSoftwareAec3
else -> AudioProcessingMethod.ForceHardware
}
}
}
@ -37,7 +44,7 @@ object RingRtcDynamicConfiguration {
return RemoteConfig.hardwareAecBlocklistModels.asListContains(Build.MODEL)
}
fun isKnownFaultyHardwareImplementation(): Boolean {
private fun isKnownFaultyHardwareImplementation(): Boolean {
return Build.PRODUCT.contains(KNOWN_ISSUE_ROMS) ||
Build.DISPLAY.contains(KNOWN_ISSUE_ROMS) ||
Build.HOST.contains(KNOWN_ISSUE_ROMS)
@ -46,4 +53,22 @@ object RingRtcDynamicConfiguration {
private fun isSoftwareBlocklisted(): Boolean {
return RemoteConfig.softwareAecBlocklistModels.asListContains(Build.MODEL)
}
@JvmStatic
fun shouldUseOboeAdm(): Boolean {
if (RemoteConfig.internalUser) {
return SignalStore.internal.callingEnableOboeAdm()
}
// For now, only allow the Oboe ADM to be used for custom ROMS.
return RemoteConfig.oboeDeployment && isKnownFaultyHardwareImplementation() && !shouldUseJavaAdm()
}
private fun shouldUseJavaAdm(): Boolean {
return RemoteConfig.useJavaAdmModels.asListContains(Build.MODEL)
}
private fun shouldUseSoftwareAecForOboe(): Boolean {
return RemoteConfig.useSoftwareAecForOboeModels.asListContains(Build.MODEL)
}
}

View file

@ -716,6 +716,27 @@ object RemoteConfig {
hotSwappable = true
)
/** Whether the Oboe ADM should be used or not. */
val oboeDeployment: Boolean by remoteBoolean(
key = "android.calling.oboeDeployment",
defaultValue = false,
hotSwappable = false
)
/** A comma-separated list of models that should use the Java ADM instead of the Oboe ADM. */
val useJavaAdmModels: String by remoteString(
key = "android.calling.useJavaAdmList",
defaultValue = "",
hotSwappable = true
)
/** A comma-separated list of models that should use software AEC for calling with the Oboe ADM. */
val useSoftwareAecForOboeModels: String by remoteString(
key = "android.calling.useSoftwareAecForOboe",
defaultValue = "",
hotSwappable = true
)
/** A comma-separated list of manufacturers that *should* use Telecom for calling. */
val telecomManufacturerAllowList: String by remoteString(
key = "android.calling.telecomAllowList",