mirror of
https://github.com/appium/appium.git
synced 2026-02-11 20:39:04 -06:00
Merge pull request #2177 from jlipps/master
ensure that app is always force-stopped before uninstalling apk (fix #17...
This commit is contained in:
@@ -1268,21 +1268,25 @@ ADB.prototype.waitForNotActivity = function (pkg, act, waitMs, cb) {
|
||||
|
||||
ADB.prototype.uninstallApk = function (pkg, cb) {
|
||||
logger.info("Uninstalling " + pkg);
|
||||
this.exec("uninstall " + pkg, {timeout: 20000}, function (err, stdout) {
|
||||
if (err) {
|
||||
logger.error(err);
|
||||
cb(err);
|
||||
} else {
|
||||
stdout = stdout.trim();
|
||||
// stdout may contain warnings meaning success is not on the first line.
|
||||
if (stdout.indexOf("Success") !== -1) {
|
||||
logger.debug("App was uninstalled");
|
||||
this.forceStop(pkg, function (err) {
|
||||
if (err) logger.info("Force-stopping before uninstall didn't work; " +
|
||||
"maybe app wasn't running");
|
||||
this.exec("uninstall " + pkg, {timeout: 20000}, function (err, stdout) {
|
||||
if (err) {
|
||||
logger.error(err);
|
||||
cb(err);
|
||||
} else {
|
||||
logger.debug("App was not uninstalled, maybe it wasn't on device?");
|
||||
stdout = stdout.trim();
|
||||
// stdout may contain warnings meaning success is not on the first line.
|
||||
if (stdout.indexOf("Success") !== -1) {
|
||||
logger.debug("App was uninstalled");
|
||||
} else {
|
||||
logger.debug("App was not uninstalled, maybe it wasn't on device?");
|
||||
}
|
||||
cb();
|
||||
}
|
||||
cb();
|
||||
}
|
||||
});
|
||||
});
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
ADB.prototype.installRemote = function (remoteApk, cb) {
|
||||
|
||||
@@ -337,12 +337,9 @@ androidCommon.resetApp = function (cb) {
|
||||
if (!remoteApk) {
|
||||
return cb(new Error("Can't run reset if remote apk doesn't exist"));
|
||||
}
|
||||
this.adb.forceStop(this.args.appPackage, function (err) {
|
||||
this.adb.uninstallApk(this.args.appPackage, function (err) {
|
||||
if (err) return cb(err);
|
||||
this.adb.uninstallApk(this.args.appPackage, function (err) {
|
||||
if (err) return cb(err);
|
||||
this.adb.installRemote(remoteApk, cb);
|
||||
}.bind(this));
|
||||
this.adb.installRemote(remoteApk, cb);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user