Move away from device.get_props.

Properties can include \n so get_props isn't sound, and it's not obvious how
to fix it (without adding something like cat's -v to getprop, which wouldn't
help the intended use case of working with arbitrary old devices).

Bug: https://issuetracker.google.com/37093233
Test: gdbclient -r /system/bin/date
Change-Id: I96042fd44f1de17974968954fab6c916a9d13b61
This commit is contained in:
Elliott Hughes
2017-06-02 13:15:59 -07:00
parent ddd86bd217
commit 1a2f12d23e

View File

@@ -74,8 +74,8 @@ def dump_var(root, variable):
return make_output.splitlines()[0]
def verify_device(root, props):
names = set([props["ro.build.product"], props["ro.product.device"]])
def verify_device(root, device):
names = set([device.get_prop("ro.build.product"), device.get_prop("ro.product.device")])
target_device = dump_var(root, "TARGET_DEVICE")
if target_device not in names:
msg = "TARGET_DEVICE ({}) does not match attached device ({})"
@@ -216,13 +216,11 @@ def main():
if device is None:
sys.exit("ERROR: Failed to find device.")
props = device.get_props()
root = os.environ["ANDROID_BUILD_TOP"]
sysroot = dump_var(root, "abs-TARGET_OUT_UNSTRIPPED")
# Make sure the environment matches the attached device.
verify_device(root, props)
verify_device(root, device)
debug_socket = "/data/local/tmp/debug_socket"
pid = None