Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Bug 794546 - add uninstallApp method to devicemanager which does not …
Browse files Browse the repository at this point in the history
…do a reboot. r=wlach
  • Loading branch information
jmaher committed Sep 27, 2012
1 parent 4d43867 commit 9f222fa
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 15 deletions.
19 changes: 14 additions & 5 deletions mozdevice/mozdevice/devicemanager.py
Expand Up @@ -495,19 +495,28 @@ def installApp(self, appBundlePath, destPath=None):
failure: error string
"""

@abstractmethod
def uninstallApp(self, appName, installPath=None):
"""
Uninstalls the named application from device and DOES NOT cause a reboot
appName - the name of the application (e.g org.mozilla.fennec)
installPath - the path to where the application was installed (optional)
returns:
success: None
failure: DMError exception thrown
"""

@abstractmethod
def uninstallAppAndReboot(self, appName, installPath=None):
"""
Uninstalls the named application from device and causes a reboot
appName - the name of the application (e.g org.mozilla.fennec)
installPath - the path to where the application was installed (optional)
Returns True, but it doesn't mean anything other than the command was sent,
the reboot happens and we don't know if this succeeds or not
returns:
success: True
failure: None
success: None
failure: DMError exception thrown
"""

@abstractmethod
Expand Down
33 changes: 31 additions & 2 deletions mozdevice/mozdevice/devicemanagerADB.py
Expand Up @@ -806,6 +806,36 @@ def getInfo(self, directive=None):
print ret
return ret

def uninstallApp(self, appName, installPath=None):
"""
Uninstalls the named application from device and DOES NOT cause a reboot
appName - the name of the application (e.g org.mozilla.fennec)
installPath - ignored, but used for compatibility with SUTAgent
returns:
success: None
failure: DMError exception thrown
"""
data = self._runCmd(["uninstall", appName]).stdout.read().strip()
status = data.split('\n')[0].strip()
if status == 'Success':
return
raise DMError("uninstall failed for %s" % appName)

def uninstallAppAndReboot(self, appName, installPath=None):
"""
Uninstalls the named application from device and causes a reboot
appName - the name of the application (e.g org.mozilla.fennec)
installPath - ignored, but used for compatibility with SUTAgent
returns:
success: None
failure: DMError exception thrown
"""
results = self.uninstallApp(appName)
self.reboot()
return

def _runCmd(self, args):
"""
Runs a command using adb
Expand Down Expand Up @@ -940,8 +970,7 @@ def _verifyDevice(self):
if deviceStatus == None:
raise DMError("device not found: %s" % self.deviceSerial)
elif deviceStatus != "device":
raise DMError("bad status for device %s: %s" % (self.deviceSerial,
deviceStatus))
raise DMError("bad status for device %s: %s" % (self.deviceSerial, deviceStatus))

# Check to see if we can connect to device and run a simple command
try:
Expand Down
38 changes: 30 additions & 8 deletions mozdevice/mozdevice/devicemanagerSUT.py
Expand Up @@ -12,7 +12,7 @@
import subprocess
from threading import Thread
import StringIO
from devicemanager import DeviceManager, FileError, NetworkTools, _pop_last_line
from devicemanager import DeviceManager, FileError, DMError, NetworkTools, _pop_last_line
import errno
from distutils.version import StrictVersion

Expand Down Expand Up @@ -1149,30 +1149,52 @@ def installApp(self, appBundlePath, destPath=None):
return line
return None

def uninstallApp(self, appName, installPath=None):
"""
Uninstalls the named application from device and DOES NOT cause a reboot
appName - the name of the application (e.g org.mozilla.fennec)
installPath - the path to where the application was installed (optional)
returns:
success: None
failure: DMError exception thrown
"""
cmd = 'uninstall ' + appName
if installPath:
cmd += ' ' + installPath
try:
data = self._runCmds([{ 'cmd': cmd }])
except AgentError, err:
raise DMError("Remote Device Error: Error uninstalling all %s" % appName)

status = data.split('\n')[0].strip()
if self.debug > 3:
print "uninstallApp: '%s'" % status
if status == 'Success':
return
raise DMError("Remote Device Error: uninstall failed for %s" % appName)

def uninstallAppAndReboot(self, appName, installPath=None):
"""
Uninstalls the named application from device and causes a reboot
appName - the name of the application (e.g org.mozilla.fennec)
installPath - the path to where the application was installed (optional)
Returns True, but it doesn't mean anything other than the command was sent,
the reboot happens and we don't know if this succeeds or not
returns:
success: True
failure: None
success: None
failure: DMError exception thrown
"""
cmd = 'uninst ' + appName
if installPath:
cmd += ' ' + installPath
try:
data = self._runCmds([{ 'cmd': cmd }])
except AgentError:
return None
raise DMError("Remote Device Error: uninstall failed for %s" % appName)

if (self.debug > 3):
print "uninstallAppAndReboot: " + str(data)
return True
return

def updateApp(self, appBundlePath, processName=None, destPath=None, ipAddr=None, port=30000):
"""
Expand Down

0 comments on commit 9f222fa

Please sign in to comment.