Loading android/app/src/com/android/bluetooth/tbs/TbsGeneric.java +3 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,9 @@ public class TbsGeneric { mTbsGatt.clearSilentModeFlag(); } // Android supports inband ringtone mTbsGatt.setInbandRingtoneFlag(); mReceiver = new Receiver(); mTbsGatt.getContext().registerReceiver(mReceiver, new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION)); Loading android/app/src/com/android/bluetooth/telephony/BluetoothInCallService.java +0 −53 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.net.Uri; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -61,8 +60,6 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; /** * Used to receive updates about calls from the Telecom component. This service is bound to Telecom Loading Loading @@ -97,8 +94,6 @@ public class BluetoothInCallService extends InCallService { // Indicates that no BluetoothCall is ringing private static final int DEFAULT_RINGING_ADDRESS_TYPE = 128; private static final int DISCONNECT_TONE_TIMEOUT_SECONDS = 1; private int mNumActiveCalls = 0; private int mNumHeldCalls = 0; private int mNumChildrenOfActiveCall = 0; Loading @@ -114,13 +109,6 @@ public class BluetoothInCallService extends InCallService { private BluetoothLeCallControlProxy mBluetoothLeCallControl; private ExecutorService mExecutor; private Semaphore mDisconnectionToneSemaphore = new Semaphore(0); private int mAudioMode = AudioManager.MODE_INVALID; private final Object mAudioModeLock = new Object(); @VisibleForTesting public AudioManager mAudioManager; @VisibleForTesting public TelephonyManager mTelephonyManager; Loading Loading @@ -328,19 +316,6 @@ public class BluetoothInCallService extends InCallService { } } class BluetoothOnModeChangedListener implements AudioManager.OnModeChangedListener { @Override public void onModeChanged(int mode) { synchronized (mAudioModeLock) { mAudioMode = mode; } if (mode == AudioManager.MODE_NORMAL) { mDisconnectionToneSemaphore.release(); } } } private BluetoothOnModeChangedListener mBluetoothOnModeChangedListener; @Override public IBinder onBind(Intent intent) { Log.i(TAG, "onBind. Intent: " + intent); Loading Loading @@ -567,26 +542,6 @@ public class BluetoothInCallService extends InCallService { return; } Log.d(TAG, "onCallRemoved"); BluetoothCall heldCall = mCallInfo.getHeldCall(); if (mCallInfo.isNullCall(heldCall)) { // current call is the only call mDisconnectionToneSemaphore.drainPermits(); boolean isAudioModeNormal = false; synchronized (mAudioModeLock) { isAudioModeNormal = (mAudioMode == AudioManager.MODE_NORMAL); } if (!isAudioModeNormal) { Log.d(TAG, "Acquiring mDisconnectionToneSemaphore"); try { boolean result = mDisconnectionToneSemaphore.tryAcquire( DISCONNECT_TONE_TIMEOUT_SECONDS, TimeUnit.SECONDS); Log.d(TAG, "Acquiring mDisconnectionToneSemaphore result " + result); } catch (InterruptedException e) { Log.w(TAG, "Failed to acquire mDisconnectionToneSemaphore"); } } } CallStateCallback callback = getCallback(call); if (callback != null) { call.unregisterCallback(callback); Loading Loading @@ -633,10 +588,6 @@ public class BluetoothInCallService extends InCallService { mBluetoothAdapterReceiver = new BluetoothAdapterReceiver(); IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(mBluetoothAdapterReceiver, intentFilter); mBluetoothOnModeChangedListener = new BluetoothOnModeChangedListener(); mAudioManager = getSystemService(AudioManager.class); mAudioManager.addOnModeChangedListener( Executors.newSingleThreadExecutor(), mBluetoothOnModeChangedListener); mOnCreateCalled = true; } Loading @@ -650,10 +601,6 @@ public class BluetoothInCallService extends InCallService { private void clear() { Log.d(TAG, "clear"); if (mBluetoothOnModeChangedListener != null) { mAudioManager.removeOnModeChangedListener(mBluetoothOnModeChangedListener); mBluetoothOnModeChangedListener = null; } if (mBluetoothAdapterReceiver != null) { unregisterReceiver(mBluetoothAdapterReceiver); mBluetoothAdapterReceiver = null; Loading apex/apex_manifest.json +1 −1 Original line number Diff line number Diff line { "name": "com.android.bluetooth", "version": 330000000 "version": 330090000 } system/audio_hal_interface/aidl/le_audio_software_aidl.cc +1 −0 Original line number Diff line number Diff line Loading @@ -360,6 +360,7 @@ std::unordered_map<int32_t, uint16_t> octets_per_frame_map{ {30, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen30}, {40, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen40}, {60, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen60}, {80, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen80}, {120, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen120}}; std::unordered_map<AudioLocation, uint32_t> audio_location_map{ Loading system/bta/hearing_aid/hearing_aid.cc +53 −12 Original line number Diff line number Diff line Loading @@ -402,15 +402,6 @@ class HearingAidImpl : public HearingAid { hearingDevice->connection_update_status = AWAITING; } if (controller_get_interface()->supports_ble_2m_phy()) { LOG(INFO) << address << " set preferred PHY to 2M"; BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0); } // Set data length // TODO(jpawlowski: for 16khz only 87 is required, optimize BTM_SetBleDataLength(address, 167); if (BTM_SecIsSecurityPending(address)) { /* if security collision happened, wait for encryption done * (BTA_GATTC_ENC_CMPL_CB_EVT) */ Loading Loading @@ -510,6 +501,12 @@ class HearingAidImpl : public HearingAid { hearingDevice->connection_update_status = NONE; } if (!hearingDevice->accepting_audio && hearingDevice->connection_update_status == COMPLETED && hearingDevice->gap_opened) { OnDeviceReady(hearingDevice->address); } for (auto& device : hearingDevices.devices) { if (device.conn_id && (device.connection_update_status == AWAITING)) { device.connection_update_status = STARTED; Loading Loading @@ -578,6 +575,24 @@ class HearingAidImpl : public HearingAid { } } void OnPhyUpdateEvent(uint16_t conn_id, uint8_t tx_phys, uint8_t rx_phys, tGATT_STATUS status) { HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); if (!hearingDevice) { DVLOG(2) << "Skipping unknown device, conn_id=" << loghex(conn_id); return; } if (status == GATT_SUCCESS && tx_phys == PHY_LE_2M && rx_phys == PHY_LE_2M) { LOG(INFO) << hearingDevice->address << " phy update to 2M successful"; return; } LOG(INFO) << hearingDevice->address << " phy update to 2M fail, try again. status: " << status << ", tx_phys: " << tx_phys << ", rx_phys: " << rx_phys; BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0); } void OnServiceChangeEvent(const RawAddress& address) { HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); if (!hearingDevice) { Loading Loading @@ -875,6 +890,15 @@ class HearingAidImpl : public HearingAid { void ConnectSocket(HearingDevice* hearingDevice, uint16_t psm) { tL2CAP_CFG_INFO cfg_info = tL2CAP_CFG_INFO{.mtu = 512}; if (controller_get_interface()->supports_ble_2m_phy()) { LOG(INFO) << hearingDevice->address << " set preferred PHY to 2M"; BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0); } // Set data length // TODO(jpawlowski: for 16khz only 87 is required, optimize BTM_SetBleDataLength(hearingDevice->address, 167); SendEnableServiceChangedInd(hearingDevice); uint8_t service_id = hearingDevice->isLeft() Loading Loading @@ -915,8 +939,8 @@ class HearingAidImpl : public HearingAid { instance->OnPsmRead(conn_id, status, handle, len, value, data); } /* CoC Socket is ready */ void OnGapConnection(const RawAddress& address) { /* CoC Socket, BLE connection parameter are ready */ void OnDeviceReady(const RawAddress& address) { HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); if (!hearingDevice) { LOG(INFO) << "Device not connected to profile" << address; Loading Loading @@ -1398,7 +1422,16 @@ class HearingAidImpl : public HearingAid { LOG(INFO) << "GAP_EVT_CONN_OPENED " << address << ", tx_mtu=" << tx_mtu << ", init_credit=" << init_credit; OnGapConnection(address); HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); if (!hearingDevice) { LOG(INFO) << "Skipping unknown device" << address; return; } hearingDevice->gap_opened = true; if (hearingDevice->connection_update_status == COMPLETED) { OnDeviceReady(address); } break; } Loading @@ -1417,6 +1450,7 @@ class HearingAidImpl : public HearingAid { hearingDevice->accepting_audio = false; hearingDevice->playback_started = false; hearingDevice->command_acked = false; hearingDevice->gap_opened = false; } break; case GAP_EVT_CONN_DATA_AVAIL: { Loading Loading @@ -1631,6 +1665,7 @@ class HearingAidImpl : public HearingAid { } } hearingDevice->connection_update_status = NONE; hearingDevice->gap_opened = false; if (hearingDevice->conn_id) { BtaGattQueue::Clean(hearingDevice->conn_id); Loading Loading @@ -1850,6 +1885,12 @@ void hearingaid_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data) { if (!instance) return; instance->OnServiceDiscDoneEvent(p_data->service_changed.remote_bda); break; case BTA_GATTC_PHY_UPDATE_EVT: { if (!instance) return; tBTA_GATTC_PHY_UPDATE& p = p_data->phy_update; instance->OnPhyUpdateEvent(p.conn_id, p.tx_phy, p.rx_phy, p.status); break; } default: break; Loading Loading
android/app/src/com/android/bluetooth/tbs/TbsGeneric.java +3 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,9 @@ public class TbsGeneric { mTbsGatt.clearSilentModeFlag(); } // Android supports inband ringtone mTbsGatt.setInbandRingtoneFlag(); mReceiver = new Receiver(); mTbsGatt.getContext().registerReceiver(mReceiver, new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION)); Loading
android/app/src/com/android/bluetooth/telephony/BluetoothInCallService.java +0 −53 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.net.Uri; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -61,8 +60,6 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; /** * Used to receive updates about calls from the Telecom component. This service is bound to Telecom Loading Loading @@ -97,8 +94,6 @@ public class BluetoothInCallService extends InCallService { // Indicates that no BluetoothCall is ringing private static final int DEFAULT_RINGING_ADDRESS_TYPE = 128; private static final int DISCONNECT_TONE_TIMEOUT_SECONDS = 1; private int mNumActiveCalls = 0; private int mNumHeldCalls = 0; private int mNumChildrenOfActiveCall = 0; Loading @@ -114,13 +109,6 @@ public class BluetoothInCallService extends InCallService { private BluetoothLeCallControlProxy mBluetoothLeCallControl; private ExecutorService mExecutor; private Semaphore mDisconnectionToneSemaphore = new Semaphore(0); private int mAudioMode = AudioManager.MODE_INVALID; private final Object mAudioModeLock = new Object(); @VisibleForTesting public AudioManager mAudioManager; @VisibleForTesting public TelephonyManager mTelephonyManager; Loading Loading @@ -328,19 +316,6 @@ public class BluetoothInCallService extends InCallService { } } class BluetoothOnModeChangedListener implements AudioManager.OnModeChangedListener { @Override public void onModeChanged(int mode) { synchronized (mAudioModeLock) { mAudioMode = mode; } if (mode == AudioManager.MODE_NORMAL) { mDisconnectionToneSemaphore.release(); } } } private BluetoothOnModeChangedListener mBluetoothOnModeChangedListener; @Override public IBinder onBind(Intent intent) { Log.i(TAG, "onBind. Intent: " + intent); Loading Loading @@ -567,26 +542,6 @@ public class BluetoothInCallService extends InCallService { return; } Log.d(TAG, "onCallRemoved"); BluetoothCall heldCall = mCallInfo.getHeldCall(); if (mCallInfo.isNullCall(heldCall)) { // current call is the only call mDisconnectionToneSemaphore.drainPermits(); boolean isAudioModeNormal = false; synchronized (mAudioModeLock) { isAudioModeNormal = (mAudioMode == AudioManager.MODE_NORMAL); } if (!isAudioModeNormal) { Log.d(TAG, "Acquiring mDisconnectionToneSemaphore"); try { boolean result = mDisconnectionToneSemaphore.tryAcquire( DISCONNECT_TONE_TIMEOUT_SECONDS, TimeUnit.SECONDS); Log.d(TAG, "Acquiring mDisconnectionToneSemaphore result " + result); } catch (InterruptedException e) { Log.w(TAG, "Failed to acquire mDisconnectionToneSemaphore"); } } } CallStateCallback callback = getCallback(call); if (callback != null) { call.unregisterCallback(callback); Loading Loading @@ -633,10 +588,6 @@ public class BluetoothInCallService extends InCallService { mBluetoothAdapterReceiver = new BluetoothAdapterReceiver(); IntentFilter intentFilter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(mBluetoothAdapterReceiver, intentFilter); mBluetoothOnModeChangedListener = new BluetoothOnModeChangedListener(); mAudioManager = getSystemService(AudioManager.class); mAudioManager.addOnModeChangedListener( Executors.newSingleThreadExecutor(), mBluetoothOnModeChangedListener); mOnCreateCalled = true; } Loading @@ -650,10 +601,6 @@ public class BluetoothInCallService extends InCallService { private void clear() { Log.d(TAG, "clear"); if (mBluetoothOnModeChangedListener != null) { mAudioManager.removeOnModeChangedListener(mBluetoothOnModeChangedListener); mBluetoothOnModeChangedListener = null; } if (mBluetoothAdapterReceiver != null) { unregisterReceiver(mBluetoothAdapterReceiver); mBluetoothAdapterReceiver = null; Loading
apex/apex_manifest.json +1 −1 Original line number Diff line number Diff line { "name": "com.android.bluetooth", "version": 330000000 "version": 330090000 }
system/audio_hal_interface/aidl/le_audio_software_aidl.cc +1 −0 Original line number Diff line number Diff line Loading @@ -360,6 +360,7 @@ std::unordered_map<int32_t, uint16_t> octets_per_frame_map{ {30, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen30}, {40, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen40}, {60, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen60}, {80, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen80}, {120, ::le_audio::codec_spec_conf::kLeAudioCodecLC3FrameLen120}}; std::unordered_map<AudioLocation, uint32_t> audio_location_map{ Loading
system/bta/hearing_aid/hearing_aid.cc +53 −12 Original line number Diff line number Diff line Loading @@ -402,15 +402,6 @@ class HearingAidImpl : public HearingAid { hearingDevice->connection_update_status = AWAITING; } if (controller_get_interface()->supports_ble_2m_phy()) { LOG(INFO) << address << " set preferred PHY to 2M"; BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0); } // Set data length // TODO(jpawlowski: for 16khz only 87 is required, optimize BTM_SetBleDataLength(address, 167); if (BTM_SecIsSecurityPending(address)) { /* if security collision happened, wait for encryption done * (BTA_GATTC_ENC_CMPL_CB_EVT) */ Loading Loading @@ -510,6 +501,12 @@ class HearingAidImpl : public HearingAid { hearingDevice->connection_update_status = NONE; } if (!hearingDevice->accepting_audio && hearingDevice->connection_update_status == COMPLETED && hearingDevice->gap_opened) { OnDeviceReady(hearingDevice->address); } for (auto& device : hearingDevices.devices) { if (device.conn_id && (device.connection_update_status == AWAITING)) { device.connection_update_status = STARTED; Loading Loading @@ -578,6 +575,24 @@ class HearingAidImpl : public HearingAid { } } void OnPhyUpdateEvent(uint16_t conn_id, uint8_t tx_phys, uint8_t rx_phys, tGATT_STATUS status) { HearingDevice* hearingDevice = hearingDevices.FindByConnId(conn_id); if (!hearingDevice) { DVLOG(2) << "Skipping unknown device, conn_id=" << loghex(conn_id); return; } if (status == GATT_SUCCESS && tx_phys == PHY_LE_2M && rx_phys == PHY_LE_2M) { LOG(INFO) << hearingDevice->address << " phy update to 2M successful"; return; } LOG(INFO) << hearingDevice->address << " phy update to 2M fail, try again. status: " << status << ", tx_phys: " << tx_phys << ", rx_phys: " << rx_phys; BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0); } void OnServiceChangeEvent(const RawAddress& address) { HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); if (!hearingDevice) { Loading Loading @@ -875,6 +890,15 @@ class HearingAidImpl : public HearingAid { void ConnectSocket(HearingDevice* hearingDevice, uint16_t psm) { tL2CAP_CFG_INFO cfg_info = tL2CAP_CFG_INFO{.mtu = 512}; if (controller_get_interface()->supports_ble_2m_phy()) { LOG(INFO) << hearingDevice->address << " set preferred PHY to 2M"; BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0); } // Set data length // TODO(jpawlowski: for 16khz only 87 is required, optimize BTM_SetBleDataLength(hearingDevice->address, 167); SendEnableServiceChangedInd(hearingDevice); uint8_t service_id = hearingDevice->isLeft() Loading Loading @@ -915,8 +939,8 @@ class HearingAidImpl : public HearingAid { instance->OnPsmRead(conn_id, status, handle, len, value, data); } /* CoC Socket is ready */ void OnGapConnection(const RawAddress& address) { /* CoC Socket, BLE connection parameter are ready */ void OnDeviceReady(const RawAddress& address) { HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); if (!hearingDevice) { LOG(INFO) << "Device not connected to profile" << address; Loading Loading @@ -1398,7 +1422,16 @@ class HearingAidImpl : public HearingAid { LOG(INFO) << "GAP_EVT_CONN_OPENED " << address << ", tx_mtu=" << tx_mtu << ", init_credit=" << init_credit; OnGapConnection(address); HearingDevice* hearingDevice = hearingDevices.FindByAddress(address); if (!hearingDevice) { LOG(INFO) << "Skipping unknown device" << address; return; } hearingDevice->gap_opened = true; if (hearingDevice->connection_update_status == COMPLETED) { OnDeviceReady(address); } break; } Loading @@ -1417,6 +1450,7 @@ class HearingAidImpl : public HearingAid { hearingDevice->accepting_audio = false; hearingDevice->playback_started = false; hearingDevice->command_acked = false; hearingDevice->gap_opened = false; } break; case GAP_EVT_CONN_DATA_AVAIL: { Loading Loading @@ -1631,6 +1665,7 @@ class HearingAidImpl : public HearingAid { } } hearingDevice->connection_update_status = NONE; hearingDevice->gap_opened = false; if (hearingDevice->conn_id) { BtaGattQueue::Clean(hearingDevice->conn_id); Loading Loading @@ -1850,6 +1885,12 @@ void hearingaid_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data) { if (!instance) return; instance->OnServiceDiscDoneEvent(p_data->service_changed.remote_bda); break; case BTA_GATTC_PHY_UPDATE_EVT: { if (!instance) return; tBTA_GATTC_PHY_UPDATE& p = p_data->phy_update; instance->OnPhyUpdateEvent(p.conn_id, p.tx_phy, p.rx_phy, p.status); break; } default: break; Loading