Reverse condition for code clarity with `ChecksSdkIntAtLeast`

This commit is contained in:
Benoit Marty 2022-09-16 17:35:26 +02:00 committed by Benoit Marty
parent 0910b118ff
commit 5886245bbf
1 changed files with 8 additions and 8 deletions

View File

@ -33,18 +33,18 @@ class VoiceRecorderProvider @Inject constructor(
private val buildVersionSdkIntProvider: BuildVersionSdkIntProvider, private val buildVersionSdkIntProvider: BuildVersionSdkIntProvider,
) { ) {
fun provideVoiceRecorder(): VoiceRecorder { fun provideVoiceRecorder(): VoiceRecorder {
return if (useFallbackRecorder()) { return if (useNativeRecorder()) {
VoiceRecorderL(context, Dispatchers.IO)
} else {
VoiceRecorderQ(context) VoiceRecorderQ(context)
} else {
VoiceRecorderL(context, Dispatchers.IO)
} }
} }
@ChecksSdkIntAtLeast(api = 29) @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.Q)
private fun useFallbackRecorder(): Boolean { private fun useNativeRecorder(): Boolean {
return buildVersionSdkIntProvider.get() < Build.VERSION_CODES.Q || return buildVersionSdkIntProvider.get() >= Build.VERSION_CODES.Q &&
!hasOpusEncoder() || hasOpusEncoder() &&
vectorFeatures.forceUsageOfOpusEncoder() !vectorFeatures.forceUsageOfOpusEncoder()
} }
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)