Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 234b31a2 authored by Bhakthavatsala Raghavendra's avatar Bhakthavatsala Raghavendra
Browse files

Donot check bond state from profiles

Test: mmm packages/modules/Bluetooth
Flag:
com.android.bluetooth.flags.donot_validate_bond_state_from_profiles
Bug: 238353843
Bug: 353738134

Change-Id: I8dd7dbba8bd55e1caf55a95786ac1d5c9d718e8f
parent 195c247f
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -392,13 +392,16 @@ public class A2dpService extends ProfileService {
        }
        // Check connectionPolicy and accept or reject the connection.
        int connectionPolicy = getConnectionPolicy(device);
        if (!Flags.donotValidateBondStateFromProfiles()) {
            int bondState = mAdapterService.getBondState(device);
            // Allow this connection only if the device is bonded. Any attempt to connect while
            // bonding would potentially lead to an unauthorized connection.
            if (bondState != BluetoothDevice.BOND_BONDED) {
                Log.w(TAG, "okToConnect: return false, bondState=" + bondState);
                return false;
        } else if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
            }
        }
        if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
            && connectionPolicy != BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            if (!isOutgoingRequest) {
                HeadsetService headsetService = HeadsetService.getHeadsetService();
+10 −7
Original line number Diff line number Diff line
@@ -368,13 +368,16 @@ public class HearingAidService extends ProfileService {
        }
        // Check connection policy and accept or reject the connection.
        int connectionPolicy = getConnectionPolicy(device);
        if (!Flags.donotValidateBondStateFromProfiles()) {
            int bondState = mAdapterService.getBondState(device);
            // Allow this connection only if the device is bonded. Any attempt to connect while
            // bonding would potentially lead to an unauthorized connection.
            if (bondState != BluetoothDevice.BOND_BONDED) {
                Log.w(TAG, "okToConnect: return false, bondState=" + bondState);
                return false;
        } else if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
            }
        }
        if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
                && connectionPolicy != BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            // Otherwise, reject the connection if connectionPolicy is not valid.
            Log.w(TAG, "okToConnect: return false, connectionPolicy=" + connectionPolicy);
+11 −8
Original line number Diff line number Diff line
@@ -2426,13 +2426,16 @@ public class HeadsetService extends ProfileService {
        }
        // Check connection policy and accept or reject the connection.
        int connectionPolicy = getConnectionPolicy(device);
        if (!Flags.donotValidateBondStateFromProfiles()) {
            int bondState = mAdapterService.getBondState(device);
            // Allow this connection only if the device is bonded. Any attempt to connect while
            // bonding would potentially lead to an unauthorized connection.
            if (bondState != BluetoothDevice.BOND_BONDED) {
                Log.w(TAG, "okToAcceptConnection: return false, bondState=" + bondState);
                return false;
        } else if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
            }
        }
        if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
            && connectionPolicy != BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            // Otherwise, reject the connection if connection policy is not valid.
            if (!isOutgoingRequest) {
+11 −7
Original line number Diff line number Diff line
@@ -1469,13 +1469,17 @@ public class HidHostService extends ProfileService {
        }
        // Check connection policy and accept or reject the connection.
        int connectionPolicy = getConnectionPolicy(device);
        if (!Flags.donotValidateBondStateFromProfiles()) {
            int bondState = mAdapterService.getBondState(device);
        // Allow this connection only if the device is bonded. Any attempt to connect while
        // bonding would potentially lead to an unauthorized connection.
            // Allow this connection only if the device is bonded. Any attempt to connect
            // while bonding would potentially lead to an unauthorized connection.
            if (bondState != BluetoothDevice.BOND_BONDED) {
            Log.w(TAG, "okToConnect: return false, device=" + device + " bondState=" + bondState);
                Log.w(TAG, "okToConnect: return false, device=" + device + " bondState="
                    + bondState);
                return false;
        } else if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
            }
        }
        if (connectionPolicy != BluetoothProfile.CONNECTION_POLICY_UNKNOWN
                && connectionPolicy != BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
            // Otherwise, reject the connection if connectionPolicy is not valid.
            Log.w(