Loading android/app/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ <bool name="profile_supported_pbapclient">false</bool> <bool name="profile_supported_mapmce">false</bool> <bool name="profile_supported_hid_device">true</bool> <bool name="profile_supported_hearing_aid">true</bool> <bool name="profile_supported_hearing_aid">false</bool> <!-- If true, we will require location to be enabled on the device to fire Bluetooth LE scan result callbacks in addition to having one Loading android/app/src/com/android/bluetooth/a2dp/A2dpService.java +17 −11 Original line number Diff line number Diff line Loading @@ -346,19 +346,25 @@ public class A2dpService extends ProfileService { + " : too many connected devices"); return false; } // Check priority and accept or reject the connection // Check priority and accept or reject the connection. // Note: Logic can be simplified, but keeping it this way for readability int priority = getPriority(device); int bondState = mAdapterService.getBondState(device); // If priority is undefined, it is likely that our SDP has not completed and peer is // initiating the connection. Allow the connection only if the device is bonded or bonding. if ((priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_NONE)) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority + " bondState=" + bondState); return false; } if (priority <= BluetoothProfile.PRIORITY_OFF) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority); // If priority is undefined, it is likely that service discovery has not completed and peer // initiated the connection. Allow this connection only if the device is bonded or bonding boolean serviceDiscoveryPending = (priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_BONDING || bondState == BluetoothDevice.BOND_BONDED); // Also allow connection when device is bonded/bonding and priority is ON/AUTO_CONNECT. boolean isEnabled = (priority == BluetoothProfile.PRIORITY_ON || priority == BluetoothProfile.PRIORITY_AUTO_CONNECT) && (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_BONDING); if (!serviceDiscoveryPending && !isEnabled) { // Otherwise, reject the connection if no service discovery is pending and priority is // neither PRIORITY_ON nor PRIORITY_AUTO_CONNECT Log.w(TAG, "okToConnect: return false, priority=" + priority + ", bondState=" + bondState); return false; } return true; Loading android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.bluetooth.a2dp.A2dpService; Loading Loading @@ -392,4 +393,24 @@ class ActiveDeviceManager { mHearingAidActiveDevice = null; } @VisibleForTesting BroadcastReceiver getBroadcastReceiver() { return mReceiver; } @VisibleForTesting BluetoothDevice getA2dpActiveDevice() { return mA2dpActiveDevice; } @VisibleForTesting BluetoothDevice getHfpActiveDevice() { return mHfpActiveDevice; } @VisibleForTesting BluetoothDevice getHearingAidActiveDevice() { return mHearingAidActiveDevice; } } android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +17 −10 Original line number Diff line number Diff line Loading @@ -313,18 +313,25 @@ public class HearingAidService extends ProfileService { Log.e(TAG, "okToConnect: cannot connect to " + device + " : quiet mode enabled"); return false; } // Check priority and accept or reject the connection // Check priority and accept or reject the connection. // Note: Logic can be simplified, but keeping it this way for readability int priority = getPriority(device); int bondState = mAdapterService.getBondState(device); // Allow the connection only if the device is bonded or bonding. if ((priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_NONE)) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority + " bondState=" + bondState); return false; } if (priority <= BluetoothProfile.PRIORITY_OFF) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority); // If priority is undefined, it is likely that service discovery has not completed and peer // initiated the connection. Allow this connection only if the device is bonded or bonding boolean serviceDiscoveryPending = (priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_BONDING || bondState == BluetoothDevice.BOND_BONDED); // Also allow connection when device is bonded/bonding and priority is ON/AUTO_CONNECT. boolean isEnabled = (priority == BluetoothProfile.PRIORITY_ON || priority == BluetoothProfile.PRIORITY_AUTO_CONNECT) && (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_BONDING); if (!serviceDiscoveryPending && !isEnabled) { // Otherwise, reject the connection if no service discovery is pending and priority is // neither PRIORITY_ON nor PRIORITY_AUTO_CONNECT Log.w(TAG, "okToConnect: return false, priority=" + priority + ", bondState=" + bondState); return false; } return true; Loading android/app/src/com/android/bluetooth/hfp/HeadsetService.java +14 −9 Original line number Diff line number Diff line Loading @@ -1228,17 +1228,22 @@ public class HeadsetService extends ProfileService { // Note: Logic can be simplified, but keeping it this way for readability int priority = getPriority(device); int bondState = mAdapterService.getBondState(device); // If priority is undefined, it is likely that our SDP has not completed and peer is // initiating the connection. Allow this connection only if the device is bonded or bonding if ((priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_NONE)) { Log.w(TAG, "okToAcceptConnection: return false, priority=" + priority + ", bondState=" // If priority is undefined, it is likely that service discovery has not completed and peer // initiated the connection. Allow this connection only if the device is bonded or bonding boolean serviceDiscoveryPending = (priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_BONDING || bondState == BluetoothDevice.BOND_BONDED); // Also allow connection when device is bonded/bonding and priority is ON/AUTO_CONNECT. boolean isEnabled = (priority == BluetoothProfile.PRIORITY_ON || priority == BluetoothProfile.PRIORITY_AUTO_CONNECT) && (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_BONDING); if (!serviceDiscoveryPending && !isEnabled) { // Otherwise, reject the connection if no service discovery is pending and priority is // neither PRIORITY_ON nor PRIORITY_AUTO_CONNECT Log.w(TAG, "okToConnect: return false, priority=" + priority + ", bondState=" + bondState); return false; } else if (priority <= BluetoothProfile.PRIORITY_OFF) { // Otherwise, reject the connection if priority is less than or equal to PRIORITY_OFF Log.w(TAG, "okToAcceptConnection: return false, priority=" + priority); return false; } List<BluetoothDevice> connectingConnectedDevices = getDevicesMatchingConnectionStates(CONNECTING_CONNECTED_STATES); Loading Loading
android/app/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ <bool name="profile_supported_pbapclient">false</bool> <bool name="profile_supported_mapmce">false</bool> <bool name="profile_supported_hid_device">true</bool> <bool name="profile_supported_hearing_aid">true</bool> <bool name="profile_supported_hearing_aid">false</bool> <!-- If true, we will require location to be enabled on the device to fire Bluetooth LE scan result callbacks in addition to having one Loading
android/app/src/com/android/bluetooth/a2dp/A2dpService.java +17 −11 Original line number Diff line number Diff line Loading @@ -346,19 +346,25 @@ public class A2dpService extends ProfileService { + " : too many connected devices"); return false; } // Check priority and accept or reject the connection // Check priority and accept or reject the connection. // Note: Logic can be simplified, but keeping it this way for readability int priority = getPriority(device); int bondState = mAdapterService.getBondState(device); // If priority is undefined, it is likely that our SDP has not completed and peer is // initiating the connection. Allow the connection only if the device is bonded or bonding. if ((priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_NONE)) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority + " bondState=" + bondState); return false; } if (priority <= BluetoothProfile.PRIORITY_OFF) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority); // If priority is undefined, it is likely that service discovery has not completed and peer // initiated the connection. Allow this connection only if the device is bonded or bonding boolean serviceDiscoveryPending = (priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_BONDING || bondState == BluetoothDevice.BOND_BONDED); // Also allow connection when device is bonded/bonding and priority is ON/AUTO_CONNECT. boolean isEnabled = (priority == BluetoothProfile.PRIORITY_ON || priority == BluetoothProfile.PRIORITY_AUTO_CONNECT) && (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_BONDING); if (!serviceDiscoveryPending && !isEnabled) { // Otherwise, reject the connection if no service discovery is pending and priority is // neither PRIORITY_ON nor PRIORITY_AUTO_CONNECT Log.w(TAG, "okToConnect: return false, priority=" + priority + ", bondState=" + bondState); return false; } return true; Loading
android/app/src/com/android/bluetooth/btservice/ActiveDeviceManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; import android.support.annotation.VisibleForTesting; import android.util.Log; import com.android.bluetooth.a2dp.A2dpService; Loading Loading @@ -392,4 +393,24 @@ class ActiveDeviceManager { mHearingAidActiveDevice = null; } @VisibleForTesting BroadcastReceiver getBroadcastReceiver() { return mReceiver; } @VisibleForTesting BluetoothDevice getA2dpActiveDevice() { return mA2dpActiveDevice; } @VisibleForTesting BluetoothDevice getHfpActiveDevice() { return mHfpActiveDevice; } @VisibleForTesting BluetoothDevice getHearingAidActiveDevice() { return mHearingAidActiveDevice; } }
android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +17 −10 Original line number Diff line number Diff line Loading @@ -313,18 +313,25 @@ public class HearingAidService extends ProfileService { Log.e(TAG, "okToConnect: cannot connect to " + device + " : quiet mode enabled"); return false; } // Check priority and accept or reject the connection // Check priority and accept or reject the connection. // Note: Logic can be simplified, but keeping it this way for readability int priority = getPriority(device); int bondState = mAdapterService.getBondState(device); // Allow the connection only if the device is bonded or bonding. if ((priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_NONE)) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority + " bondState=" + bondState); return false; } if (priority <= BluetoothProfile.PRIORITY_OFF) { Log.e(TAG, "okToConnect: cannot connect to " + device + " : priority=" + priority); // If priority is undefined, it is likely that service discovery has not completed and peer // initiated the connection. Allow this connection only if the device is bonded or bonding boolean serviceDiscoveryPending = (priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_BONDING || bondState == BluetoothDevice.BOND_BONDED); // Also allow connection when device is bonded/bonding and priority is ON/AUTO_CONNECT. boolean isEnabled = (priority == BluetoothProfile.PRIORITY_ON || priority == BluetoothProfile.PRIORITY_AUTO_CONNECT) && (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_BONDING); if (!serviceDiscoveryPending && !isEnabled) { // Otherwise, reject the connection if no service discovery is pending and priority is // neither PRIORITY_ON nor PRIORITY_AUTO_CONNECT Log.w(TAG, "okToConnect: return false, priority=" + priority + ", bondState=" + bondState); return false; } return true; Loading
android/app/src/com/android/bluetooth/hfp/HeadsetService.java +14 −9 Original line number Diff line number Diff line Loading @@ -1228,17 +1228,22 @@ public class HeadsetService extends ProfileService { // Note: Logic can be simplified, but keeping it this way for readability int priority = getPriority(device); int bondState = mAdapterService.getBondState(device); // If priority is undefined, it is likely that our SDP has not completed and peer is // initiating the connection. Allow this connection only if the device is bonded or bonding if ((priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_NONE)) { Log.w(TAG, "okToAcceptConnection: return false, priority=" + priority + ", bondState=" // If priority is undefined, it is likely that service discovery has not completed and peer // initiated the connection. Allow this connection only if the device is bonded or bonding boolean serviceDiscoveryPending = (priority == BluetoothProfile.PRIORITY_UNDEFINED) && (bondState == BluetoothDevice.BOND_BONDING || bondState == BluetoothDevice.BOND_BONDED); // Also allow connection when device is bonded/bonding and priority is ON/AUTO_CONNECT. boolean isEnabled = (priority == BluetoothProfile.PRIORITY_ON || priority == BluetoothProfile.PRIORITY_AUTO_CONNECT) && (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_BONDING); if (!serviceDiscoveryPending && !isEnabled) { // Otherwise, reject the connection if no service discovery is pending and priority is // neither PRIORITY_ON nor PRIORITY_AUTO_CONNECT Log.w(TAG, "okToConnect: return false, priority=" + priority + ", bondState=" + bondState); return false; } else if (priority <= BluetoothProfile.PRIORITY_OFF) { // Otherwise, reject the connection if priority is less than or equal to PRIORITY_OFF Log.w(TAG, "okToAcceptConnection: return false, priority=" + priority); return false; } List<BluetoothDevice> connectingConnectedDevices = getDevicesMatchingConnectionStates(CONNECTING_CONNECTED_STATES); Loading