Merge "Revert "AudioService: handle BT profile disconnections"" into tm-qpr-dev am: a3ac6abdf1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21444136 Change-Id: I385649c601e7806f24e0794798def9a914572f55 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1512,7 +1512,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
case MSG_I_BT_SERVICE_DISCONNECTED_PROFILE:
|
case MSG_I_BT_SERVICE_DISCONNECTED_PROFILE:
|
||||||
if (msg.arg1 != BluetoothProfile.HEADSET) {
|
if (msg.arg1 != BluetoothProfile.HEADSET) {
|
||||||
synchronized (mDeviceStateLock) {
|
synchronized (mDeviceStateLock) {
|
||||||
mBtHelper.onBtProfileDisconnected(msg.arg1);
|
|
||||||
mDeviceInventory.onBtProfileDisconnected(msg.arg1);
|
mDeviceInventory.onBtProfileDisconnected(msg.arg1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -279,11 +279,7 @@ public class BtHelper {
|
|||||||
}
|
}
|
||||||
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
||||||
AudioServiceEvents.VolumeEvent.VOL_SET_AVRCP_VOL, index));
|
AudioServiceEvents.VolumeEvent.VOL_SET_AVRCP_VOL, index));
|
||||||
try {
|
mA2dp.setAvrcpAbsoluteVolume(index);
|
||||||
mA2dp.setAvrcpAbsoluteVolume(index);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Exception while changing abs volume", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ synchronized @AudioSystem.AudioFormatNativeEnumForBtCodec int getA2dpCodec(
|
/*package*/ synchronized @AudioSystem.AudioFormatNativeEnumForBtCodec int getA2dpCodec(
|
||||||
@@ -291,12 +287,7 @@ public class BtHelper {
|
|||||||
if (mA2dp == null) {
|
if (mA2dp == null) {
|
||||||
return AudioSystem.AUDIO_FORMAT_DEFAULT;
|
return AudioSystem.AUDIO_FORMAT_DEFAULT;
|
||||||
}
|
}
|
||||||
final BluetoothCodecStatus btCodecStatus = null;
|
final BluetoothCodecStatus btCodecStatus = mA2dp.getCodecStatus(device);
|
||||||
try {
|
|
||||||
mA2dp.getCodecStatus(device);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Exception while getting status of " + device, e);
|
|
||||||
}
|
|
||||||
if (btCodecStatus == null) {
|
if (btCodecStatus == null) {
|
||||||
return AudioSystem.AUDIO_FORMAT_DEFAULT;
|
return AudioSystem.AUDIO_FORMAT_DEFAULT;
|
||||||
}
|
}
|
||||||
@@ -430,11 +421,7 @@ public class BtHelper {
|
|||||||
}
|
}
|
||||||
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
||||||
AudioServiceEvents.VolumeEvent.VOL_SET_LE_AUDIO_VOL, index, maxIndex));
|
AudioServiceEvents.VolumeEvent.VOL_SET_LE_AUDIO_VOL, index, maxIndex));
|
||||||
try {
|
mLeAudio.setVolume(volume);
|
||||||
mLeAudio.setVolume(volume);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Exception while setting LE volume", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ synchronized void setHearingAidVolume(int index, int streamType,
|
/*package*/ synchronized void setHearingAidVolume(int index, int streamType,
|
||||||
@@ -460,11 +447,7 @@ public class BtHelper {
|
|||||||
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
AudioService.sVolumeLogger.log(new AudioServiceEvents.VolumeEvent(
|
||||||
AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB));
|
AudioServiceEvents.VolumeEvent.VOL_SET_HEARING_AID_VOL, index, gainDB));
|
||||||
}
|
}
|
||||||
try {
|
mHearingAid.setVolume(gainDB);
|
||||||
mHearingAid.setVolume(gainDB);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.i(TAG, "Exception while setting hearing aid volume", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ synchronized void onBroadcastScoConnectionState(int state) {
|
/*package*/ synchronized void onBroadcastScoConnectionState(int state) {
|
||||||
@@ -504,35 +487,6 @@ public class BtHelper {
|
|||||||
mBluetoothHeadset = null;
|
mBluetoothHeadset = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//@GuardedBy("AudioDeviceBroker.mDeviceStateLock")
|
|
||||||
/*package*/ synchronized void onBtProfileDisconnected(int profile) {
|
|
||||||
switch (profile) {
|
|
||||||
case BluetoothProfile.A2DP:
|
|
||||||
mA2dp = null;
|
|
||||||
break;
|
|
||||||
case BluetoothProfile.HEARING_AID:
|
|
||||||
mHearingAid = null;
|
|
||||||
break;
|
|
||||||
case BluetoothProfile.LE_AUDIO:
|
|
||||||
mLeAudio = null;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BluetoothProfile.A2DP_SINK:
|
|
||||||
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
|
||||||
// shouldn't be received here as profile doesn't involve BtHelper
|
|
||||||
Log.e(TAG, "onBtProfileDisconnected: Not a profile handled by BtHelper "
|
|
||||||
+ BluetoothProfile.getProfileName(profile));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Not a valid profile to disconnect
|
|
||||||
Log.e(TAG, "onBtProfileDisconnected: Not a valid profile to disconnect "
|
|
||||||
+ BluetoothProfile.getProfileName(profile));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//@GuardedBy("AudioDeviceBroker.mDeviceStateLock")
|
|
||||||
/*package*/ synchronized void onBtProfileConnected(int profile, BluetoothProfile proxy) {
|
/*package*/ synchronized void onBtProfileConnected(int profile, BluetoothProfile proxy) {
|
||||||
if (profile == BluetoothProfile.HEADSET) {
|
if (profile == BluetoothProfile.HEADSET) {
|
||||||
onHeadsetProfileConnected((BluetoothHeadset) proxy);
|
onHeadsetProfileConnected((BluetoothHeadset) proxy);
|
||||||
@@ -718,6 +672,7 @@ public class BtHelper {
|
|||||||
public void onServiceConnected(int profile, BluetoothProfile proxy) {
|
public void onServiceConnected(int profile, BluetoothProfile proxy) {
|
||||||
switch(profile) {
|
switch(profile) {
|
||||||
case BluetoothProfile.A2DP:
|
case BluetoothProfile.A2DP:
|
||||||
|
case BluetoothProfile.A2DP_SINK:
|
||||||
case BluetoothProfile.HEADSET:
|
case BluetoothProfile.HEADSET:
|
||||||
case BluetoothProfile.HEARING_AID:
|
case BluetoothProfile.HEARING_AID:
|
||||||
case BluetoothProfile.LE_AUDIO:
|
case BluetoothProfile.LE_AUDIO:
|
||||||
@@ -727,10 +682,6 @@ public class BtHelper {
|
|||||||
mDeviceBroker.postBtProfileConnected(profile, proxy);
|
mDeviceBroker.postBtProfileConnected(profile, proxy);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BluetoothProfile.A2DP_SINK:
|
|
||||||
// no A2DP sink functionality handled by BtHelper
|
|
||||||
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
|
||||||
// no broadcast functionality handled by BtHelper
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -739,19 +690,14 @@ public class BtHelper {
|
|||||||
|
|
||||||
switch (profile) {
|
switch (profile) {
|
||||||
case BluetoothProfile.A2DP:
|
case BluetoothProfile.A2DP:
|
||||||
|
case BluetoothProfile.A2DP_SINK:
|
||||||
case BluetoothProfile.HEADSET:
|
case BluetoothProfile.HEADSET:
|
||||||
case BluetoothProfile.HEARING_AID:
|
case BluetoothProfile.HEARING_AID:
|
||||||
case BluetoothProfile.LE_AUDIO:
|
case BluetoothProfile.LE_AUDIO:
|
||||||
AudioService.sDeviceLogger.log(new AudioEventLogger.StringEvent(
|
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
||||||
"BT profile service: disconnecting "
|
|
||||||
+ BluetoothProfile.getProfileName(profile) + " profile"));
|
|
||||||
mDeviceBroker.postBtProfileDisconnected(profile);
|
mDeviceBroker.postBtProfileDisconnected(profile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BluetoothProfile.A2DP_SINK:
|
|
||||||
// no A2DP sink functionality handled by BtHelper
|
|
||||||
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
|
||||||
// no broadcast functionality handled by BtHelper
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user