From 5c99b4fe158b05745d8b1ec3b8b24c16279a4939 Mon Sep 17 00:00:00 2001 From: Cody Northrop Date: Mon, 7 Aug 2017 14:25:25 -0600 Subject: [PATCH] android: Add function to detect root access --- renderdoc/replay/entry_points.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index 0c90fe247..06d89880b 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -1228,6 +1228,30 @@ bool CheckInstalledPermissions(const string &deviceID, const string &packageName return CheckPermissions(dump); } +bool CheckRootAccess(const string &deviceID) +{ + RDCLOG("Checking for root access on %s", deviceID.c_str()); + + Process::ProcessResult result = {}; + + // Try switching adb to root and check a few indicators for success + // Nothing will fall over if we get a false positive here, it just enables + // additional methods of getting things set up. + + result = adbExecCommand(deviceID, "root"); + + string whoami = trim(adbExecCommand(deviceID, "shell whoami").strStdout); + if(whoami == "root") + return true; + + string checksu = + trim(adbExecCommand(deviceID, "shell test -e /system/xbin/su && echo found").strStdout); + if(checksu == "found") + return true; + + return false; +} + extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_CheckAndroidPackage(const char *host, const char *exe, AndroidFlags *flags)