Merge (manually) pag/209446: Increase allowed duration to connect to HOGP profile
Original file was moved from packages/apps/Settings to frameworks/base.
Change-Id: I26912c0461780a255281a135c60cc0da2d25ae5a
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index e1cb878..64b4452 100755
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -104,6 +104,7 @@
// 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;
@@ -525,9 +526,11 @@
*/
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));
}
@@ -535,9 +538,11 @@
* 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();