源码如下:
def _install_uiautomator_apks(self):
""" use uiautomator 2.0 to run uiautomator test
通常在连接USB数据线的情况下调用
"""
self.shell("pm", "uninstall", "com.github.uiautomator")
self.shell("pm", "uninstall", "com.github.uiautomator.test")
for filename, url in app_uiautomator_apk_urls():
path = self.push_url(url, mode=0o644)
self.shell("pm", "install", "-r", "-t", path)
self.logger.info("- %s installed", filename)
其中self.shell("pm", "uninstall", "com.github.uiautomator")
表示卸载一个应用.
self.shell("pm", "install", "-r", "-t", path)
表示安装一个应用, -r
表示重新安装, -t
表示允许安装测试应用.