Just ban general purpose computers that allow running arbitrary unsigned code. I'm sure lots of governments and corporations would be happy to get on board that one, and many end-users wouldn't notice.
Of course you could make your population turn over their old smartphones, remove IR filtering from the camera lenses and solder them to a robot body. But this will slow down manufacturing as it isn't well suited to mass manufacturing processes. Furthermore, it's a limited resource so you might have to deal with attempts by your enemy to exhaust it. Last, you'd be limited in fanciness, as in your robots can only process limited amounts. The best place to source the computation needed for really "smart" robot soldiers would probably be self driving cars as they have the AI processing power needed.
Maybe cheap LIDAR will be something we can keep a lid on? But regular vision is still likely pretty good for lining up a shot or finding a face.