| 259 | |
| 260 | TouchConsumer.prototype._connectService = function() { |
| 261 | function tryConnect(times, delay) { |
| 262 | return adb.openLocal(options.serial, 'localabstract:minitouch') |
| 263 | .timeout(10000) |
| 264 | .then(function(out) { |
| 265 | return out |
| 266 | }) |
| 267 | .catch(function(err) { |
| 268 | if (/closed/.test(err.message) && times > 1) { |
| 269 | return Promise.delay(delay) |
| 270 | .then(function() { |
| 271 | return tryConnect(times - 1, delay * 2) |
| 272 | }) |
| 273 | } |
| 274 | return Promise.reject(err) |
| 275 | }) |
| 276 | } |
| 277 | log.info('Connecting to minitouch service') |
| 278 | // SH-03G can be very slow to start sometimes. Make sure we try long |
| 279 | // enough. |