Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50d47618 authored by Etan Cohen's avatar Etan Cohen
Browse files

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
parent eb864d40
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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();