Guesstimate installation progress.

This commit is contained in:
Simo Kinnunen
2014-04-04 18:01:00 +09:00
parent 44378e625f
commit 317bdf5438

View File

@@ -58,8 +58,8 @@ module.exports = syrup.serial()
// Progress 0% to 70%
sendProgress(
'pushing_app'
, 70 * Math.max(0, Math.min(
70
, 50 * Math.max(0, Math.min(
50
, stats.bytesTransferred / contentLength
))
)
@@ -90,9 +90,22 @@ module.exports = syrup.serial()
sendProgress('pushing_app', 0)
pushApp()
.then(function(apk) {
// Progress 80%
sendProgress('installing_app', 80)
return adb.installRemote(options.serial, apk)
var start = 50
, end = 90
, guesstimate = start
sendProgress('installing_app', guesstimate)
return promiseutil.periodicNotify(
adb.installRemote(options.serial, apk)
, 1000
)
.progressed(function() {
guesstimate = Math.min(
end
, guesstimate + 5 * (end - guesstimate) / (end - start)
)
sendProgress('installing_app', guesstimate)
})
})
.timeout(30000)
.then(function() {