mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
android: Don't error if ADB is already running as root
With recent versions of adb, adb root can fail if the daemon is already running as root. Check the raised error message for this case and avoid raising an error in this scenario.
This commit is contained in:
parent
1196e336a5
commit
a585426924
@ -385,9 +385,18 @@ class AdbConnection(ConnectionBase):
|
|||||||
|
|
||||||
def adb_root(self, enable=True):
|
def adb_root(self, enable=True):
|
||||||
cmd = 'root' if enable else 'unroot'
|
cmd = 'root' if enable else 'unroot'
|
||||||
output = adb_command(self.device, cmd, timeout=30, adb_server=self.adb_server)
|
try:
|
||||||
if 'cannot run as root in production builds' in output:
|
output = adb_command(self.device, cmd, timeout=30, adb_server=self.adb_server)
|
||||||
raise TargetStableError(output)
|
except subprocess.CalledProcessError as e:
|
||||||
|
# Ignore if we're already root
|
||||||
|
if 'adbd is already running as root' in e.output:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
# Check separately as this does not cause a error exit code.
|
||||||
|
if 'cannot run as root in production builds' in output:
|
||||||
|
raise TargetStableError(output)
|
||||||
AdbConnection._connected_as_root[self.device] = enable
|
AdbConnection._connected_as_root[self.device] = enable
|
||||||
|
|
||||||
def wait_for_device(self, timeout=30):
|
def wait_for_device(self, timeout=30):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user