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

Commit 043295a2 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Bluetooth: Enforce BT state check during GATT close/disconnect"

parents 53026a04 b53d1d82
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) {