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
This commit is contained in:
Etan Cohen
2015-03-31 12:45:23 -07:00
parent eb864d4000
commit 50d4761830

View File

@@ -104,6 +104,7 @@ public final class CachedBluetoothDevice implements Comparable<CachedBluetoothDe
// 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 @@ public final class CachedBluetoothDevice implements Comparable<CachedBluetoothDe
*/
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 @@ public final class CachedBluetoothDevice implements Comparable<CachedBluetoothDe
* 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();