SamsungDAP: Add QS subtitle with profile name

Change-Id: I368c519ab2a76a4f4a3ba267c3f36a04f4690464
tirimbino
LuK1337 3 years ago
parent c7de29af9e
commit 577494c66a
  1. 18
      dap/src/org/lineageos/dap/DolbyCore.kt
  2. 1
      dap/src/org/lineageos/dap/DolbyTile.kt

@ -16,8 +16,11 @@
package org.lineageos.dap package org.lineageos.dap
import android.content.Context
import android.media.audiofx.AudioEffect import android.media.audiofx.AudioEffect
import org.lineageos.dap.DolbyFragment.Companion.PREF_DOLBY_MODES
import java.util.UUID import java.util.UUID
object DolbyCore { object DolbyCore {
@ -40,6 +43,21 @@ object DolbyCore {
AudioEffect(EFFECT_TYPE_DAP, AudioEffect.EFFECT_TYPE_NULL, 0, 0) AudioEffect(EFFECT_TYPE_DAP, AudioEffect.EFFECT_TYPE_NULL, 0, 0)
}.getOrNull() }.getOrNull()
fun getProfile(): Int {
val out = intArrayOf(PROFILE_AUTO)
audioEffect?.getParameter(EFFECT_PARAM_PROFILE, out)
return out.first()
}
fun getProfileName(context: Context): String {
val profile = getProfile()
val resourceName = PREF_DOLBY_MODES.filter { it.value == profile }.keys.first()
return context.resources.getString(context.resources.getIdentifier(
resourceName, "string", context.packageName
))
}
fun setProfile(profile: Int) { fun setProfile(profile: Int) {
audioEffect?.setParameter(EFFECT_PARAM_EFF_ENAB, 1) audioEffect?.setParameter(EFFECT_PARAM_EFF_ENAB, 1)
audioEffect?.setParameter(EFFECT_PARAM_PROFILE, profile) audioEffect?.setParameter(EFFECT_PARAM_PROFILE, profile)

@ -28,6 +28,7 @@ class DolbyTile : TileService() {
set(value) { set(value) {
field = value field = value
qsTile.state = if (value) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE qsTile.state = if (value) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE
qsTile.subtitle = DolbyCore.getProfileName(this)
qsTile.updateTile() qsTile.updateTile()
} }

Loading…
Cancel
Save