Loading core/java/android/bluetooth/BluetoothLwPwrProximityMonitor.java +18 −1 Original line number Diff line number Diff line Loading @@ -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!"); Loading Loading @@ -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; Loading @@ -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){ Loading Loading @@ -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"); Loading Loading @@ -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); Loading Loading
core/java/android/bluetooth/BluetoothLwPwrProximityMonitor.java +18 −1 Original line number Diff line number Diff line Loading @@ -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!"); Loading Loading @@ -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; Loading @@ -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){ Loading Loading @@ -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"); Loading Loading @@ -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); Loading