File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -717,6 +717,15 @@ def get_xcode_version():
717717
718718 return version
719719
720+ def app_is_installed (adb_cmd , pack_name ):
721+ list_pack_cmd = "%s shell 'pm list packages'" % (adb_cmd )
722+ desired_name = "package:%s" % (pack_name )
723+ child = subprocess .Popen (list_pack_cmd , stdout = subprocess .PIPE , shell = True )
724+ for line in child .stdout :
725+ if desired_name == line .strip ():
726+ return True
727+ return False
728+
720729def version_compare (a , op , b ):
721730 '''Compares two version numbers to see if a op b is true
722731
Original file line number Diff line number Diff line change @@ -161,9 +161,10 @@ def deploy_android(self, dependencies):
161161 adb_path = cocos .CMDRunner .convert_path_to_cmd (os .path .join (sdk_root , 'platform-tools' , 'adb' ))
162162
163163 if not self ._no_uninstall :
164- #TODO detect if the application is installed before running this
165- adb_uninstall = "%s uninstall %s" % (adb_path , self .package )
166- self ._run_cmd (adb_uninstall )
164+ # do uninstall only when that app is installed
165+ if cocos .app_is_installed (adb_path , self .package ):
166+ adb_uninstall = "%s uninstall %s" % (adb_path , self .package )
167+ self ._run_cmd (adb_uninstall )
167168
168169 adb_install = "%s install -r \" %s\" " % (adb_path , apk_path )
169170 self ._run_cmd (adb_install )
You can’t perform that action at this time.
0 commit comments