if installing a remote apk fails, uninstall/rm and retry (fix #2188)

This commit is contained in:
Jonathan Lipps
2014-04-04 15:43:28 -07:00
parent 9dfad1a323
commit 645cc62d61
+22 -1
View File
@@ -426,7 +426,7 @@ androidCommon.installApp = function (cb) {
if (err) return cb(err);
var install = function (err) {
if (err) return cb(err);
this.adb.installRemote(remoteApk, cb);
this.installRemoteWithRetry(remoteApk, cb);
}.bind(this);
if (appExists) {
install();
@@ -444,6 +444,27 @@ androidCommon.installApp = function (cb) {
}.bind(this));
};
androidCommon.installRemoteWithRetry = function (remoteApk, cb) {
this.adb.installRemote(remoteApk, function (err) {
if (err) {
logger.warn("Installing remote apk failed, going to uninstall and try " +
"again");
this.adb.uninstallApk(this.args.appPackage, function (err) {
if (err) logger.warn("Uninstalling apk failed, continuing");
this.removeTempApks([], function () {
this.adb.push(this.args.app, remoteApk, function (err) {
if (err) return cb(err);
logger.info("Attempting to install again for the last time");
this.adb.installRemote(remoteApk, cb);
}.bind(this));
}.bind(this));
}.bind(this));
} else {
cb();
}
}.bind(this));
};
androidCommon.getAppMd5 = function (cb) {
md5(this.args.app, function (err, md5Hash) {
if (err) return cb(err);