appium / appium-uiautomator2-driver

Appium driver for Android UIAutomator2
Apache License 2.0
519 stars 170 forks source link

fix: uninstall installed uia2 servers if they were greater than on-going session #796

Closed KazuCocoa closed 3 weeks ago

KazuCocoa commented 4 weeks ago

https://github.com/appium/appium/issues/19799#issuecomment-2181932720

The current UIA2 driver does not uninstall UIA2 servers on the device if they are newer than newly installed servers by the UIA2. It could cause old UIA2 driver with newer UIA2 servers on the device, which is a mismatch condition. It could cause unexpected behavior.   Maybe... this.adb.APP_INSTALL_STATE.NOT_INSTALLED condition should be this.adb.APP_INSTALL_STATE.NEWER_VERSION_INSTALLED to "uninstall" installed UIA2 servers?

It looks like sinon mock's expects, never, once etc might not be so reliable. Some could be not good. To improve condition check as test code, I have extracted condition check into two methods and added tests for them. At least shouldUninstallServerPackages and canInstallServerPackages tests should be reliable.

github-actions[bot] commented 3 weeks ago

:tada: This PR is included in version 3.5.7 :tada:

The release is available on:

Your semantic-release bot :package::rocket: