Loading core/java/android/view/VolumePanel.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -403,7 +403,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie case AudioManager.STREAM_MUSIC: { case AudioManager.STREAM_MUSIC: { // message = MUSIC_VOLUME_TEXT; // message = MUSIC_VOLUME_TEXT; // Special case for when Bluetooth is active for music // Special case for when Bluetooth is active for music if (mAudioManager.isBluetoothA2dpOn()) { if ((mAudioManager.getDevicesForStream(AudioManager.STREAM_MUSIC) & (AudioManager.DEVICE_OUT_BLUETOOTH_A2DP | AudioManager.DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | AudioManager.DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)) != 0) { // additionalMessage = // additionalMessage = // com.android.internal.R.string.volume_music_hint_playing_through_bluetooth; // com.android.internal.R.string.volume_music_hint_playing_through_bluetooth; // setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_ad2p); // setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_ad2p); Loading core/jni/android_media_AudioSystem.cpp +8 −1 Original line number Original line Diff line number Diff line Loading @@ -192,6 +192,12 @@ android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env, jobject thiz, jint s return index; return index; } } static jint android_media_AudioSystem_getDevicesForStream(JNIEnv *env, jobject thiz, jint stream) { return (jint) AudioSystem::getDevicesForStream(static_cast <AudioSystem::stream_type>(stream)); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { static JNINativeMethod gMethods[] = { Loading @@ -208,7 +214,8 @@ static JNINativeMethod gMethods[] = { {"getForceUse", "(I)I", (void *)android_media_AudioSystem_getForceUse}, {"getForceUse", "(I)I", (void *)android_media_AudioSystem_getForceUse}, {"initStreamVolume", "(III)I", (void *)android_media_AudioSystem_initStreamVolume}, {"initStreamVolume", "(III)I", (void *)android_media_AudioSystem_initStreamVolume}, {"setStreamVolumeIndex","(II)I", (void *)android_media_AudioSystem_setStreamVolumeIndex}, {"setStreamVolumeIndex","(II)I", (void *)android_media_AudioSystem_setStreamVolumeIndex}, {"getStreamVolumeIndex","(I)I", (void *)android_media_AudioSystem_getStreamVolumeIndex} {"getStreamVolumeIndex","(I)I", (void *)android_media_AudioSystem_getStreamVolumeIndex}, {"getDevicesForStream", "(I)I", (void *)android_media_AudioSystem_getDevicesForStream}, }; }; const char* const kClassPathName = "android/media/AudioSystem"; const char* const kClassPathName = "android/media/AudioSystem"; Loading include/media/AudioSystem.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -392,6 +392,7 @@ public: static status_t getStreamVolumeIndex(stream_type stream, int *index); static status_t getStreamVolumeIndex(stream_type stream, int *index); static uint32_t getStrategyForStream(stream_type stream); static uint32_t getStrategyForStream(stream_type stream); static uint32_t getDevicesForStream(stream_type stream); static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); static status_t registerEffect(effect_descriptor_t *desc, static status_t registerEffect(effect_descriptor_t *desc, Loading include/media/IAudioPolicyService.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -74,6 +74,7 @@ public: virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0; virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0; virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0; virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0; virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0; virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0; virtual uint32_t getDevicesForStream(AudioSystem::stream_type stream) = 0; virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0; virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0; virtual status_t registerEffect(effect_descriptor_t *desc, virtual status_t registerEffect(effect_descriptor_t *desc, audio_io_handle_t output, audio_io_handle_t output, Loading media/java/android/media/AudioManager.java +104 −3 Original line number Original line Diff line number Diff line Loading @@ -979,7 +979,7 @@ public class AudioManager { * false if otherwise * false if otherwise */ */ public boolean isBluetoothA2dpOn() { public boolean isBluetoothA2dpOn() { if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,"") if (AudioSystem.getDeviceConnectionState(DEVICE_OUT_BLUETOOTH_A2DP,"") == AudioSystem.DEVICE_STATE_UNAVAILABLE) { == AudioSystem.DEVICE_STATE_UNAVAILABLE) { return false; return false; } else { } else { Loading @@ -1004,9 +1004,9 @@ public class AudioManager { * false if otherwise * false if otherwise */ */ public boolean isWiredHeadsetOn() { public boolean isWiredHeadsetOn() { if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADSET,"") if (AudioSystem.getDeviceConnectionState(DEVICE_OUT_WIRED_HEADSET,"") == AudioSystem.DEVICE_STATE_UNAVAILABLE && == AudioSystem.DEVICE_STATE_UNAVAILABLE && AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,"") AudioSystem.getDeviceConnectionState(DEVICE_OUT_WIRED_HEADPHONE,"") == AudioSystem.DEVICE_STATE_UNAVAILABLE) { == AudioSystem.DEVICE_STATE_UNAVAILABLE) { return false; return false; } else { } else { Loading Loading @@ -1679,4 +1679,105 @@ public class AudioManager { return silentMode; return silentMode; } } // This section re-defines new output device constants from AudioSystem, because the AudioSystem // class is not used by other parts of the framework, which instead use definitions and methods // from AudioManager. AudioSystem is an internal class used by AudioManager and AudioService. /** {@hide} The audio output device code for the small speaker at the front of the device used * when placing calls. Does not refer to an in-ear headphone without attached microphone, * such as earbuds, earphones, or in-ear monitors (IEM). Those would be handled as a * {@link #DEVICE_OUT_WIRED_HEADPHONE}. */ public static final int DEVICE_OUT_EARPIECE = AudioSystem.DEVICE_OUT_EARPIECE; /** {@hide} The audio output device code for the built-in speaker */ public static final int DEVICE_OUT_SPEAKER = AudioSystem.DEVICE_OUT_SPEAKER; /** {@hide} The audio output device code for a wired headset with attached microphone */ public static final int DEVICE_OUT_WIRED_HEADSET = AudioSystem.DEVICE_OUT_WIRED_HEADSET; /** {@hide} The audio output device code for a wired headphone without attached microphone */ public static final int DEVICE_OUT_WIRED_HEADPHONE = AudioSystem.DEVICE_OUT_WIRED_HEADPHONE; /** {@hide} The audio output device code for generic Bluetooth SCO, for voice */ public static final int DEVICE_OUT_BLUETOOTH_SCO = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO; /** {@hide} The audio output device code for Bluetooth SCO Headset Profile (HSP) and * Hands-Free Profile (HFP), for voice */ public static final int DEVICE_OUT_BLUETOOTH_SCO_HEADSET = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET; /** {@hide} The audio output device code for Bluetooth SCO car audio, for voice */ public static final int DEVICE_OUT_BLUETOOTH_SCO_CARKIT = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT; /** {@hide} The audio output device code for generic Bluetooth A2DP, for music */ public static final int DEVICE_OUT_BLUETOOTH_A2DP = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP; /** {@hide} The audio output device code for Bluetooth A2DP headphones, for music */ public static final int DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES; /** {@hide} The audio output device code for Bluetooth A2DP external speaker, for music */ public static final int DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER; /** {@hide} The audio output device code for S/PDIF or HDMI */ public static final int DEVICE_OUT_AUX_DIGITAL = AudioSystem.DEVICE_OUT_AUX_DIGITAL; /** {@hide} The audio output device code for an analog wired headset attached via a * docking station */ public static final int DEVICE_OUT_ANLG_DOCK_HEADSET = AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET; /** {@hide} The audio output device code for a digital wired headset attached via a * docking station */ public static final int DEVICE_OUT_DGTL_DOCK_HEADSET = AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET; /** {@hide} This is not used as a returned value from {@link #getDevicesForStream}, but could be * used in the future in a set method to select whatever default device is chosen by the * platform-specific implementation. */ public static final int DEVICE_OUT_DEFAULT = AudioSystem.DEVICE_OUT_DEFAULT; /** * Return the enabled devices for the specified output stream type. * * @param streamType The stream type to query. One of * {@link #STREAM_VOICE_CALL}, * {@link #STREAM_SYSTEM}, * {@link #STREAM_RING}, * {@link #STREAM_MUSIC}, * {@link #STREAM_ALARM}, * {@link #STREAM_NOTIFICATION}, * {@link #STREAM_DTMF}. * * @return The bit-mask "or" of audio output device codes for all enabled devices on this * stream. Zero or more of * {@link #DEVICE_OUT_EARPIECE}, * {@link #DEVICE_OUT_SPEAKER}, * {@link #DEVICE_OUT_WIRED_HEADSET}, * {@link #DEVICE_OUT_WIRED_HEADPHONE}, * {@link #DEVICE_OUT_BLUETOOTH_SCO}, * {@link #DEVICE_OUT_BLUETOOTH_SCO_HEADSET}, * {@link #DEVICE_OUT_BLUETOOTH_SCO_CARKIT}, * {@link #DEVICE_OUT_BLUETOOTH_A2DP}, * {@link #DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES}, * {@link #DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER}, * {@link #DEVICE_OUT_AUX_DIGITAL}, * {@link #DEVICE_OUT_ANLG_DOCK_HEADSET}, * {@link #DEVICE_OUT_DGTL_DOCK_HEADSET}. * {@link #DEVICE_OUT_DEFAULT} is not used here. * * The implementation may support additional device codes beyond those listed, so * the application should ignore any bits which it does not recognize. * Note that the information may be imprecise when the implementation * cannot distinguish whether a particular device is enabled. * * {@hide} */ public int getDevicesForStream(int streamType) { switch (streamType) { case STREAM_VOICE_CALL: case STREAM_SYSTEM: case STREAM_RING: case STREAM_MUSIC: case STREAM_ALARM: case STREAM_NOTIFICATION: case STREAM_DTMF: return AudioSystem.getDevicesForStream(streamType); default: return 0; } } } } Loading
core/java/android/view/VolumePanel.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -403,7 +403,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie case AudioManager.STREAM_MUSIC: { case AudioManager.STREAM_MUSIC: { // message = MUSIC_VOLUME_TEXT; // message = MUSIC_VOLUME_TEXT; // Special case for when Bluetooth is active for music // Special case for when Bluetooth is active for music if (mAudioManager.isBluetoothA2dpOn()) { if ((mAudioManager.getDevicesForStream(AudioManager.STREAM_MUSIC) & (AudioManager.DEVICE_OUT_BLUETOOTH_A2DP | AudioManager.DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | AudioManager.DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER)) != 0) { // additionalMessage = // additionalMessage = // com.android.internal.R.string.volume_music_hint_playing_through_bluetooth; // com.android.internal.R.string.volume_music_hint_playing_through_bluetooth; // setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_ad2p); // setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_ad2p); Loading
core/jni/android_media_AudioSystem.cpp +8 −1 Original line number Original line Diff line number Diff line Loading @@ -192,6 +192,12 @@ android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env, jobject thiz, jint s return index; return index; } } static jint android_media_AudioSystem_getDevicesForStream(JNIEnv *env, jobject thiz, jint stream) { return (jint) AudioSystem::getDevicesForStream(static_cast <AudioSystem::stream_type>(stream)); } // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { static JNINativeMethod gMethods[] = { Loading @@ -208,7 +214,8 @@ static JNINativeMethod gMethods[] = { {"getForceUse", "(I)I", (void *)android_media_AudioSystem_getForceUse}, {"getForceUse", "(I)I", (void *)android_media_AudioSystem_getForceUse}, {"initStreamVolume", "(III)I", (void *)android_media_AudioSystem_initStreamVolume}, {"initStreamVolume", "(III)I", (void *)android_media_AudioSystem_initStreamVolume}, {"setStreamVolumeIndex","(II)I", (void *)android_media_AudioSystem_setStreamVolumeIndex}, {"setStreamVolumeIndex","(II)I", (void *)android_media_AudioSystem_setStreamVolumeIndex}, {"getStreamVolumeIndex","(I)I", (void *)android_media_AudioSystem_getStreamVolumeIndex} {"getStreamVolumeIndex","(I)I", (void *)android_media_AudioSystem_getStreamVolumeIndex}, {"getDevicesForStream", "(I)I", (void *)android_media_AudioSystem_getDevicesForStream}, }; }; const char* const kClassPathName = "android/media/AudioSystem"; const char* const kClassPathName = "android/media/AudioSystem"; Loading
include/media/AudioSystem.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -392,6 +392,7 @@ public: static status_t getStreamVolumeIndex(stream_type stream, int *index); static status_t getStreamVolumeIndex(stream_type stream, int *index); static uint32_t getStrategyForStream(stream_type stream); static uint32_t getStrategyForStream(stream_type stream); static uint32_t getDevicesForStream(stream_type stream); static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc); static status_t registerEffect(effect_descriptor_t *desc, static status_t registerEffect(effect_descriptor_t *desc, Loading
include/media/IAudioPolicyService.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -74,6 +74,7 @@ public: virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0; virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0; virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0; virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0; virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0; virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0; virtual uint32_t getDevicesForStream(AudioSystem::stream_type stream) = 0; virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0; virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0; virtual status_t registerEffect(effect_descriptor_t *desc, virtual status_t registerEffect(effect_descriptor_t *desc, audio_io_handle_t output, audio_io_handle_t output, Loading
media/java/android/media/AudioManager.java +104 −3 Original line number Original line Diff line number Diff line Loading @@ -979,7 +979,7 @@ public class AudioManager { * false if otherwise * false if otherwise */ */ public boolean isBluetoothA2dpOn() { public boolean isBluetoothA2dpOn() { if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,"") if (AudioSystem.getDeviceConnectionState(DEVICE_OUT_BLUETOOTH_A2DP,"") == AudioSystem.DEVICE_STATE_UNAVAILABLE) { == AudioSystem.DEVICE_STATE_UNAVAILABLE) { return false; return false; } else { } else { Loading @@ -1004,9 +1004,9 @@ public class AudioManager { * false if otherwise * false if otherwise */ */ public boolean isWiredHeadsetOn() { public boolean isWiredHeadsetOn() { if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADSET,"") if (AudioSystem.getDeviceConnectionState(DEVICE_OUT_WIRED_HEADSET,"") == AudioSystem.DEVICE_STATE_UNAVAILABLE && == AudioSystem.DEVICE_STATE_UNAVAILABLE && AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,"") AudioSystem.getDeviceConnectionState(DEVICE_OUT_WIRED_HEADPHONE,"") == AudioSystem.DEVICE_STATE_UNAVAILABLE) { == AudioSystem.DEVICE_STATE_UNAVAILABLE) { return false; return false; } else { } else { Loading Loading @@ -1679,4 +1679,105 @@ public class AudioManager { return silentMode; return silentMode; } } // This section re-defines new output device constants from AudioSystem, because the AudioSystem // class is not used by other parts of the framework, which instead use definitions and methods // from AudioManager. AudioSystem is an internal class used by AudioManager and AudioService. /** {@hide} The audio output device code for the small speaker at the front of the device used * when placing calls. Does not refer to an in-ear headphone without attached microphone, * such as earbuds, earphones, or in-ear monitors (IEM). Those would be handled as a * {@link #DEVICE_OUT_WIRED_HEADPHONE}. */ public static final int DEVICE_OUT_EARPIECE = AudioSystem.DEVICE_OUT_EARPIECE; /** {@hide} The audio output device code for the built-in speaker */ public static final int DEVICE_OUT_SPEAKER = AudioSystem.DEVICE_OUT_SPEAKER; /** {@hide} The audio output device code for a wired headset with attached microphone */ public static final int DEVICE_OUT_WIRED_HEADSET = AudioSystem.DEVICE_OUT_WIRED_HEADSET; /** {@hide} The audio output device code for a wired headphone without attached microphone */ public static final int DEVICE_OUT_WIRED_HEADPHONE = AudioSystem.DEVICE_OUT_WIRED_HEADPHONE; /** {@hide} The audio output device code for generic Bluetooth SCO, for voice */ public static final int DEVICE_OUT_BLUETOOTH_SCO = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO; /** {@hide} The audio output device code for Bluetooth SCO Headset Profile (HSP) and * Hands-Free Profile (HFP), for voice */ public static final int DEVICE_OUT_BLUETOOTH_SCO_HEADSET = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET; /** {@hide} The audio output device code for Bluetooth SCO car audio, for voice */ public static final int DEVICE_OUT_BLUETOOTH_SCO_CARKIT = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT; /** {@hide} The audio output device code for generic Bluetooth A2DP, for music */ public static final int DEVICE_OUT_BLUETOOTH_A2DP = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP; /** {@hide} The audio output device code for Bluetooth A2DP headphones, for music */ public static final int DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES; /** {@hide} The audio output device code for Bluetooth A2DP external speaker, for music */ public static final int DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER; /** {@hide} The audio output device code for S/PDIF or HDMI */ public static final int DEVICE_OUT_AUX_DIGITAL = AudioSystem.DEVICE_OUT_AUX_DIGITAL; /** {@hide} The audio output device code for an analog wired headset attached via a * docking station */ public static final int DEVICE_OUT_ANLG_DOCK_HEADSET = AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET; /** {@hide} The audio output device code for a digital wired headset attached via a * docking station */ public static final int DEVICE_OUT_DGTL_DOCK_HEADSET = AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET; /** {@hide} This is not used as a returned value from {@link #getDevicesForStream}, but could be * used in the future in a set method to select whatever default device is chosen by the * platform-specific implementation. */ public static final int DEVICE_OUT_DEFAULT = AudioSystem.DEVICE_OUT_DEFAULT; /** * Return the enabled devices for the specified output stream type. * * @param streamType The stream type to query. One of * {@link #STREAM_VOICE_CALL}, * {@link #STREAM_SYSTEM}, * {@link #STREAM_RING}, * {@link #STREAM_MUSIC}, * {@link #STREAM_ALARM}, * {@link #STREAM_NOTIFICATION}, * {@link #STREAM_DTMF}. * * @return The bit-mask "or" of audio output device codes for all enabled devices on this * stream. Zero or more of * {@link #DEVICE_OUT_EARPIECE}, * {@link #DEVICE_OUT_SPEAKER}, * {@link #DEVICE_OUT_WIRED_HEADSET}, * {@link #DEVICE_OUT_WIRED_HEADPHONE}, * {@link #DEVICE_OUT_BLUETOOTH_SCO}, * {@link #DEVICE_OUT_BLUETOOTH_SCO_HEADSET}, * {@link #DEVICE_OUT_BLUETOOTH_SCO_CARKIT}, * {@link #DEVICE_OUT_BLUETOOTH_A2DP}, * {@link #DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES}, * {@link #DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER}, * {@link #DEVICE_OUT_AUX_DIGITAL}, * {@link #DEVICE_OUT_ANLG_DOCK_HEADSET}, * {@link #DEVICE_OUT_DGTL_DOCK_HEADSET}. * {@link #DEVICE_OUT_DEFAULT} is not used here. * * The implementation may support additional device codes beyond those listed, so * the application should ignore any bits which it does not recognize. * Note that the information may be imprecise when the implementation * cannot distinguish whether a particular device is enabled. * * {@hide} */ public int getDevicesForStream(int streamType) { switch (streamType) { case STREAM_VOICE_CALL: case STREAM_SYSTEM: case STREAM_RING: case STREAM_MUSIC: case STREAM_ALARM: case STREAM_NOTIFICATION: case STREAM_DTMF: return AudioSystem.getDevicesForStream(streamType); default: return 0; } } } }