android: Add function to detect root access

This commit is contained in:
Cody Northrop
2017-08-15 09:36:20 -07:00
committed by Baldur Karlsson
parent 58b0d29bf4
commit 5c99b4fe15
+24
View File
@@ -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)