From ca33f5b69673d65ebca55378550f4028884b5f96 Mon Sep 17 00:00:00 2001 From: Stanley Tng Date: Thu, 2 May 2019 10:36:40 -0700 Subject: Increase the timeout for Hearing Aids Pairing Some device will need a longer time to do its service discovery process and therefore, need a longer timeout. This is especially true for the second device where the connection interval is increased. Bug: 131835452 Test: Manual Change-Id: I2e0821e30a0f08a4a123b8b5447a8b44c8830f9a Merged-In: I2e0821e30a0f08a4a123b8b5447a8b44c8830f9a (cherry picked from commit 8ce72cf350eec6beeabb03353bf07541a8f2671c) (cherry picked from commit 5489a5fbc1eb02bf929b11dc89238e90030a799f) --- .../com/android/settingslib/bluetooth/CachedBluetoothDevice.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index ff34578d0fea..1d351a5e53b6 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -50,6 +50,8 @@ public class CachedBluetoothDevice implements Comparable // See mConnectAttempted private static final long MAX_UUID_DELAY_FOR_AUTO_CONNECT = 5000; + // Some Hearing Aids (especially the 2nd device) needs more time to do service discovery + private static final long MAX_HEARING_AIDS_DELAY_FOR_AUTO_CONNECT = 15000; private static final long MAX_HOGP_DELAY_FOR_AUTO_CONNECT = 30000; private final Context mContext; @@ -223,7 +225,7 @@ public class CachedBluetoothDevice implements Comparable // various profiles // If UUIDs are not available yet, connect will be happen // upon arrival of the ACTION_UUID intent. - Log.d(TAG, "No profiles. Maybe we will connect later"); + Log.d(TAG, "No profiles. Maybe we will connect later for device " + mDevice); return; } @@ -608,10 +610,12 @@ public class CachedBluetoothDevice implements Comparable long timeout = MAX_UUID_DELAY_FOR_AUTO_CONNECT; if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Hogp)) { timeout = MAX_HOGP_DELAY_FOR_AUTO_CONNECT; + } else if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.HearingAid)) { + timeout = MAX_HEARING_AIDS_DELAY_FOR_AUTO_CONNECT; } if (BluetoothUtils.D) { - Log.d(TAG, "onUuidChanged: Time since last connect" + Log.d(TAG, "onUuidChanged: Time since last connect=" + (SystemClock.elapsedRealtime() - mConnectAttempted)); } -- cgit v1.2.3-59-g8ed1b