This seems like an eminently solvable problem.
My car knows when its key fob is inside it with great precision, to the point that I cannot even lock the doors while it is inside. My iPhone knows when it is itself in the car, so when I want to use it while driving, I have to dismiss a warning message, which I adeptly do with muscle memory.
Seems to me if cars supported driver and passenger authentication, most illegal device usage could be stopped rather trivially.