| 182 | } |
| 183 | |
| 184 | private void idle(IOIO ioio) { |
| 185 | if (interrupted()) |
| 186 | return; |
| 187 | |
| 188 | try { |
| 189 | if (listener.onIOIOIdle(ioio)) |
| 190 | return; |
| 191 | } catch (ConnectionLostException e) { |
| 192 | Log.w(TAG, "IOIO connection " + getName() + " lost"); |
| 193 | return; |
| 194 | } catch (InterruptedException e) { |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | if (interrupted()) |
| 199 | return; |
| 200 | |
| 201 | try { |
| 202 | if (ioio != null) { |
| 203 | /* there is a connection: wait for connection error or |
| 204 | until Thread.interrupt() gets called */ |
| 205 | ioio.waitForDisconnect(); |
| 206 | Log.w(TAG, "IOIO connection " + getName() + " lost"); |
| 207 | } else { |
| 208 | /* there is no connection: wait until Thread.interrupt() |
| 209 | gets called */ |
| 210 | synchronized(this) { |
| 211 | if (enabledFlag) |
| 212 | /* don't block here, we should instead open a new |
| 213 | connection */ |
| 214 | return; |
| 215 | |
| 216 | /* we're not actually waiting for an Object.notify() call, |
| 217 | this is just a dummy call to make this thread idle and |
| 218 | interruptible */ |
| 219 | wait(); |
| 220 | } |
| 221 | } |
| 222 | } catch (InterruptedException e) { |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * The connection thread. |