Blocklist not working spotify custom actions
This commit is contained in:
parent
7dbe9d4d6f
commit
336be61521
@ -396,7 +396,7 @@ internal class MusicServiceImpl(
|
|||||||
send(SupportedActions())
|
send(SupportedActions())
|
||||||
return@collectLatest
|
return@collectLatest
|
||||||
}
|
}
|
||||||
send(SupportedActions(state.actions, state.customActions))
|
send(SupportedActions(lastPlayerPackage, state.actions, state.customActions))
|
||||||
}
|
}
|
||||||
}.shareIn(scope, SharingStarted.WhileSubscribed(), 1)
|
}.shareIn(scope, SharingStarted.WhileSubscribed(), 1)
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,6 @@ package de.mm20.launcher2.music
|
|||||||
|
|
||||||
import android.media.session.PlaybackState
|
import android.media.session.PlaybackState
|
||||||
import android.media.session.PlaybackState.CustomAction
|
import android.media.session.PlaybackState.CustomAction
|
||||||
import android.os.Bundle
|
|
||||||
import android.util.Log
|
|
||||||
|
|
||||||
data class SupportedActions(
|
data class SupportedActions(
|
||||||
val stop: Boolean = false,
|
val stop: Boolean = false,
|
||||||
@ -16,7 +14,7 @@ data class SupportedActions(
|
|||||||
val setRating: Boolean = false,
|
val setRating: Boolean = false,
|
||||||
val customActions: List<CustomAction> = emptyList()
|
val customActions: List<CustomAction> = emptyList()
|
||||||
) {
|
) {
|
||||||
constructor(actions: Long?, customActions: List<CustomAction>?) : this(
|
constructor(playerPackege: String?, actions: Long?, customActions: List<CustomAction>?) : this(
|
||||||
stop = actions?.and(PlaybackState.ACTION_STOP) == PlaybackState.ACTION_STOP,
|
stop = actions?.and(PlaybackState.ACTION_STOP) == PlaybackState.ACTION_STOP,
|
||||||
skipToNext = actions?.and(PlaybackState.ACTION_SKIP_TO_NEXT) == PlaybackState.ACTION_SKIP_TO_NEXT,
|
skipToNext = actions?.and(PlaybackState.ACTION_SKIP_TO_NEXT) == PlaybackState.ACTION_SKIP_TO_NEXT,
|
||||||
skipToPrevious = actions?.and(PlaybackState.ACTION_SKIP_TO_PREVIOUS) == PlaybackState.ACTION_SKIP_TO_PREVIOUS,
|
skipToPrevious = actions?.and(PlaybackState.ACTION_SKIP_TO_PREVIOUS) == PlaybackState.ACTION_SKIP_TO_PREVIOUS,
|
||||||
@ -25,15 +23,12 @@ data class SupportedActions(
|
|||||||
seekTo = actions?.and(PlaybackState.ACTION_SEEK_TO) == PlaybackState.ACTION_SEEK_TO,
|
seekTo = actions?.and(PlaybackState.ACTION_SEEK_TO) == PlaybackState.ACTION_SEEK_TO,
|
||||||
setPlaybackSpeed = actions?.and(PlaybackState.ACTION_SET_PLAYBACK_SPEED) == PlaybackState.ACTION_SET_PLAYBACK_SPEED,
|
setPlaybackSpeed = actions?.and(PlaybackState.ACTION_SET_PLAYBACK_SPEED) == PlaybackState.ACTION_SET_PLAYBACK_SPEED,
|
||||||
setRating = actions?.and(PlaybackState.ACTION_SET_RATING) == PlaybackState.ACTION_SET_RATING,
|
setRating = actions?.and(PlaybackState.ACTION_SET_RATING) == PlaybackState.ACTION_SET_RATING,
|
||||||
customActions = customActions ?: emptyList(),
|
customActions = customActions?.filter {
|
||||||
) {
|
// Most of Spotify's custom actions are known to be broken, blocklist them in release builds
|
||||||
for (action in customActions ?: emptyList()) {
|
if (!BuildConfig.DEBUG && playerPackege == "com.spotify.music") {
|
||||||
Log.d("MM20", action.action.toString())
|
return@filter (it.action == "REMOVE_FROM_COLLECTION" || it.action == "ADD_TO_COLLECTION")
|
||||||
val extras = action.extras ?: Bundle.EMPTY
|
|
||||||
val keySet = extras.keySet()
|
|
||||||
for (key in keySet) {
|
|
||||||
Log.d("MM20", "$key: ${extras.get(key)}")
|
|
||||||
}
|
}
|
||||||
}
|
true
|
||||||
}
|
} ?: emptyList(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user