Added support for USB audio devices

Two types of USB audio devices are defined:
- USB audio device: the audio device in USB device mode while
the Android device is in USB host mode.
- USB audio accessory: the audio device in USB host mode while
the Android device is in USB device mode.

Renamed intents for analog and digital docks to avoid confusion:
 - ACTION_USB_ANLG_HEADSET_PLUG to ACTION_ANALOG_AUDIO_DOCK_PLUG
 - ACTION_USB_DGTL_HEADSET_PLUG to ACTION_DIGITAL_AUDIO_DOCK_PLUG

Factorized code in AudioService broadcast receiver.

Change-Id: I1b6d0257a9d68ecb9495c78c98bac8c67fec7891
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 736dd24..18d682d 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2000,8 +2000,8 @@
      * @hide
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String ACTION_USB_ANLG_HEADSET_PLUG =
-            "android.intent.action.USB_ANLG_HEADSET_PLUG";
+    public static final String ACTION_ANALOG_AUDIO_DOCK_PLUG =
+            "android.intent.action.ANALOG_AUDIO_DOCK_PLUG";
 
     /**
      * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
@@ -2015,8 +2015,8 @@
      * @hide
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String ACTION_USB_DGTL_HEADSET_PLUG =
-            "android.intent.action.USB_DGTL_HEADSET_PLUG";
+    public static final String ACTION_DIGITAL_AUDIO_DOCK_PLUG =
+            "android.intent.action.DIGITAL_AUDIO_DOCK_PLUG";
 
     /**
      * Broadcast Action: A HMDI cable was plugged or unplugged
@@ -2034,22 +2034,6 @@
             "android.intent.action.HDMI_AUDIO_PLUG";
 
     /**
-     * Broadcast Action: A USB audio device was plugged in or unplugged.
-     *
-     * <p>The intent will have the following extra values:
-     * <ul>
-     *   <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
-     *   <li><em>card</em> - ALSA card number (integer) </li>
-     *   <li><em>device</em> - ALSA device number (integer) </li>
-     * </ul>
-     * </ul>
-     * @hide
-     */
-    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String ACTION_USB_AUDIO_DEVICE_PLUG =
-            "android.intent.action.USB_AUDIO_DEVICE_PLUG";
-
-    /**
      * Broadcast Action: A USB audio accessory was plugged in or unplugged.
      *
      * <p>The intent will have the following extra values:
@@ -2066,6 +2050,22 @@
             "android.intent.action.USB_AUDIO_ACCESSORY_PLUG";
 
     /**
+     * Broadcast Action: A USB audio device was plugged in or unplugged.
+     *
+     * <p>The intent will have the following extra values:
+     * <ul>
+     *   <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
+     *   <li><em>card</em> - ALSA card number (integer) </li>
+     *   <li><em>device</em> - ALSA device number (integer) </li>
+     * </ul>
+     * </ul>
+     * @hide
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_USB_AUDIO_DEVICE_PLUG =
+            "android.intent.action.USB_AUDIO_DEVICE_PLUG";
+
+    /**
      * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
      * <ul>
      *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>