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

Commit b03762a0 authored by Nitin Srivastava's avatar Nitin Srivastava
Browse files

Bluetooth: Added null check condtion.

Added null check for mCurrentDevice to
avoid any null pointer exception due to
invalid access to mCurrentDevice.

CRs-Fixed: 579061
Change-Id: Id03adde6472fa957b9beb198e7f46000e91cb27d
parent 51f081eb
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1203,6 +1203,14 @@ final class HeadsetStateMachine extends StateMachine {
            }

            if (currentState == mConnected || currentState == mAudioOn) {
                // Added safe check for mCurrentDevice as voice call use
                // cases can call this function with valid device due to
                // delay in state transition from connected to disconnected.
                // This may trigger null pointer exception here since
                // we set mCurrentDevice to null soon after disconnect,
                // but it can be calld before we move to disconnected state
                // in BT regression tests.
                if (mCurrentDevice != null)
                    if (mCurrentDevice.equals(device)) {
                        return BluetoothProfile.STATE_CONNECTED;
                    }
@@ -1217,7 +1225,7 @@ final class HeadsetStateMachine extends StateMachine {
    List<BluetoothDevice> getConnectedDevices() {
        List<BluetoothDevice> devices = new ArrayList<BluetoothDevice>();
        synchronized(this) {
            if (isConnected()) {
            if (isConnected() && (mCurrentDevice != null)) { /* Check for mCurrentDevice too*/
                devices.add(mCurrentDevice);
            }
        }