mirror of
https://github.com/mik3y/usb-serial-for-android.git
synced 2026-08-22 22:02:55 +00:00
open(): Set mConnection eagerly, and clear on failure.
Similar to CdcAcmSerialDriver. Issue #53.
This commit is contained in:
@@ -243,6 +243,7 @@ public class FtdiSerialDriver implements UsbSerialDriver {
|
|||||||
if (mConnection != null) {
|
if (mConnection != null) {
|
||||||
throw new IOException("Already open");
|
throw new IOException("Already open");
|
||||||
}
|
}
|
||||||
|
mConnection = connection;
|
||||||
|
|
||||||
boolean opened = false;
|
boolean opened = false;
|
||||||
try {
|
try {
|
||||||
@@ -258,8 +259,7 @@ public class FtdiSerialDriver implements UsbSerialDriver {
|
|||||||
} finally {
|
} finally {
|
||||||
if (!opened) {
|
if (!opened) {
|
||||||
close();
|
close();
|
||||||
} else {
|
mConnection = null;
|
||||||
mConnection = connection;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user