Turning on Bluetooth crashes app when "Detect headset" toggled on
Description
When the Detect headset option under Audio settings is toggled on, and the app is not open (removed from Recents or never opened after restarting device), turning Bluetooth on causes a crash. I'm somewhat certain this was introduced in 3.5.3, as I would have noticed such a crash on 3.5.2 or earlier.
If the app is open in the foreground, the crash doesn't occur, and this seems to match what the log says.
Logs
FATAL EXCEPTION: main
Process: org.videolan.vlc, PID: 28831
java.lang.RuntimeException: Unable to create service org.videolan.vlc.MediaParsingService: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service org.videolan.vlc/.MediaParsingService
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4567)
at android.app.ActivityThread.access$1700(ActivityThread.java:256)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2110)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7870)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service org.videolan.vlc/.MediaParsingService
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelable(Parcel.java:3334)
at android.os.Parcel.createExceptionOrNull(Parcel.java:2421)
at android.os.Parcel.createException(Parcel.java:2410)
at android.os.Parcel.readException(Parcel.java:2393)
at android.os.Parcel.readException(Parcel.java:2335)
at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7158)
at android.app.Service.startForeground(Service.java:736)
at org.videolan.vlc.MediaParsingService.forceForeground(MediaParsingService.kt:203)
at org.videolan.vlc.MediaParsingService.onCreate(MediaParsingService.kt:126)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:4554)
... 9 more