How can my car launch apps on my phone via Bluetooth?

cpk0

Ars Tribunus Militum
2,367
Subscriptor++
I've never done any development work with Bluetooth devices, and don't plan to, so this is a question purely of academic curiosity.

My car (an older BMW) exhibits very strange behavior in how it interacts with my phone (an iPhone 15 Pro). I'm happy to bore people with details, but I have one fundamental question I haven't been able to figure out:

When the phone connects to the car, sometimes it will start playing music through the Apple Music app, even though Apple Music wasn't previously running (or even suspended) and there was audio from another app (e.g., Pocket Casts) already playing. How is the car's infotainment system able to launch an app on the phone?

So far my best guess is that there's a normal, generic "begin playback" call that the BT device can make, which every other BT device on the planet would make and would work as expected. And also some sort of "begin music playback" call that the car is making (sometimes?), which the phone gets and thinks it needs to handle using the Apple Music app, so the phone is launching the app (i.e., the car itself isn't directly making the decision to launch the app). I've never seen any other BT audio device cause this to happen, and I can't find any BT reference that discusses two different flavors of start-playback API call (though I'm finding it hard to track down good docs talking about the car hardware side of this equation). This behavior also doesn't happen consistently.

I know the whole the-first-song-alphabetically-in-your-library-starts-playing thing is very common, usually when there's nothing loaded in the OS's media manager; this is not that. This will replace what's already in the media manager, and generally start playing the last thing that was playing in Apple Music when it was previously running.

I'm ready to blame iOS for this, since the behavior has been consistent across a number of iPhones. But this is behavior that I've never experienced connecting any other BT audio device to any iPhone, so there's something fairly unique about the particular interaction between the car and the phone to cause it to happen. I used to make audio-based iPhone apps; it's been a while but there's nothing in the archives of my brain that help explain this. In fact, my memory is that there's pretty limited abilities for what an external device can request to do in terms of media control in iOS.

I know I can't fix it, but the programmer inside me really wants to be able to explain this.
 

Paladin

Ars Legatus Legionis
32,552
Subscriptor
From what I have seen in various apps, it's not that the car is launching an app or doing anything really. The phone makes a bluetooth connection to what it sees as a big speaker and whatever app is installed on the phone sees that a previously used speaker has reconnected and the app resumes playing audio according to its preferences.

In the world of Android apps, you can go into the settings in the app itself and tell it what to do on the connection event of various things (headphone, bluetooth speaker/headphones, etc.) as well as resume actions after a call, notification interruption, etc.

Basically the phone does whatever it and its apps are configured to do when a bluetooth audio output is reconnected. The car is likely not doing anything.
 

Genome

Ars Tribunus Angusticlavius
9,202
I'm ready to blame iOS for this
And you’re right. This is iOS finding a Bluetooth device capable of playing music and randomly deciding that this device needs to be fed by Apple Music. Happens on my iPhone now and then when I have Music installed.

This also happens on macOS with headphones and is frequently the bane of my existence.

It’s some sort of bug - but since it drives people to Apple Music, Apple seems to consider it a feature and haven’t solved it yet.
 

Mechjaz

Ars Tribunus Militum
2,159
Subscriptor++
Funnily enough, this isn't the first ride on this particular rodeo: https://arstechnica.com/civis/threa...triggered-by-bluetooth-audio-devices.1495695/

My truck's head unit doesn't know whether to shit or go blind when my phone connects; I've observed that (very) roughly, if it was VLC, it's resume playing 2 out of 5 times. If the last thing playing was Apple Music, it's more like 1 out of 3. I suspect but haven't tested that there's some kind of statefulness with power cycling the head unit; a stop for gas doesn't seem to bother it, but driving to a destination and leaving it off for hours turns it into the aforementioned crapshoot.

Bluetooth still sucks.
 

cpk0

Ars Tribunus Militum
2,367
Subscriptor++
I want to believe everyone saying it's purely an OS/iOS issue, and I can definitely see that being where all the (bad) logic is happening, but there still seems to be something particular about the interaction between the car and the phone. Maybe it's something specific about how the connection is being made? Or some type of device class where "cars" are treated different than "speakers"? I just feel like if it were so cut-and-dry, my phone would behave this way, or at least in a similar way, in every car, but literally no other car or speaker shows this behavior.

And it's hard to miss. One of the very common behaviors I experience is having a podcast loaded up in Pocket Casts, which I run at 2x playback speed (don't at me), and after connecting to the car it will switch to Apple Music and play back somewhere around 10-20x speed. It will play an entire song every few seconds. So aside from how insane and hilarious that is, I mention it only to say it's very obvious when it happens. And in the countless other cars/speakers/etc I've connected my phones to, no other device has ever done that.

So even if it is 100% an iOS bug, it's not just a general BT bug, and I'd still love to know what weird thing the BMW is doing to make the already sucky world of Bluetooth even suckier.
 

continuum

