Use simple equality to compare media notif intents
Intent.filterEquals does not compare extra data included in intents,
which can lead to false positives for some apps, resulting in stale
intents being used
Flag: com.android.systemui.media_controls_posts_optimization
Bug: 369853463
Test: manual with affected apps
Test: MediaDataProcessorTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d52d5593647e945b172041df267fd53be2b2ab4f)
Merged-In: Ib037ece86cdd887ab0bb56b54648db7b73b42fab
Change-Id: Ib037ece86cdd887ab0bb56b54648db7b73b42fab
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaProcessingHelper.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaProcessingHelper.kt
index 55d7b1d..2bdee67 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaProcessingHelper.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaProcessingHelper.kt
@@ -42,7 +42,7 @@
context: Context,
newController: MediaController,
new: MediaData,
- old: MediaData?
+ old: MediaData?,
): Boolean {
if (old == null || !mediaControlsPostsOptimization()) return false
@@ -71,7 +71,7 @@
/** Returns whether actions lists are equal. */
fun areCustomActionListsEqual(
first: List<PlaybackState.CustomAction>?,
- second: List<PlaybackState.CustomAction>?
+ second: List<PlaybackState.CustomAction>?,
): Boolean {
// Same object, or both null
if (first === second) {
@@ -94,7 +94,7 @@
private fun areCustomActionsEqual(
firstAction: PlaybackState.CustomAction,
- secondAction: PlaybackState.CustomAction
+ secondAction: PlaybackState.CustomAction,
): Boolean {
if (
firstAction.action != secondAction.action ||
@@ -139,7 +139,7 @@
context: Context,
newController: MediaController,
new: MediaData,
- old: MediaData
+ old: MediaData,
): Boolean {
val oldState = MediaController(context, old.token!!).playbackState
return if (
@@ -150,8 +150,7 @@
var same = true
new.actions.asSequence().zip(old.actions.asSequence()).forEach {
if (
- it.first.actionIntent?.intent?.filterEquals(it.second.actionIntent?.intent) !=
- true ||
+ it.first.actionIntent?.intent != it.second.actionIntent?.intent ||
it.first.icon != it.second.icon ||
it.first.contentDescription != it.second.contentDescription
) {
@@ -164,7 +163,7 @@
oldState?.actions == newController.playbackState?.actions &&
areCustomActionListsEqual(
oldState?.customActions,
- newController.playbackState?.customActions
+ newController.playbackState?.customActions,
)
} else {
false
@@ -172,8 +171,5 @@
}
private fun areClickIntentsEqual(newIntent: PendingIntent?, oldIntent: PendingIntent?): Boolean {
- if ((newIntent == null && oldIntent == null) || newIntent === oldIntent) return true
- if (newIntent == null || oldIntent == null) return false
-
- return newIntent.intent?.filterEquals(oldIntent.intent) == true
+ return newIntent == oldIntent
}