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,
) {
fun provideVoiceRecorder(): VoiceRecorder {
return if (useFallbackRecorder()) {
VoiceRecorderL(context, Dispatchers.IO)
} else {
return if (useNativeRecorder()) {
VoiceRecorderQ(context)
} else {
VoiceRecorderL(context, Dispatchers.IO)
}
}
@ChecksSdkIntAtLeast(api = 29)
private fun useFallbackRecorder(): Boolean {
return buildVersionSdkIntProvider.get() < Build.VERSION_CODES.Q ||
!hasOpusEncoder() ||
vectorFeatures.forceUsageOfOpusEncoder()
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.Q)
private fun useNativeRecorder(): Boolean {
return buildVersionSdkIntProvider.get() >= Build.VERSION_CODES.Q &&
hasOpusEncoder() &&
!vectorFeatures.forceUsageOfOpusEncoder()
}
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)