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

Commit 540aadf2 authored by Satish kumar sugasi's avatar Satish kumar sugasi Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Enforce BT state check during GATT close/disconnect

Enforce BT state check when BLE Apps call into GATT to handle scenarios in which
delayed call from BLE App to disconnect/close comes after the BT is OFF

CRs-Fixed: 759852
Change-Id: Iaf7004cdd4fe52e64c48838f6ed918e1d25f5a1e
parent ec7064fc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.bluetooth;

import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.os.ParcelUuid;
import android.os.RemoteException;
@@ -628,6 +629,8 @@ public final class BluetoothGatt implements BluetoothProfile {
    public void close() {
        if (DBG) Log.d(TAG, "close()");

        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        if (adapter.getState() != adapter.STATE_ON) return ;
        unregisterApp();
        mConnState = CONN_STATE_CLOSED;
    }
@@ -750,6 +753,8 @@ public final class BluetoothGatt implements BluetoothProfile {
        if (DBG) Log.d(TAG, "cancelOpen() - device: " + mDevice.getAddress());
        if (mService == null || mClientIf == 0) return;

        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
        if (adapter.getState() != adapter.STATE_ON) return ;
        try {
            mService.clientDisconnect(mClientIf, mDevice.getAddress());
        } catch (RemoteException e) {