From f476086114a56d214558f37b066849150a141390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Drobni=C4=8D?= Date: Fri, 29 Dec 2023 17:15:21 +0100 Subject: Check if volume boost effect is supported on the device (#6808) --- .../model/feed/VolumeAdaptionSetting.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'model/src') diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java b/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java index e71c5ad36..a9b1089f2 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java @@ -1,5 +1,10 @@ package de.danoeh.antennapod.model.feed; +import android.media.audiofx.AudioEffect; + +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; + public enum VolumeAdaptionSetting { OFF(0, 1.0f), LIGHT_REDUCTION(1, 0.5f), @@ -32,4 +37,29 @@ public enum VolumeAdaptionSetting { public float getAdaptionFactor() { return adaptionFactor; } + + @Nullable + private static Boolean boostSupported = null; + + public static boolean isBoostSupported() { + if (boostSupported != null) { + return boostSupported; + } + final AudioEffect.Descriptor[] audioEffects = AudioEffect.queryEffects(); + if (audioEffects != null) { + for (AudioEffect.Descriptor effect : audioEffects) { + if (effect.type.equals(AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER)) { + boostSupported = true; + return boostSupported; + } + } + } + boostSupported = false; + return boostSupported; + } + + @VisibleForTesting + public static void setBoostSupported(@Nullable Boolean boostSupported) { + VolumeAdaptionSetting.boostSupported = boostSupported; + } } -- cgit v1.2.3