How Does Android Detect USB Connectivity and More About USB ~~~~UPDATED WITH RESULTS - READ BELOW ORIGINAL POST~~~~

So here's the story. I'm going to put a tablet in my car to accommodate my many desired functions. Of these functions is a backup camera. I plan on using a Logitech webcam that I had around for the camera. The webcam uses USB, so I was going to get an OTG Y adapter so that I could charge the tablet and get data from the camera to the tablet at the same time. This would require a Kernel Update, but that's already lined up.

I plan on wiring the power for the webcam into the reverse light wire (either using a relay or a DC-DC converter), and then wiring the data cables to the front of the car to the tablet. This way, the camera would turn on only when the car was in reverse, and then I would have Tasker launch a video viewing app once it detected that the USB had been plugged in, which would be initiated by the webcam receiving power and sending data.

This is based off of the assumption that Android recognizes a USB device being "plugged in" as the transfer of data being initiated, or power transfer being initiated.

What I want to know is, which one is it? Is USB detected by whether or not power can flow from the host to the client, or whether or not the tablet is receiving data? Because the tablet would only be doing the latter, and power of the webcam would be completely separate of the tablet.

I suppose I could test this, but I wanted to check here first before I murdered several USB cables in the process.

Thanks for any input.

RESULTS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The short version: The Android device does detect a USB device based on power and data flow, but my experimentation did not conclusively prove this.

The long version: To start, I soldered in an automotive relay into the wire for the webcam. If you don't know, this now switched circuit would be dependent on whether or not another circuit going into the relay was hot or not. First, I plugged the webcam with the relay into the tablet just using an OTG cable. Using Tasker to detect when USB was plugged in and open an app, I got nothing. I looked in settings, and, on the custom ROM I have installed (Timur's Nexus 7 USB Host ROM), it said that the tablet was in USB host mode, and that it was powering the slave device. Obviously, this implies that the USB device had been detected, but no data had been transmitted, since the camera itself was still off, or at least not receiving enough power. Interestingly, when I completed the control circuit on the relay, thus allowing power to the camera, still nothing happened. It was sort of in this limbo state between being detected and actually being able to be detected by Tasker. The conclusion that can be drawn from this is that true USB detection relies on data transfer, and since data transfer will require the device to be powered, power transfer as well.

As an interesting note, the ROM give me the ability to prevent the tablet from powering the slave device. In this case, I plugged the camera into a POWERED USB hub, and plugged the hub into the tablet, which was also being powered by a charging cable with this OTG Y Cable. In this case, when everything was hooked up, and I activated the control circuit on the relay, tasker immediately recognized that something was plugged in and launched the app. 

This wasn't exactly a scientific study or anything, but based on the qualitative data gathered, it seems that true USB connectivity relies both on data and Power.

Feel free to leave any comments or responses with questions or something you want me to test specifically. I'll monitor the thread.
It is based on port detection, which involves both power and data for a conventional USB connection. See Android USB Charging Secrets and Overview of USB Battery Charging Revision 1.2 and the Important Role of Adapter Emulators
When it comes to OTG Y cable, which requires powering and data transfer as visualized by you, I don't think it will work without modifications to the cable . Reason: You are attempting to marry USB standard with USB on the go standards. The D+ and D- pins which are used for power negotiation (as described in the links above) are not available for data transfer
I haven't played around with OTG Y cables much but this question on Electronics sister site shows the modifications that are required to be done Can an Android tablet serve as USB Host and be charged simultaneously through a single port?. See in particular, Guide..OTG USB HOST and CHARGING at same time for Galaxy tabs.. by MRBR7 XDA post quoted in one of the answers


Interesting question and do post your answer with your findings (yes, answering your own question is encouraged)