Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Unified Diff: build/android/gyp/util/build_device.py

Issue 285143002: [Android] Convert to DeviceUtils versions of IsOnline, HasRoot, and EnableRoot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build/android/gyp/util/build_device.py
diff --git a/build/android/gyp/util/build_device.py b/build/android/gyp/util/build_device.py
index 928bd02f8c2f60ff4c716d5248dc4b86f090b898..470d2f3806d5fbc304e89911fe437f51db4c2049 100644
--- a/build/android/gyp/util/build_device.py
+++ b/build/android/gyp/util/build_device.py
@@ -17,6 +17,7 @@ BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
sys.path.append(BUILD_ANDROID_DIR)
from pylib import android_commands
+from pylib.device import device_errors
from pylib.device import device_utils
GetAttachedDevices = android_commands.GetAttachedDevices
@@ -57,16 +58,25 @@ def GetConfigurationForDevice(device_id):
device = device_utils.DeviceUtils(device_id)
configuration = None
has_root = False
- is_online = device.old_interface.IsOnline()
+ is_online = device.IsOnline()
if is_online:
cmd = 'ls -l /data/app; getprop ro.build.description'
cmd_output = device.old_interface.RunShellCommand(cmd)
has_root = not 'Permission denied' in cmd_output[0]
if not has_root:
- # Disable warning log messages from EnableAdbRoot()
- logging.getLogger().disabled = True
- has_root = device.old_interface.EnableAdbRoot()
- logging.getLogger().disabled = False
+ # Disable warning log messages from EnableRoot()
+ class LoggingDisabled(object):
+ def __enter__(self):
+ logging.getLogger().enabled = True
craigdh 2014/05/14 20:33:08 I believe you meant disabled = True here
jbudorick 2014/05/14 21:02:01 Done.
+ def __exit__(self, _a, _b, _c):
+ logging.getLogger().disabled = False
+
+ with LoggingDisabled():
+ try:
+ device.EnableRoot()
+ has_root = True
+ except device_errors.CommandFailedError:
+ has_root = False
cmd_output = device.old_interface.RunShellCommand(cmd)
configuration = {

Powered by Google App Engine
This is Rietveld 408576698