Skip to content

Commit 0a91007

Browse files
douglas-raillard-armmarcbonnici
authored andcommitted
utils/android: Fix adb_root() exceptions
Ensure adb_root() always raises AdbRootError so that the caller can catch it reliably. This is especially important since adb_root() failing is ignored and simply triggers a fallback on using `su`. Android production builds refuse adb root nowadays, so it's important that adb root failures are handled well.
1 parent 4b13ee7 commit 0a91007

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

devlib/utils/android.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,11 @@ def adb_root(self, enable=True):
411411
if 'adbd is already running as root' in e.output:
412412
pass
413413
else:
414-
raise
414+
raise AdbRootError(str(e)) from e
415415
else:
416416
# Check separately as this does not cause a error exit code.
417417
if 'cannot run as root in production builds' in output:
418-
raise TargetStableError(output)
418+
raise AdbRootError(output)
419419
AdbConnection._connected_as_root[self.device] = enable
420420

421421
def wait_for_device(self, timeout=30):

0 commit comments

Comments
 (0)