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

Commit fc75374b authored by Nitin Arora's avatar Nitin Arora Committed by Andre Eisenbach
Browse files

Increase allowed duration to connect to HOGP profile

This patch increases the duration allowed between the first device
connection attempt (immidiately after bonding) and profile connection
after service discovery from 5 seconds to 30 seconds to allow
HOGP connections for slow connection conditions.

Change-Id: Ia8a33a6ef8951d6e08b4a22837fcfdb70910112c
parent 22416075
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.bluetooth;

import android.bluetooth.BluetoothUuid;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
@@ -102,6 +103,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {

    // See mConnectAttempted
    private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000;
    private static final long MAX_HOGP_DELAY_FOR_AUTO_CONNECT = 30000;

    /** Auto-connect after pairing only if locally initiated. */
    private boolean mConnectAfterPairing;
@@ -523,9 +525,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
     */
    void onUuidChanged() {
        updateProfiles();
        ParcelUuid[] uuids = mDevice.getUuids();
        long timeout = MAX_UUID_DELAY_FOR_AUTO_CONNECT;

        if (DEBUG) {
            Log.e(TAG, "onUuidChanged: Time since last connect"
            Log.d(TAG, "onUuidChanged: Time since last connect"
                    + (SystemClock.elapsedRealtime() - mConnectAttempted));
        }

@@ -533,9 +537,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
         * If a connect was attempted earlier without any UUID, we will do the
         * connect now.
         */
        if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) {
            timeout = MAX_HOGP_DELAY_FOR_AUTO_CONNECT;
        }
        if (!mProfiles.isEmpty()
                && (mConnectAttempted + MAX_UUID_DELAY_FOR_AUTO_CONNECT) > SystemClock
                        .elapsedRealtime()) {
                && (mConnectAttempted + timeout) > SystemClock.elapsedRealtime()) {
            connectWithoutResettingTimer(false);
        }
        dispatchAttributesChanged();