Merge "Replace deprecated APIs in audio switcher." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a46dd4bd4b
@@ -193,8 +193,12 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
|
||||
public void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {
|
||||
}
|
||||
|
||||
protected boolean isStreamFromOutputDevice(int streamType, int device) {
|
||||
return mAudioManager.getDevicesForStream(streamType) == device;
|
||||
}
|
||||
|
||||
protected boolean isOngoingCallStatus() {
|
||||
int audioMode = mAudioManager.getMode();
|
||||
final int audioMode = mAudioManager.getMode();
|
||||
return audioMode == AudioManager.MODE_RINGTONE
|
||||
|| audioMode == AudioManager.MODE_IN_CALL
|
||||
|| audioMode == AudioManager.MODE_IN_COMMUNICATION;
|
||||
|
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.settings.sound;
|
||||
|
||||
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
@@ -76,7 +79,7 @@ public class HandsFreeProfileOutputPreferenceController extends
|
||||
// Setup devices entries, select active connected device
|
||||
setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice);
|
||||
|
||||
if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothScoOn()) {
|
||||
if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) {
|
||||
// If wired headset is plugged in and active, select to default device.
|
||||
mSelectedIndex = getDefaultDeviceIndex();
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.sound;
|
||||
|
||||
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
||||
import static android.media.AudioSystem.DEVICE_OUT_USB_HEADSET;
|
||||
import static android.media.MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
@@ -91,7 +93,7 @@ public class MediaOutputPreferenceController extends AudioSwitchPreferenceContro
|
||||
// Setup devices entries, select active connected device
|
||||
setupPreferenceEntries(mediaOutputs, mediaValues, activeDevice);
|
||||
|
||||
if (mAudioManager.isWiredHeadsetOn() && !mAudioManager.isBluetoothA2dpOn()) {
|
||||
if (isStreamFromOutputDevice(STREAM_VOICE_CALL, DEVICE_OUT_USB_HEADSET)) {
|
||||
// If wired headset is plugged in and active, select to default device.
|
||||
mSelectedIndex = getDefaultDeviceIndex();
|
||||
}
|
||||
|
Reference in New Issue
Block a user