matchboxbananasynergy
You're very kind to reply, and especially so politely given all you've been through with this! Thought about it, but it's less net effort to muddle through with the flashlight on the telephone as it is, than it is to carry an extra thing. I do very often carry keys and will probably buy a little keyring torch for the reasons you describe. There are lots of USB rechargeable keyring lights.
Wouldn't it instead be more productive to simply carry a pocket flashlight?
I suspect you're right, but if there's a way to get this code into the AOSP, I'll probably get a couple or few decades benefit out of it, so I don't mind devoting a little time to trying to understand how to solve the problem the 'correct' way.
I should add that in the mean time I'm trying to find a Third Way, using dimple NFC membrane buttons, combined with an automation app (easer or automation, but neither of them allow flashlight operation sadly... open to suggestions) in order to achieve the desired end.
I was disinclined to use a "shake for flashlight" app as the inadvertent flashlight activation will probably get annoying (my work uniform's trousers don't have serviceable pockets, and the tops have a pocket on their bottom edge, so the phone is sort of suspended in front of the hip and gets shaken whilst walking).
If I manage to achieve the end I will report back!