Ars Legatus Legionis
94,897
Moderator
I want to believe everyone saying it's purely an OS/iOS issue, and I can definitely see that being where all the (bad) logic is happening, but there still seems to be something particular about the interaction between the car and the phone. Maybe it's something specific about how the connection is being made? Or some type of device class where "cars" are treated different than "speakers"? I just feel like if it were so cut-and-dry, my phone would behave this way, or at least in a similar way, in every car, but literally no other car or speaker shows this behavior.
Hard to fully rule out something dumb on the car headunit's end. Anything reported in the various BMW forums/reddit groups/Facebook groups?

I say this as someone who has spent time driving dozens of different vehicles the past few years so am quite familiar with how common weird behaviours/bugs can be down to specific models/years...
 

cpk0

Ars Tribunus Militum
2,367
Subscriptor++
The other piece of evidence I'd like to submit, which could support my theory that the car is at least partially responsible, is that for me these weirdnesses don't only happen when the connection comes up.

Tonight:
  • Got in the car, it went through it's normal insanity, but I eventually got it playing a podcast
  • Got to my destination
  • About an hour later I got back in the car
  • Rather than playing the podcast, it immediately went back to playing music at ridiculous speeds

At this point, if I went to Pocket Casts and hit play, it would play the podcast for an instant, and then switch back to music. I could do this an infinite number of times.

So what sort of clues does that provide. I guess there's some potential that when Pocket Casts takes over audio playback, that is somehow disrupting the Bluetooth connection to the car, and it very quickly reconnects and the issue is caused at the time of the connection. I think this is unlikely, since the small bit of podcast audio I do hear is played over the car's stereo, so there's no gap, and if it's connected enough to play the podcast, it's probably past whatever point in the connection processes where the OS is deciding what to play.

I will also say, even on its best day, the display on the infotainment system that shows track/artist/time remaining info always struggles with Pocket Casts. With Apple Music, the display is always in sync with reality. With Pocket Casts, the artist/track will generally be correct for the first episode that plays. The time played/remaining is never correct, and once the app moves to subsequent episodes, the display never reflects that.

So it's also possible this is a particular bad combination of all three: a bad BT implementation in the car, buggy BT in the OS, and some weird behavior at the app-level, too. I'm not sure how the app would be doing that, since those are pretty basic calls to the OS's media manager API, and you don't get a lot of say in what happens after that, but Pocket Casts does exacerbate the problems for sure. Pocket Casts even has an app-level setting called "Legacy Bluetooth Support", which I currently have enabled. I've tried it both ways and they each generate their own strange behaviors. Legacy ends top being slightly more reliable in my previous tests.
 

cpk0

Ars Tribunus Militum
2,367
Subscriptor++
Hard to fully rule out something dumb on the car headunit's end. Anything reported in the various BMW forums/reddit groups/Facebook groups?

I say this as someone who has spent time driving dozens of different vehicles the past few years so am quite familiar with how common weird behaviours/bugs can be down to specific models/years...

I haven't dug around on BMW forums too much. There is a pretty active i3 subreddit, and I did ask there at one point but didn't get many responses. There is also a group of people reverse engineering a lot of the computer systems in that particular car on Discord, I could see if they have any thoughts.
 

BigLan

Ars Tribunus Angusticlavius
6,907
Maybe it's something specific about how the connection is being made? Or some type of device class where "cars" are treated different than "speakers"?
Don't have experience with iOS, but Android let's you specify an 'Audio Type's for Bluetooth devices which includes "Car Kit", along with headphones, speaker, hearing aid and other/unknown. I'd guess there's default behaviors for each type, and "car kit" can launch the default media playback app (in iOS, probably Apple Music) while other types have different actions.

Edit: there's a similar setting in iOS https://www.idownloadblog.com/2021/01/27/classify-bluetooth-device-tutorial/
 

Scandinavian Film

Ars Scholae Palatinae
1,285
Subscriptor++
I want to believe everyone saying it's purely an OS/iOS issue, and I can definitely see that being where all the (bad) logic is happening, but there still seems to be something particular about the interaction between the car and the phone. Maybe it's something specific about how the connection is being made? Or some type of device class where "cars" are treated different than "speakers"? I just feel like if it were so cut-and-dry, my phone would behave this way, or at least in a similar way, in every car, but literally no other car or speaker shows this behavior.

And it's hard to miss. One of the very common behaviors I experience is having a podcast loaded up in Pocket Casts, which I run at 2x playback speed (don't at me), and after connecting to the car it will switch to Apple Music and play back somewhere around 10-20x speed. It will play an entire song every few seconds. So aside from how insane and hilarious that is, I mention it only to say it's very obvious when it happens. And in the countless other cars/speakers/etc I've connected my phones to, no other device has ever done that.

So even if it is 100% an iOS bug, it's not just a general BT bug, and I'd still love to know what weird thing the BMW is doing to make the already sucky world of Bluetooth even suckier.
It’s not just classes: iOS can distinguish individual devices and react accordingly. This is useful to remember different volume settings, but you can even program automations that trigger upon connecting to a specific device. Maybe your phone has a bugged configuration just for your car, which could cause issues even if there’s nothing wrong with the car’s infotainment per se.