Merge "Show a warning if adb is not root before gdbclient.py" am: 84eeb1a8e6 am: 16deba10d9
Original change: https://android-review.googlesource.com/c/platform/development/+/1427154 Change-Id: If4532ec9f615218b5a40307d9a9644b733675cb5
This commit is contained in:
@@ -197,8 +197,20 @@ def start_gdbserver(device, gdbserver_local_path, gdbserver_remote_path,
|
||||
stderr=gdbserver_output)
|
||||
|
||||
|
||||
def get_uid(device):
|
||||
"""Gets the uid adbd runs as."""
|
||||
line, _ = device.shell(["id", "-u"])
|
||||
return int(line.strip())
|
||||
|
||||
|
||||
def forward_gdbserver_port(device, local, remote):
|
||||
"""Forwards local TCP port `port` to `remote` via `adb forward`."""
|
||||
if get_uid(device) != 0:
|
||||
WARNING = '\033[93m'
|
||||
ENDC = '\033[0m'
|
||||
print(WARNING +
|
||||
"Port forwarding may not work because adbd is not running as root. " +
|
||||
" Run `adb root` to fix." + ENDC)
|
||||
device.forward("tcp:{}".format(local), remote)
|
||||
atexit.register(lambda: device.forward_remove("tcp:{}".format(local)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user