Fix flakiness caused by checking adb root status.

Remove the check from root_adb.
Add a retry for is_adb_root.

This was cherry picked from AOSP:

Test: $ python3 test; python test
      Ran ACTS on two test beds with two different devices in
      parallel, each test run finished correctly.

Change-Id: I6441e3bf3ad4bc794ff264718ac11b4156ff8b25
diff --git a/acts/framework/acts/controllers/ b/acts/framework/acts/controllers/
index 1ede492..3b2133c 100644
--- a/acts/framework/acts/controllers/
+++ b/acts/framework/acts/controllers/
@@ -360,7 +360,12 @@
     def is_adb_root(self):
         """True if adb is running as root for this device.
-        return "root" in"id -u").decode("utf-8")
+        try:
+            return "0" =="id -u").decode("utf-8").strip()
+        except adb.AdbError:
+            # Wait a bit and retry to work around adb flakiness for this cmd.
+            time.sleep(0.2)
+            return "0" =="id -u").decode("utf-8").strip()
     def model(self):
@@ -458,11 +463,13 @@
             setattr(self, k, v)
     def root_adb(self):
-        """Change adb to root mode for this device.
+        """Change adb to root mode for this device if allowed.
+        If executed on a production build, adb will not be switched to root
+        mode per security restrictions.
-        if not self.is_adb_root:
-            self.adb.root()
-            self.adb.wait_for_device()
+        self.adb.root()
+        self.adb.wait_for_device()
     def get_droid(self, handle_event=True):
         """Create an sl4a connection to the device.