From 66eaf15cdc2d5da8d0e0964c81c2aa525fa13c68 Mon Sep 17 00:00:00 2001
From: Ionela Voinescu <ionela.voinescu@arm.com>
Date: Fri, 24 Feb 2017 14:19:25 +0000
Subject: [PATCH] android: add support for forced adb root

When rebooting a platform the internal connection state becomes
different from _connected_as_root, which was set before reboot.

Add the possibility to force adb root if you've rebooted or know
to have done something that would result in the platform having
a different connection state than the one of _connected_as_root.

Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com>
---
 devlib/target.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/devlib/target.py b/devlib/target.py
index 5b6f6ad..8523b25 100644
--- a/devlib/target.py
+++ b/devlib/target.py
@@ -1040,9 +1040,9 @@ class AndroidTarget(Target):
     def adb_reboot_bootloader(self, timeout=30):
         adb_command(self.adb_name, 'reboot-bootloader', timeout)
 
-    def adb_root(self, enable=True):
+    def adb_root(self, enable=True, force=False):
         if enable:
-            if self._connected_as_root:
+            if self._connected_as_root and not force:
                 return
             adb_command(self.adb_name, 'root', timeout=30)
             self._connected_as_root = True