It's unwise to use your phone for this purpose, because a phone and laptop might both be swiped if you're not holding on to both. This has happened to folks at cafes or on mass transit in the Bay Area.
Would make for a pretty good DMS; being deceiving with a battery attached and the OS reporting a full charge.
I wonder if there's a way to modify the mainboard (knife a lead or something) to be incapable of using the battery while still charging and the OS still being able to get reporting data.
Why go the hardware route? The AC adapter state is reported to the operating system; for instance, KDE on my laptop plays a sound when a blackout cuts the power to the AC adapter. It should be simple to have something else monitor the power state and tell logind to lock all screens on AC power loss, or even force a shutdown if you're paranoid.
Not that it would help much; there are devices which can keep the AC power on while a computer is unplugged and transported, even for desktops (which have no internal battery). Nothing prevents these devices from also being used on laptops.