am 0ca9e2df: am 4032c94d: am fc5a4bf0: Merge "AudioService: check for audio device connection success" into mnc-dev
* commit '0ca9e2dffb60781b4bdfa2a4a012f7ee2afa02b8': AudioService: check for audio device connection success
This commit is contained in:
@@ -604,6 +604,10 @@ public class AudioSystem
|
|||||||
public static final int SYNC_EVENT_NONE = 0;
|
public static final int SYNC_EVENT_NONE = 0;
|
||||||
public static final int SYNC_EVENT_PRESENTATION_COMPLETE = 1;
|
public static final int SYNC_EVENT_PRESENTATION_COMPLETE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return command completion status, one of {@link #AUDIO_STATUS_OK},
|
||||||
|
* {@link #AUDIO_STATUS_ERROR} or {@link #AUDIO_STATUS_SERVER_DIED}
|
||||||
|
*/
|
||||||
public static native int setDeviceConnectionState(int device, int state,
|
public static native int setDeviceConnectionState(int device, int state,
|
||||||
String device_address, String device_name);
|
String device_address, String device_name);
|
||||||
public static native int getDeviceConnectionState(int device, String device_address);
|
public static native int getDeviceConnectionState(int device, String device_address);
|
||||||
|
|||||||
@@ -4730,13 +4730,19 @@ public class AudioService extends IAudioService.Stub {
|
|||||||
Slog.i(TAG, "deviceSpec:" + deviceSpec + " is(already)Connected:" + isConnected);
|
Slog.i(TAG, "deviceSpec:" + deviceSpec + " is(already)Connected:" + isConnected);
|
||||||
}
|
}
|
||||||
if (connect && !isConnected) {
|
if (connect && !isConnected) {
|
||||||
AudioSystem.setDeviceConnectionState(device, AudioSystem.DEVICE_STATE_AVAILABLE,
|
final int res = AudioSystem.setDeviceConnectionState(device,
|
||||||
address, deviceName);
|
AudioSystem.DEVICE_STATE_AVAILABLE, address, deviceName);
|
||||||
|
if (res != AudioSystem.AUDIO_STATUS_OK) {
|
||||||
|
Slog.e(TAG, "not connecting device 0x" + Integer.toHexString(device) +
|
||||||
|
" due to command error " + res );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mConnectedDevices.put(deviceKey, new DeviceListSpec(device, deviceName, address));
|
mConnectedDevices.put(deviceKey, new DeviceListSpec(device, deviceName, address));
|
||||||
return true;
|
return true;
|
||||||
} else if (!connect && isConnected) {
|
} else if (!connect && isConnected) {
|
||||||
AudioSystem.setDeviceConnectionState(device, AudioSystem.DEVICE_STATE_UNAVAILABLE,
|
AudioSystem.setDeviceConnectionState(device,
|
||||||
address, deviceName);
|
AudioSystem.DEVICE_STATE_UNAVAILABLE, address, deviceName);
|
||||||
|
// always remove even if disconnection failed
|
||||||
mConnectedDevices.remove(deviceKey);
|
mConnectedDevices.remove(deviceKey);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4869,7 +4875,10 @@ public class AudioService extends IAudioService.Stub {
|
|||||||
boolean isUsb = ((device & ~AudioSystem.DEVICE_OUT_ALL_USB) == 0) ||
|
boolean isUsb = ((device & ~AudioSystem.DEVICE_OUT_ALL_USB) == 0) ||
|
||||||
(((device & AudioSystem.DEVICE_BIT_IN) != 0) &&
|
(((device & AudioSystem.DEVICE_BIT_IN) != 0) &&
|
||||||
((device & ~AudioSystem.DEVICE_IN_ALL_USB) == 0));
|
((device & ~AudioSystem.DEVICE_IN_ALL_USB) == 0));
|
||||||
handleDeviceConnection(state == 1, device, address, deviceName);
|
if (!handleDeviceConnection(state == 1, device, address, deviceName)) {
|
||||||
|
// change of connection state failed, bailout
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (state != 0) {
|
if (state != 0) {
|
||||||
if ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
|
if ((device == AudioSystem.DEVICE_OUT_WIRED_HEADSET) ||
|
||||||
(device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE) ||
|
(device == AudioSystem.DEVICE_OUT_WIRED_HEADPHONE) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user