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..a7bafe3f263df1c5111aaa41f2ded003f721c41e 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): |
Primiano Tucci (use gerrit)
2014/05/15 12:39:09
Is there a specific reason for having all this boi
jbudorick
2014/05/15 14:10:20
No, not really. The context manager would make mor
Primiano Tucci (use gerrit)
2014/05/15 15:21:34
I don't want to interfere with anybody's work (als
|
+ def __enter__(self): |
+ logging.getLogger().disabled = True |
+ 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 = { |