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
This commit is contained in:
Nitin Arora
2014-07-11 14:56:06 -07:00
committed by Andre Eisenbach
parent 2241607570
commit fc75374b0a

View File

@@ -16,6 +16,7 @@
package com.android.settings.bluetooth; package com.android.settings.bluetooth;
import android.bluetooth.BluetoothUuid;
import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothProfile;
@@ -102,6 +103,7 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
// See mConnectAttempted // See mConnectAttempted
private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; 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. */ /** Auto-connect after pairing only if locally initiated. */
private boolean mConnectAfterPairing; private boolean mConnectAfterPairing;
@@ -523,9 +525,11 @@ final class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice> {
*/ */
void onUuidChanged() { void onUuidChanged() {
updateProfiles(); updateProfiles();
ParcelUuid[] uuids = mDevice.getUuids();
long timeout = MAX_UUID_DELAY_FOR_AUTO_CONNECT;
if (DEBUG) { if (DEBUG) {
Log.e(TAG, "onUuidChanged: Time since last connect" Log.d(TAG, "onUuidChanged: Time since last connect"
+ (SystemClock.elapsedRealtime() - mConnectAttempted)); + (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 * If a connect was attempted earlier without any UUID, we will do the
* connect now. * connect now.
*/ */
if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) {
timeout = MAX_HOGP_DELAY_FOR_AUTO_CONNECT;
}
if (!mProfiles.isEmpty() if (!mProfiles.isEmpty()
&& (mConnectAttempted + MAX_UUID_DELAY_FOR_AUTO_CONNECT) > SystemClock && (mConnectAttempted + timeout) > SystemClock.elapsedRealtime()) {
.elapsedRealtime()) {
connectWithoutResettingTimer(false); connectWithoutResettingTimer(false);
} }
dispatchAttributesChanged(); dispatchAttributesChanged();