When I used to listen to music on my previous phone (a Nexus 4) I would have to constantly adjust the phone's volume: all the way to maximum when using an aux cord in my car, and way back down when using headphones. Recently I upgraded to a Nexus 5X, and noticed a surprising new feature. Somehow, the phone detects which device it's plugged into, and remembers a separate, previously-set volume level for each device.
Does anyone know how this works? It's really convenient, which makes it surprising that I can't find it documented or even mentioned anywhere online. I'm assuming the audio hardware is somehow sensing the impedance of whatever it's connected to, but is that really a reliable indicator of headphones vs. line-level inputs?