altosdroid: Check for closed before writing/reading bluetooth
authorKeith Packard <keithp@keithp.com>
Tue, 10 May 2016 00:57:12 +0000 (17:57 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 12 May 2016 06:22:15 +0000 (23:22 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java

index 15efc0e..51937b7 100644 (file)
@@ -199,6 +199,8 @@ public class AltosBluetooth extends AltosDroidLink {
        }
 
        int write(byte[] buffer, int len) {
+               if (output == null)
+                       return -1;
                try {
                        output.write(buffer, 0, len);
                } catch (IOException ie) {
@@ -208,6 +210,8 @@ public class AltosBluetooth extends AltosDroidLink {
        }
 
        int read(byte[] buffer, int len) {
+               if (input == null)
+                       return -1;
                try {
                        return input.read(buffer, 0, len);
                } catch (IOException ie) {