|
@@ -56,7 +56,6 @@ import java.util.Set;
|
|
public class MagicAudioManager {
|
|
public class MagicAudioManager {
|
|
private static final String TAG = "MagicAudioManager";
|
|
private static final String TAG = "MagicAudioManager";
|
|
private static final String SPEAKERPHONE_AUTO = "auto";
|
|
private static final String SPEAKERPHONE_AUTO = "auto";
|
|
- private static final String SPEAKERPHONE_TRUE = "true";
|
|
|
|
private static final String SPEAKERPHONE_FALSE = "false";
|
|
private static final String SPEAKERPHONE_FALSE = "false";
|
|
private final Context magicContext;
|
|
private final Context magicContext;
|
|
// Contains speakerphone setting: auto, true or false
|
|
// Contains speakerphone setting: auto, true or false
|
|
@@ -91,7 +90,7 @@ public class MagicAudioManager {
|
|
private MagicProximitySensor proximitySensor = null;
|
|
private MagicProximitySensor proximitySensor = null;
|
|
// Contains a list of available audio devices. A Set collection is used to
|
|
// Contains a list of available audio devices. A Set collection is used to
|
|
// avoid duplicate elements.
|
|
// avoid duplicate elements.
|
|
- private Set<AudioDevice> audioDevices = new HashSet<AudioDevice>();
|
|
|
|
|
|
+ private Set<AudioDevice> audioDevices = new HashSet<>();
|
|
// Broadcast receiver for wired headset intent broadcasts.
|
|
// Broadcast receiver for wired headset intent broadcasts.
|
|
private BroadcastReceiver wiredHeadsetReceiver;
|
|
private BroadcastReceiver wiredHeadsetReceiver;
|
|
// Callback method for changes in audio focus.
|
|
// Callback method for changes in audio focus.
|
|
@@ -546,14 +545,15 @@ public class MagicAudioManager {
|
|
bluetoothManager.updateDevice();
|
|
bluetoothManager.updateDevice();
|
|
}
|
|
}
|
|
|
|
|
|
- if (needBluetoothAudioStart && !needBluetoothAudioStop) {
|
|
|
|
- // Attempt to start Bluetooth SCO audio (takes a few second to start).
|
|
|
|
- if (!bluetoothManager.startScoAudio()) {
|
|
|
|
- // Remove BLUETOOTH from list of available devices since SCO failed.
|
|
|
|
- audioDevices.remove(AudioDevice.BLUETOOTH);
|
|
|
|
- audioDeviceSetUpdated = true;
|
|
|
|
- }
|
|
|
|
|
|
+ // Attempt to start Bluetooth SCO audio (takes a few second to start).
|
|
|
|
+ if (needBluetoothAudioStart &&
|
|
|
|
+ !needBluetoothAudioStop &&
|
|
|
|
+ !bluetoothManager.startScoAudio()) {
|
|
|
|
+ // Remove BLUETOOTH from list of available devices since SCO failed.
|
|
|
|
+ audioDevices.remove(AudioDevice.BLUETOOTH);
|
|
|
|
+ audioDeviceSetUpdated = true;
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
// Update selected audio device.
|
|
// Update selected audio device.
|
|
AudioDevice newAudioDevice = selectedAudioDevice;
|
|
AudioDevice newAudioDevice = selectedAudioDevice;
|
|
@@ -620,13 +620,12 @@ public class MagicAudioManager {
|
|
private static final int STATE_UNPLUGGED = 0;
|
|
private static final int STATE_UNPLUGGED = 0;
|
|
private static final int STATE_PLUGGED = 1;
|
|
private static final int STATE_PLUGGED = 1;
|
|
private static final int HAS_NO_MIC = 0;
|
|
private static final int HAS_NO_MIC = 0;
|
|
- private static final int HAS_MIC = 1;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
public void onReceive(Context context, Intent intent) {
|
|
int state = intent.getIntExtra("state", STATE_UNPLUGGED);
|
|
int state = intent.getIntExtra("state", STATE_UNPLUGGED);
|
|
- int microphone = intent.getIntExtra("microphone", HAS_NO_MIC);
|
|
|
|
- String name = intent.getStringExtra("name");
|
|
|
|
|
|
+ // int microphone = intent.getIntExtra("microphone", HAS_NO_MIC);
|
|
|
|
+ // String name = intent.getStringExtra("name");
|
|
hasWiredHeadset = (state == STATE_PLUGGED);
|
|
hasWiredHeadset = (state == STATE_PLUGGED);
|
|
updateAudioDeviceState();
|
|
updateAudioDeviceState();
|
|
}
|
|
}
|