UsbDeviceManager: Fix race condition entering USB accessory mode

When switching USB modes there are often spurious connect and disconnect events
that occur before reenumeration is complete.  There is currently a 1000ms timer
to "debounce" the disconnect events. But with some USB accessories, this timeout
is not long enough, which results in an endless cycle of attempts to enter
USB accessory mode when the phone is connected.

To fix this, we now wait up to 10 seconds for the host to successfully configure
the device when entering USB accessory mode before giving up.
This is separate from the existing debounce timer, so the behavior of the
USB state change broadcasts are not affected.

Bug: 12877769
Change-Id: I7aa61f8a618546d749a7ddfc97bf103029a73d03
1 file changed