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

Commit cdf3ce50 authored by Srinu Jella's avatar Srinu Jella Committed by Steve Kondik
Browse files

Bluetooth: Handle exceptions for bluetoot socket read

Handled IO exception in read function of BluetootSocket,
and also introduced a null check for mSocketIS.

CRs-Fixed: 605606
Change-Id: Ic948c72269e0de486a8f49163830528b002198ff
parent 3acfa0db
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -478,9 +478,15 @@ public final class BluetoothSocket implements Closeable {
    }

    /*package*/ int read(byte[] b, int offset, int length) throws IOException {

            int ret = -1;
            if (VDBG) Log.d(TAG, "read in:  " + mSocketIS + " len: " + length);
            int ret = mSocketIS.read(b, offset, length);
            if(mSocketIS != null) {
                try {
                    ret = mSocketIS.read(b, offset, length);
                } catch (IOException e) {
                    Log.e(TAG, "IOException while reading the InputStream");
                }
            }
            if(ret < 0)
                throw new IOException("bt socket closed, read return: " + ret);
            if (VDBG) Log.d(TAG, "read out:  " + mSocketIS + " ret: " + ret);