Skip to content

Commit

Permalink
timeoutexception, NullPointerException, Sparse on null object reference
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjivaniNaiknavare committed Sep 21, 2021
1 parent 7c7a86c commit 3f9bfdd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,10 @@ private void invokeMethodUIThread(final String name, final byte[] byteArray)
new Runnable() {
@Override
public void run() {
channel.invokeMethod(name, byteArray);
if(channel!=null)
{
channel.invokeMethod(name, byteArray);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ static Protos.ScanResult from(BluetoothDevice device, ScanResult scanResult) {
}
// Manufacturer Specific Data
SparseArray<byte[]> msd = scanRecord.getManufacturerSpecificData();
for (int i = 0; i < msd.size(); i++) {
if(msd!=null)
{
for (int i = 0; i < msd.size(); i++)
{
int key = msd.keyAt(i);
byte[] value = msd.valueAt(i);
a.putManufacturerData(key, ByteString.copyFrom(value));
}
}
// Service Data
Map<ParcelUuid, byte[]> serviceData = scanRecord.getServiceData();
Expand Down Expand Up @@ -205,4 +209,4 @@ static Protos.DeviceStateResponse from(BluetoothDevice device, int state) {
p.setRemoteId(device.getAddress());
return p.build();
}
}
}
2 changes: 1 addition & 1 deletion lib/src/bluetooth_device.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BluetoothDevice {
if (timeout != null) {
timer = Timer(timeout, () {
disconnect();
throw TimeoutException('Failed to connect in time.', timeout);

});
}

Expand Down

0 comments on commit 3f9bfdd

Please sign in to comment.