From 5223d086bc60601517049b29a5ede7069e917343 Mon Sep 17 00:00:00 2001
From: birdbird <6892457-tzugen@users.noreply.gitlab.com>
Date: Fri, 28 Oct 2022 09:49:22 +0000
Subject: [PATCH] Fix a small deprecation notice

---
 .../ultrasonic/receiver/MediaButtonIntentReceiver.kt   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/receiver/MediaButtonIntentReceiver.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/receiver/MediaButtonIntentReceiver.kt
index ec2dd114..6e40062f 100644
--- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/receiver/MediaButtonIntentReceiver.kt
+++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/receiver/MediaButtonIntentReceiver.kt
@@ -10,6 +10,7 @@ package org.moire.ultrasonic.receiver
 import android.content.BroadcastReceiver
 import android.content.Context
 import android.content.Intent
+import android.os.Build
 import android.os.Parcelable
 import java.lang.Exception
 import org.koin.core.component.KoinComponent
@@ -36,7 +37,14 @@ class MediaButtonIntentReceiver : BroadcastReceiver(), KoinComponent {
             Constants.CMD_PROCESS_KEYCODE != intentAction
         ) return
         val extras = intent.extras ?: return
-        val event = extras[Intent.EXTRA_KEY_EVENT] as Parcelable?
+
+        val event = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+            extras.getParcelable(Intent.EXTRA_KEY_EVENT, Parcelable::class.java)
+        } else {
+            @Suppress("DEPRECATION")
+            extras.get(Intent.EXTRA_KEY_EVENT) as Parcelable?
+        }
+
         Timber.i("Got MEDIA_BUTTON key event: %s", event)
         try {
             val serviceIntent = Intent(Constants.CMD_PROCESS_KEYCODE)