diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2014-08-27 15:46:54 -0700 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2014-08-29 17:29:27 -0700 |
commit | c5258433dd353769ccfa2e5e769a7379378a3a0b (patch) | |
tree | 3c7dc289155f3d5481789b7449a025a2bf60d186 /media | |
parent | 86469f5962a595688ed73825778c5f6d528d7735 (diff) | |
download | frameworks_base-c5258433dd353769ccfa2e5e769a7379378a3a0b.zip frameworks_base-c5258433dd353769ccfa2e5e769a7379378a3a0b.tar.gz frameworks_base-c5258433dd353769ccfa2e5e769a7379378a3a0b.tar.bz2 |
Move *_AUDIO_PLUG actions from Intent to android.media.AudioManager
For ACTION_HEADSET_PLUG (already in SDK):
- duplicated definition in AudioManager and moved
javadoc there. Javadoc in Intent points to AudioManager.
- the String value is not changed
For ACTION_HDMI_AUDIO_PLUG (being added in SDK):
- moved defintion from Intent to AudioManager
- updated String value to reflect package name "android.media"
instead of using "android.intent"
- added definition of the extras, but removed "name".
For ACTION_ANALOG_AUDIO_DOCK_PLUG,
ACTION_DIGITAL_AUDIO_DOCK_PLUG,
ACTION_USB_AUDIO_ACCESSORY_PLUG,
ACTION_USB_AUDIO_DEVICE_PLUG, all hidden:
- moved definition from Intent to AudioManager,
- changed the value from "android.intent.*" to "android.media.*"
Updated AudioService, UsbDeviceManager and UsbHostManager
to refer to the actions in AudioManager, not Intent.
Bug 17289385
Change-Id: I61dd73140022d2bb9a676a57f595092c8fa89dcc
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioManager.java | 119 | ||||
-rw-r--r-- | media/java/android/media/AudioService.java | 19 |
2 files changed, 129 insertions, 9 deletions
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 |