summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt6
-rw-r--r--core/java/android/content/Intent.java102
-rw-r--r--media/java/android/media/AudioManager.java119
-rw-r--r--media/java/android/media/AudioService.java19
-rw-r--r--services/usb/java/com/android/server/usb/UsbDeviceManager.java3
-rw-r--r--services/usb/java/com/android/server/usb/UsbHostManager.java3
6 files changed, 144 insertions, 108 deletions
diff --git a/api/current.txt b/api/current.txt
index c96213d..c1c1f3d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7715,7 +7715,6 @@ package android.content {
field public static final java.lang.String ACTION_GET_RESTRICTION_ENTRIES = "android.intent.action.GET_RESTRICTION_ENTRIES";
field public static final java.lang.String ACTION_GTALK_SERVICE_CONNECTED = "android.intent.action.GTALK_CONNECTED";
field public static final java.lang.String ACTION_GTALK_SERVICE_DISCONNECTED = "android.intent.action.GTALK_DISCONNECTED";
- field public static final java.lang.String ACTION_HDMI_AUDIO_PLUG = "android.intent.action.HDMI_AUDIO_PLUG";
field public static final java.lang.String ACTION_HEADSET_PLUG = "android.intent.action.HEADSET_PLUG";
field public static final java.lang.String ACTION_INPUT_METHOD_CHANGED = "android.intent.action.INPUT_METHOD_CHANGED";
field public static final java.lang.String ACTION_INSERT = "android.intent.action.INSERT";
@@ -14211,6 +14210,8 @@ package android.media {
method public deprecated void unregisterRemoteControlClient(android.media.RemoteControlClient);
method public deprecated void unregisterRemoteController(android.media.RemoteController);
field public static final java.lang.String ACTION_AUDIO_BECOMING_NOISY = "android.media.AUDIO_BECOMING_NOISY";
+ field public static final java.lang.String ACTION_HDMI_AUDIO_PLUG = "android.media.action.HDMI_AUDIO_PLUG";
+ field public static final java.lang.String ACTION_HEADSET_PLUG = "android.intent.action.HEADSET_PLUG";
field public static final deprecated java.lang.String ACTION_SCO_AUDIO_STATE_CHANGED = "android.media.SCO_AUDIO_STATE_CHANGED";
field public static final java.lang.String ACTION_SCO_AUDIO_STATE_UPDATED = "android.media.ACTION_SCO_AUDIO_STATE_UPDATED";
field public static final int ADJUST_LOWER = -1; // 0xffffffff
@@ -14228,6 +14229,9 @@ package android.media {
field public static final int AUDIO_SESSION_ID_GENERATE = 0; // 0x0
field public static final int ERROR = -1; // 0xffffffff
field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
+ field public static final java.lang.String EXTRA_AUDIO_PLUG_STATE = "android.media.extra.audio_plug_state";
+ field public static final java.lang.String EXTRA_ENCODINGS = "android.media.extra.encodings";
+ field public static final java.lang.String EXTRA_MAX_CHANNEL_COUNT = "android.media.extra.max_channel_count";
field public static final java.lang.String EXTRA_RINGER_MODE = "android.media.EXTRA_RINGER_MODE";
field public static final java.lang.String EXTRA_SCO_AUDIO_PREVIOUS_STATE = "android.media.extra.SCO_AUDIO_PREVIOUS_STATE";
field public static final java.lang.String EXTRA_SCO_AUDIO_STATE = "android.media.extra.SCO_AUDIO_STATE";
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 61e105b..dd57af9 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2216,104 +2216,14 @@ public class Intent implements Parcelable, Cloneable {
/**
* Broadcast Action: Wired Headset plugged in or unplugged.
*
- * You <em>cannot</em> receive this through components declared
- * in manifests, only by explicitly registering for it with
- * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
- * Context.registerReceiver()}.
- *
- * <p>The intent will have the following extra values:
- * <ul>
- * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
- * <li><em>name</em> - Headset type, human readable string </li>
- * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
- * </ul>
- * </ul>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_HEADSET_PLUG =
- "android.intent.action.HEADSET_PLUG";
-
- /**
- * Broadcast Action: An analog audio speaker/headset 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>name</em> - Headset type, human readable string </li>
- * </ul>
- * </ul>
- * @hide
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- 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.
- *
- * <p>The intent will have the following extra values:
- * <ul>
- * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
- * <li><em>name</em> - Headset type, human readable string </li>
- * </ul>
- * </ul>
- * @hide
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_DIGITAL_AUDIO_DOCK_PLUG =
- "android.intent.action.DIGITAL_AUDIO_DOCK_PLUG";
-
- /**
- * Broadcast Action: A sticky broadcast indicating an HMDI cable was plugged 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>name</em> - HDMI cable, human readable string </li>
- * <li><em>maxChannelCount</em> - the maximum number of output channels supported by the
- * connected HDMI device, only available when <i>state</i> is 1.</li>
- * <li><em>encodings</em> - an array of formats supported by the connected HDMI device,
- * only available when <i>state</i> is 1. Encoding values are defined in
- * {@link android.media.AudioFormat} (for instance see
- * {@link android.media.AudioFormat#ENCODING_PCM_16BIT}). Use
- * {@link #getIntArrayExtra(String)} to retrieve the encoding values.</li>
- * </ul>
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_HDMI_AUDIO_PLUG =
- "android.intent.action.HDMI_AUDIO_PLUG";
-
- /**
- * Broadcast Action: A USB audio accessory 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_ACCESSORY_PLUG =
- "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
+ * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
+ * and documentation.
+ * <p>If the minimum SDK version of your application is
+ * {@link android.os.Build.VERSION_CODES#L}, it is recommended to refer
+ * to the <code>AudioManager</code> constant in your receiver registration code instead.
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_USB_AUDIO_DEVICE_PLUG =
- "android.intent.action.USB_AUDIO_DEVICE_PLUG";
+ public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
/**
* <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index e69c456..739483e 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -206,6 +206,125 @@ public class AudioManager {
public static final String EXTRA_MASTER_VOLUME_MUTED =
"android.media.EXTRA_MASTER_VOLUME_MUTED";
+ /**
+ * Broadcast Action: Wired Headset plugged in or unplugged.
+ *
+ * You <em>cannot</em> receive this through components declared
+ * in manifests, only by explicitly registering for it with
+ * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
+ * Context.registerReceiver()}.
+ *
+ * <p>The intent will have the following extra values:
+ * <ul>
+ * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
+ * <li><em>name</em> - Headset type, human readable string </li>
+ * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
+ * </ul>
+ * </ul>
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_HEADSET_PLUG =
+ "android.intent.action.HEADSET_PLUG";
+
+ /**
+ * Broadcast Action: A sticky broadcast indicating an HMDI cable was plugged or unplugged
+ *
+ * The intent will have the following extra values: {@link #EXTRA_AUDIO_PLUG_STATE},
+ * {@link #EXTRA_MAX_CHANNEL_COUNT}, {@link #EXTRA_ENCODINGS}.
+ * <p>It can only be received by explicitly registering for it with
+ * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)}.
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_HDMI_AUDIO_PLUG =
+ "android.media.action.HDMI_AUDIO_PLUG";
+
+ /**
+ * Extra used in {@link #ACTION_HDMI_AUDIO_PLUG} to communicate whether HDMI is plugged in
+ * or unplugged.
+ * An integer value of 1 indicates a plugged-in state, 0 is unplugged.
+ */
+ public static final String EXTRA_AUDIO_PLUG_STATE = "android.media.extra.audio_plug_state";
+
+ /**
+ * Extra used in {@link #ACTION_HDMI_AUDIO_PLUG} to define the maximum number of channels
+ * supported by the HDMI device.
+ * The corresponding integer value is only available when the device is plugged in (as expressed
+ * by {@link #EXTRA_AUDIO_PLUG_STATE}).
+ */
+ public static final String EXTRA_MAX_CHANNEL_COUNT = "android.media.extra.max_channel_count";
+
+ /**
+ * Extra used in {@link #ACTION_HDMI_AUDIO_PLUG} to define the audio encodings supported by
+ * the connected HDMI device.
+ * The corresponding array of encoding values is only available when the device is plugged in
+ * (as expressed by {@link #EXTRA_AUDIO_PLUG_STATE}). Encoding values are defined in
+ * {@link AudioFormat} (for instance see {@link AudioFormat#ENCODING_PCM_16BIT}). Use
+ * {@link android.content.Intent#getIntArrayExtra(String)} to retrieve the encoding values.
+ */
+ public static final String EXTRA_ENCODINGS = "android.media.extra.encodings";
+
+ /**
+ * Broadcast Action: An analog audio speaker/headset 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>name</em> - Headset type, human readable string </li>
+ * </ul>
+ * </ul>
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_ANALOG_AUDIO_DOCK_PLUG =
+ "android.media.action.ANALOG_AUDIO_DOCK_PLUG";
+
+ /**
+ * Broadcast Action: A digital audio speaker/headset 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>name</em> - Headset type, human readable string </li>
+ * </ul>
+ * </ul>
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_DIGITAL_AUDIO_DOCK_PLUG =
+ "android.media.action.DIGITAL_AUDIO_DOCK_PLUG";
+
+ /**
+ * Broadcast Action: A USB audio accessory 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_ACCESSORY_PLUG =
+ "android.media.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.media.action.USB_AUDIO_DEVICE_PLUG";
+
/** The audio stream for phone calls */
public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL;
/** The audio stream for system sounds */
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 3fea688..e97e2dc 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -598,8 +598,8 @@ public class AudioService extends IAudioService.Stub {
new IntentFilter(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
intentFilter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
- intentFilter.addAction(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG);
- intentFilter.addAction(Intent.ACTION_USB_AUDIO_DEVICE_PLUG);
+ intentFilter.addAction(AudioManager.ACTION_USB_AUDIO_ACCESSORY_PLUG);
+ intentFilter.addAction(AudioManager.ACTION_USB_AUDIO_DEVICE_PLUG);
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
@@ -4352,10 +4352,10 @@ public class AudioService extends IAudioService.Stub {
intent.putExtra("microphone", 0);
} else if (device == AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET) {
connType = AudioRoutesInfo.MAIN_DOCK_SPEAKERS;
- intent.setAction(Intent.ACTION_ANALOG_AUDIO_DOCK_PLUG);
+ intent.setAction(AudioManager.ACTION_ANALOG_AUDIO_DOCK_PLUG);
} else if (device == AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET) {
connType = AudioRoutesInfo.MAIN_DOCK_SPEAKERS;
- intent.setAction(Intent.ACTION_DIGITAL_AUDIO_DOCK_PLUG);
+ intent.setAction(AudioManager.ACTION_DIGITAL_AUDIO_DOCK_PLUG);
} else if (device == AudioSystem.DEVICE_OUT_HDMI) {
connType = AudioRoutesInfo.MAIN_HDMI;
configureHdmiPlugIntent(intent, state);
@@ -4441,7 +4441,8 @@ public class AudioService extends IAudioService.Stub {
}
private void configureHdmiPlugIntent(Intent intent, int state) {
- intent.setAction(Intent.ACTION_HDMI_AUDIO_PLUG);
+ intent.setAction(AudioManager.ACTION_HDMI_AUDIO_PLUG);
+ intent.putExtra(AudioManager.EXTRA_AUDIO_PLUG_STATE, state);
if (state == 1) {
ArrayList<AudioPort> ports = new ArrayList<AudioPort>();
int[] portGeneration = new int[1];
@@ -4465,7 +4466,7 @@ public class AudioService extends IAudioService.Stub {
for (int i = 0 ; i < encodingArray.length ; i++) {
encodingArray[i] = encodingList.get(i);
}
- intent.putExtra("encodings", encodingArray);
+ intent.putExtra(AudioManager.EXTRA_ENCODINGS, encodingArray);
}
// find the maximum supported number of channels
int maxChannels = 0;
@@ -4475,7 +4476,7 @@ public class AudioService extends IAudioService.Stub {
maxChannels = channelCount;
}
}
- intent.putExtra("maxChannelCount", maxChannels);
+ intent.putExtra(AudioManager.EXTRA_MAX_CHANNEL_COUNT, maxChannels);
}
}
}
@@ -4569,7 +4570,7 @@ public class AudioService extends IAudioService.Stub {
}
}
}
- } else if (action.equals(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG)) {
+ } else if (action.equals(AudioManager.ACTION_USB_AUDIO_ACCESSORY_PLUG)) {
state = intent.getIntExtra("state", 0);
int alsaCard = intent.getIntExtra("card", -1);
@@ -4581,7 +4582,7 @@ public class AudioService extends IAudioService.Stub {
// Playback Device
outDevice = AudioSystem.DEVICE_OUT_USB_ACCESSORY;
setWiredDeviceConnectionState(outDevice, state, params);
- } else if (action.equals(Intent.ACTION_USB_AUDIO_DEVICE_PLUG)) {
+ } else if (action.equals(AudioManager.ACTION_USB_AUDIO_DEVICE_PLUG)) {
// FIXME Does not yet handle the case where the setting is changed
// after device connection. Ideally we should handle the settings change
// in SettingsObserver. Here we should log that a USB device is connected
diff --git a/services/usb/java/com/android/server/usb/UsbDeviceManager.java b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
index c078cb2..c63eb18 100644
--- a/services/usb/java/com/android/server/usb/UsbDeviceManager.java
+++ b/services/usb/java/com/android/server/usb/UsbDeviceManager.java
@@ -30,6 +30,7 @@ import android.content.res.Resources;
import android.database.ContentObserver;
import android.hardware.usb.UsbAccessory;
import android.hardware.usb.UsbManager;
+import android.media.AudioManager;
import android.os.FileUtils;
import android.os.Handler;
import android.os.Looper;
@@ -587,7 +588,7 @@ public class UsbDeviceManager {
UsbManager.USB_FUNCTION_AUDIO_SOURCE);
if (enabled != mAudioSourceEnabled) {
// send a sticky broadcast containing current USB state
- Intent intent = new Intent(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG);
+ Intent intent = new Intent(AudioManager.ACTION_USB_AUDIO_ACCESSORY_PLUG);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
intent.putExtra("state", (enabled ? 1 : 0));
diff --git a/services/usb/java/com/android/server/usb/UsbHostManager.java b/services/usb/java/com/android/server/usb/UsbHostManager.java
index 5860fc7..06febb3 100644
--- a/services/usb/java/com/android/server/usb/UsbHostManager.java
+++ b/services/usb/java/com/android/server/usb/UsbHostManager.java
@@ -25,6 +25,7 @@ import android.hardware.usb.UsbConstants;
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
+import android.media.AudioManager;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
@@ -124,7 +125,7 @@ public class UsbHostManager {
private void sendDeviceNotification(int card, int device, boolean enabled,
boolean hasPlayback, boolean hasCapture, boolean hasMIDI) {
// send a sticky broadcast containing current USB state
- Intent intent = new Intent(Intent.ACTION_USB_AUDIO_DEVICE_PLUG);
+ Intent intent = new Intent(AudioManager.ACTION_USB_AUDIO_DEVICE_PLUG);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
intent.putExtra("state", enabled ? 1 : 0);