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 15efc0e2a72294765626ce97fa5ace879f4b8702..51937b7faa6999f7c125188aa7a5e1be35f4c861 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) {