From 82a35343e69b791831a92a8b8ffa95c5ba30a310 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 25 Apr 2019 12:36:01 +0100 Subject: [PATCH] Only run 'adb root' when getting friendly name * This avoid spamming adb root into the log often when we only need to run it once when a device is first seen. --- renderdoc/android/android.cpp | 6 ------ renderdoc/android/android_utils.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/renderdoc/android/android.cpp b/renderdoc/android/android.cpp index 71de1091e..1cf943a90 100644 --- a/renderdoc/android/android.cpp +++ b/renderdoc/android/android.cpp @@ -584,12 +584,6 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_EnumerateAndroidDevices(rdc // Forward the ports so we can see if a remoteserver/captured app is already running. Android::adbForwardPorts(idx, tokens[0], 0, 0, true); - // run adb root now, so we hit any disconnection that we're going to before trying to connect. - // If we can't be root, this is cheap, if we're already root, this is cheap, if we can be root - // and this changes us it will block only the first time - and we expect this function to be - // slow-ish. - Android::adbExecCommand(tokens[0], "root"); - idx++; } } diff --git a/renderdoc/android/android_utils.cpp b/renderdoc/android/android_utils.cpp index 852ca23db..77bb5ba6d 100644 --- a/renderdoc/android/android_utils.cpp +++ b/renderdoc/android/android_utils.cpp @@ -157,6 +157,15 @@ std::string GetFriendlyName(std::string deviceID) if(it != friendlyNameCache.end()) return it->second; + // run adb root now, so we hit any disconnection that we're going to before trying to connect. + // If we can't be root, this is cheap, if we're already root, this is cheap, if we can be root + // and this changes us it will block only the first time - and we expect this function to be + // slow-ish. + // + // We do this here so that we sneakily take advantage of the above caching - otherwise we spam adb + // root commands into the log + Android::adbExecCommand(deviceID, "root"); + std::string manuf = trim(Android::adbExecCommand(deviceID, "shell getprop ro.product.manufacturer").strStdout); std::string model =