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

Commit 2d1fc4e3 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Remove delay with auto connection.

SDP records are now registered with a dbus call so we don't have to wait
for initiating auto connections.

Also reduce time to connect other profiles case by 2 secs.

Change-Id: I8f0eab6a95d3bfaf11a8eb7495a024949639d7fc
parent ffdd591a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
    public static final int TRANSITION_TO_STABLE = 102;
    public static final int CONNECT_OTHER_PROFILES = 103;

    private static final int AUTO_CONNECT_DELAY = 6000; // 6 secs
    private static final int CONNECT_OTHER_PROFILES_DELAY = 4000; // 4 secs

    private BondedDevice mBondedDevice = new BondedDevice();
    private OutgoingHandsfree mOutgoingHandsfree = new OutgoingHandsfree();
@@ -152,7 +152,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
            } else if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
                Message msg = new Message();
                msg.what = AUTO_CONNECT_PROFILES;
                sendMessageDelayed(msg, AUTO_CONNECT_DELAY);
                sendMessage(msg);
            } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
                // This is technically not needed, but we can get stuck sometimes.
                // For example, if incoming A2DP fails, we are not informed by Bluez
@@ -1019,7 +1019,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                    Message msg = new Message();
                    msg.what = CONNECT_OTHER_PROFILES;
                    msg.arg1 = CONNECT_A2DP_OUTGOING;
                    sendMessageDelayed(msg, AUTO_CONNECT_DELAY);
                    sendMessageDelayed(msg, CONNECT_OTHER_PROFILES_DELAY);
                }
                break;
            case CONNECT_A2DP_INCOMING:
@@ -1031,7 +1031,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                    Message msg = new Message();
                    msg.what = CONNECT_OTHER_PROFILES;
                    msg.arg1 = CONNECT_HFP_OUTGOING;
                    sendMessageDelayed(msg, AUTO_CONNECT_DELAY);
                    sendMessageDelayed(msg, CONNECT_OTHER_PROFILES_DELAY);
                }
                break;
            default:
+6 −2
Original line number Diff line number Diff line
@@ -420,6 +420,11 @@ public class BluetoothService extends IBluetooth.Stub {
                                    BluetoothDevice.UNBOND_REASON_AUTH_CANCELED);
        }

        // Stop the profile state machine for bonded devices.
        for (String address : mBondState.listInState(BluetoothDevice.BOND_BONDED)) {
            removeProfileState(address);
        }

        // update mode
        Intent intent = new Intent(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
        intent.putExtra(BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothAdapter.SCAN_MODE_NONE);
@@ -2714,10 +2719,9 @@ public class BluetoothService extends IBluetooth.Stub {
        for (String path : bonds) {
            String address = getAddressFromObjectPath(path);
            BluetoothDeviceProfileState state = addProfileState(address);
            // Allow 8 secs for SDP records to get registered.
            Message msg = new Message();
            msg.what = BluetoothDeviceProfileState.AUTO_CONNECT_PROFILES;
            state.sendMessageDelayed(msg, 8000);
            state.sendMessage(msg);
        }
    }