title: How to toggle USB mode in Android?
body: <p>I am designing a USB OTG board as an extension board for Android. The board is based upon Freescale KL25Z128VLK4. Most part of design is similar to IOIO from Sparkfun, with some extensions.</p>
  
  <ol>
  <li>By connecting OTG cable from Android phone (Galaxy Nexus) to KL25Z
  board, Android acts as USB host and KL25Z acts as device B (CDC).</li>
  <li>By reverse connecting OTG cable, Android works in AOA/ADK/ADB mode,
  and KL25Z sources VBUS and charge current to Android.</li>
  </ol>
  
  <p>In current design, switching role host/device has to be done manually by swapping cable connection. However, in latter case, if KL25Z can not offer enough current to Android, KL25Z wants to hand over host role to Android, so it can switch off main supply of 5V/500mA, and works in low power mode with VBUS from Android.</p>
  
  <p>Anyway, I want my board to support switching mode between HOST/Device, as well as support in Android.</p>
  
  <p>In principle, HNP protocol should be started for switching A/B in OTG. However, I have no idea how to handle it in Android side. I mean I don't know how Android SDK support HNP in programmatic way? Any API involved? Any documents, labs and open projects?</p>