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

Commit 470406db authored by Subramanian Srinivasan's avatar Subramanian Srinivasan Committed by Steve Kondik
Browse files

Bluetooth: Fix PXP LPP app link loss reconnection

When BLE link loss reconnection happens,the host is
not able to send Vendor specific commands
to the controller to start monitoring the RSSI
values.

CRs-fixed: 597822

Change-Id: I436889fae7f7d42c4f532690b726271ffc136e94
parent 6e9a8c77
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public final class BluetoothLwPwrProximityMonitor implements QBluetoothAdapter.
    /* This timer is triggered in case that BluetoothGatt does not callback when we perform connect/disconnect */
    private Timer     mTimer = null;
    private final int mTimeOutValue = 30*1000;
    public boolean isWriteThresholdNeedToBeCalled = false;
    private final class ConnectTimeOutTask extends TimerTask {
        public void run() {
            if (DBG) Log.d(TAG, "connect timer triggered!");
@@ -139,8 +140,9 @@ public final class BluetoothLwPwrProximityMonitor implements QBluetoothAdapter.
                        stop = true;
                    }
                } else if (newState == BluetoothProfile.STATE_CONNECTED) {
                    if (mState == MONITOR_STATE_STARTING) {
                    if (mState == MONITOR_STATE_STARTING && isWriteThresholdNeedToBeCalled) {
                        if (status == BluetoothGatt.GATT_SUCCESS) {
                            isWriteThresholdNeedToBeCalled = false;
                            if(!mQAdapter.writeRssiThreshold(BluetoothLwPwrProximityMonitor.this, mLowerLimit, mUpperLimit)) {
                                mGattProfile.disconnect();
                                mState = MONITOR_STATE_STOPPING;
@@ -151,6 +153,10 @@ public final class BluetoothLwPwrProximityMonitor implements QBluetoothAdapter.
                            stop = true;
                        }
                    }
                    if (status != BluetoothGatt.GATT_SUCCESS) {
                        mState = MONITOR_STATE_IDLE;
                        stop = true;
                    }
                }
            }
            if (stop && mMonitorCbk != null){
@@ -206,6 +212,7 @@ public final class BluetoothLwPwrProximityMonitor implements QBluetoothAdapter.
    /** @hide */
    public boolean start (int thresh_min, int thresh_max) {
        if (DBG) Log.d(TAG, "start() low=" + thresh_min + ", upper=" + thresh_max);
        isWriteThresholdNeedToBeCalled = true;
        synchronized(mStateLock){
            if (mState != MONITOR_STATE_IDLE) {
                if (DBG) Log.d(TAG, "start() invalid state, monitor is not idle");
@@ -233,6 +240,16 @@ public final class BluetoothLwPwrProximityMonitor implements QBluetoothAdapter.
                        mState = MONITOR_STATE_IDLE;
                        return false;
                    }
                    else {
                        if (mState == MONITOR_STATE_STARTING && isWriteThresholdNeedToBeCalled) {
                            isWriteThresholdNeedToBeCalled = false;
                            if(!mQAdapter.writeRssiThreshold(BluetoothLwPwrProximityMonitor.this, mLowerLimit, mUpperLimit)) {
                                mGattProfile.disconnect();
                                mState = MONITOR_STATE_STOPPING;
                                setTimer(BluetoothLwPwrProximityMonitor.this.new DisconnectTimeOutTask(), mTimeOutValue);
                            }
                        }
                    }
                }
            } catch (IllegalStateException e) {
                mQAdapter.registerLppClient(this, mDevice.getAddress(), false);