From 0a910071f85ca357d4891e8543ea3398e655298c Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Fri, 3 Feb 2023 15:08:20 +0000 Subject: [PATCH] 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. --- devlib/utils/android.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devlib/utils/android.py b/devlib/utils/android.py index 1cecd06..b57910d 100755 --- a/devlib/utils/android.py +++ b/devlib/utils/android.py @@ -411,11 +411,11 @@ class AdbConnection(ConnectionBase): if 'adbd is already running as root' in e.output: pass else: - raise + raise AdbRootError(str(e)) from e 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) + raise AdbRootError(output) AdbConnection._connected_as_root[self.device] = enable def wait_for_device(self, timeout=30):