Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a128a9f2 authored by Luca Stefani's avatar Luca Stefani
Browse files

Catch BadParcelableException when checking extras

The extras found in CustomAction are provided by user apps
when they want to add custom commands to the session with
extra information.

To avoid unneeded updates the actions compared to the
currently known actions, along with their extras,
but those may not have a Parcelable implementation
thus will fail to be un-parcelled.

Simply catch the exception when comparing the extras
as those aren't used anywhere else in code and only
sent back to the user-side session.

Test: m; media 3 app
Change-Id: I5f755d6a09266372ea724b08c97a11e3ca913569
parent 228ccb46
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Context
import android.graphics.drawable.Icon
import android.graphics.drawable.Icon
import android.media.session.MediaController
import android.media.session.MediaController
import android.media.session.PlaybackState
import android.media.session.PlaybackState
import android.os.BadParcelableException
import android.util.Log
import android.util.Log
import com.android.systemui.Flags.mediaControlsPostsOptimization
import com.android.systemui.Flags.mediaControlsPostsOptimization
import com.android.systemui.biometrics.Utils.toBitmap
import com.android.systemui.biometrics.Utils.toBitmap
@@ -109,9 +110,14 @@ private fun areCustomActionsEqual(
    }
    }
    if (firstAction.extras != null) {
    if (firstAction.extras != null) {
        firstAction.extras.keySet().forEach { key ->
        firstAction.extras.keySet().forEach { key ->
            try {
                if (firstAction.extras[key] != secondAction.extras[key]) {
                if (firstAction.extras[key] != secondAction.extras[key]) {
                    return false
                    return false
                }
                }
            } catch (e: BadParcelableException) {
                Log.e(TAG, "Cannot unparcel extras", e)
                return false
            }
        }
        }
    }
    }
    return true
    return true