diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-04-09 22:33:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 22:33:52 +0200 |
commit | d9e84f8c38d9f867074713618d90a765ef6db995 (patch) | |
tree | 2bd7673309f49c8b032869b1e91e4e13338def51 /playback | |
parent | bd4e9e19d732de045260fcd7fd2870421f0a4d19 (diff) | |
download | AntennaPod-d9e84f8c38d9f867074713618d90a765ef6db995.zip |
Target SDK 34 (#7075)
Diffstat (limited to 'playback')
3 files changed, 14 insertions, 7 deletions
diff --git a/playback/service/src/main/AndroidManifest.xml b/playback/service/src/main/AndroidManifest.xml index 62ab1094e..d5aa49978 100644 --- a/playback/service/src/main/AndroidManifest.xml +++ b/playback/service/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> + <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> <application android:allowBackup="true" diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java index cfd494ba2..4a6ebbad2 100644 --- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java +++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackController.java @@ -12,6 +12,7 @@ import android.util.Log; import android.util.Pair; import android.view.SurfaceHolder; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.DBWriter; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; @@ -83,10 +84,10 @@ public abstract class PlaybackController { } initialized = true; - activity.registerReceiver(statusUpdate, new IntentFilter( - PlaybackService.ACTION_PLAYER_STATUS_CHANGED)); - activity.registerReceiver(notificationReceiver, new IntentFilter( - PlaybackServiceInterface.ACTION_PLAYER_NOTIFICATION)); + ContextCompat.registerReceiver(activity, statusUpdate, new IntentFilter( + PlaybackService.ACTION_PLAYER_STATUS_CHANGED), ContextCompat.RECEIVER_NOT_EXPORTED); + ContextCompat.registerReceiver(activity, notificationReceiver, new IntentFilter( + PlaybackServiceInterface.ACTION_PLAYER_NOTIFICATION), ContextCompat.RECEIVER_NOT_EXPORTED); if (!released) { bindToService(); diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java index 0f3d06b00..7f213a598 100644 --- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java +++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/PlaybackService.java @@ -228,9 +228,12 @@ public class PlaybackService extends MediaBrowserServiceCompat { stateManager = new PlaybackServiceStateManager(this); notificationBuilder = new PlaybackServiceNotificationBuilder(this); - registerReceiver(autoStateUpdated, new IntentFilter("com.google.android.gms.car.media.STATUS")); + ContextCompat.registerReceiver(this, autoStateUpdated, + new IntentFilter("com.google.android.gms.car.media.STATUS"), ContextCompat.RECEIVER_EXPORTED); + ContextCompat.registerReceiver(this, shutdownReceiver, + new IntentFilter(PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE), + ContextCompat.RECEIVER_NOT_EXPORTED); registerReceiver(headsetDisconnected, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); - registerReceiver(shutdownReceiver, new IntentFilter(PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE)); registerReceiver(bluetoothStateUpdated, new IntentFilter(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)); registerReceiver(audioBecomingNoisy, new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY)); EventBus.getDefault().register(this); @@ -1609,8 +1612,10 @@ public class PlaybackService extends MediaBrowserServiceCompat { @Override public void onReceive(Context context, Intent intent) { if (TextUtils.equals(intent.getAction(), PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE)) { - EventBus.getDefault().post(new PlaybackServiceEvent(PlaybackServiceEvent.Action.SERVICE_SHUT_DOWN)); stateManager.stopService(); + PlaybackPreferences.writeNoMediaPlaying(); + EventBus.getDefault().post(new PlaybackServiceEvent(PlaybackServiceEvent.Action.SERVICE_SHUT_DOWN)); + EventBus.getDefault().post(new PlayerStatusEvent()); } } |