From fc75374b0afeac5ad1f0217299bbbe3c29a015c0 Mon Sep 17 00:00:00 2001 From: Nitin Arora Date: Fri, 11 Jul 2014 14:56:06 -0700 Subject: [PATCH] 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 --- .../settings/bluetooth/CachedBluetoothDevice.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java index f33f4db2bc7..c8b9c5b2256 100755 --- a/src/com/android/settings/bluetooth/CachedBluetoothDevice.java +++ b/src/com/android/settings/bluetooth/CachedBluetoothDevice.java @@ -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 { // 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 { */ 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 { * 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();