Samsung Galaxy S4 BLE Bluetooth GATT close, disconnect improper behaviour
<p>I'm working on BLE based android application. Where I'm testing it on Samsung S4.
When I close application from recent app list, what app do is close Bluetooth GATT.  </p>

<p>Problem is if I unpair bluetooth device from the bluetooth setting. Then on second try if user try to disconnect connection it also closes Bluetooth Gatt or On closing BluetoothGatt it doen't close the bluetooth gatt. 
<strong>So, the behavior of Bluetooth gatt operation is very unstable on Samsung S4.</strong> </p>

<pre><code>private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { 
    @Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { 

        if (status == BluetoothGatt.GATT_SUCCESS
                            &amp;&amp; newState == BluetoothProfile.STATE_CONNECTED) {
            // Do something
        } else if (status == BluetoothGatt.GATT_SUCCESS
                            &amp;&amp; newState == BluetoothProfile.STATE_DISCONNECTED) {
            mBluetoothDeviceAddress = null;
            mBluetoothGatt.disconnect();
            mBluetoothGatt.close();
            //....

        } else if (status != BluetoothGatt.GATT_SUCCESS) { 
            mBluetoothDeviceAddress = null;
            mBluetoothGatt.disconnect();
            mBluetoothGatt.close();
            //...
        }

    }   
}
</code></pre>

<p>To disconnect Bluetooth connection.</p>

<pre><code>public void disconnect() {
    if (mBtAdapter == null) {
        Log.w(TAG, "disconnect: BluetoothAdapter not initialized");
        return;
    }

    if (mBluetoothGatt != null) {
        Log.i(TAG, "disconnect");

        // mBluetoothGatt.disconnect();
        new Handler(Looper.getMainLooper()).post(new Runnable() {

            @Override
            public void run() {
                mBluetoothGatt.disconnect();
            }
        });

    }
}
</code></pre>

<p>To close bluetooth gatt.</p>

<pre><code>public void close() {
    if (mBluetoothGatt != null) {
        if (mBluetoothDeviceAddress != null) {
            Log.i(TAG, "close");

            mBluetoothGatt.disconnect();
            mBluetoothGatt.close();

            // mBluetoothGatt.close();

        }
        mBluetoothGatt = null;
    }
}
</code></pre>

<p>I'm performing all this <strong>BluetoothGatt related operation on service.</strong></p>

<p><strong>Device: Samsung S4<br>
Android version: 5.0.1<br>
Build number: LRX22C.19500XXUHOK2</strong></p>