From 060a432d092bc3105ecd2b40b705efa921c289c5 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 20 Jun 2024 21:30:27 -0700 Subject: [PATCH] fix: uninstall installed uia2 servers if they were greater than on-going session --- lib/uiautomator2.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/uiautomator2.js b/lib/uiautomator2.js index d839a17c9..88ba2adcb 100644 --- a/lib/uiautomator2.js +++ b/lib/uiautomator2.js @@ -116,8 +116,9 @@ class UiAutomator2Server { ); this.log.debug(`Server packages status: ${JSON.stringify(packagesInfo)}`); - // Enforce server packages reinstall if any of the packages is not installed, while the other is - const shouldUninstallServerPackages = (packagesInfo.some(({installState}) => installState === this.adb.APP_INSTALL_STATE.NOT_INSTALLED) + // Enforce server packages reinstall if any of the packages is not installed, + // or newer one than uia2 driver is going to use. + const shouldUninstallServerPackages = (packagesInfo.some(({installState}) => installState === this.adb.APP_INSTALL_STATE.NEWER_VERSION_INSTALLED) && !packagesInfo.every(({installState}) => installState === this.adb.APP_INSTALL_STATE.NOT_INSTALLED)); // Install must always follow uninstall. Also, perform the install if // any of server packages is not installed or is outdated