I wonder by what method it does that? put out a pulse code on the power out and look for it? Some USB cables don't actually carry the data lines through, so.
You either have a ping before connecting and if you get a response don't do it. Or you send some high frequency wave additionally to the power. You can detect that signal and then stop accepting the power.
Probably just sends a number as data, and if it gets it back then doesn't charge.
You're right that some cables don't carry data, but most do and as long as the cable that comes with it does then it's going to be fine for 99% of cases.
There'll often be a way to break it like going through a USB hub, but most people aren't actively trying to damage things. I can see people wrapping the cable around it and plugging both ends in to stop them flapping about though.