USB OTG with occasional charging
This is a fundamental problem. When the ID=GND, your phone assumes the role of HOST, and therefore will SOURCE VBUS. And it will not charge its internal battery. When ID = open, the Phone will assume the role of device, will charge itself, but there will be no communication with your barcode scanner, since USB does not support device-device communication.

What you might need is to implement so-called "accessory charging adapter". See Section 1.4.1 and Section 6 of "USB Battery Charging Specification 1.2", which can be found on usb.org website link. 

You might want to check with Texas Instrument offering as TSU6721 
link for application ideas.

This all assumes that your phone really follows/supports the BC1.2 specification. If not, you are out of luck.