mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-25 16:06:31 +00:00
Switch string_utils to use rdc types
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "android.h"
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include "api/replay/version.h"
|
||||
#include "core/core.h"
|
||||
#include "core/remote_server.h"
|
||||
@@ -78,14 +77,14 @@ std::string GetDefaultActivityForPackage(const std::string &deviceID, const std:
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> lines;
|
||||
rdcarray<rdcstr> lines;
|
||||
split(activity.strStdout, lines, '\n');
|
||||
|
||||
for(std::string &line : lines)
|
||||
for(rdcstr &line : lines)
|
||||
{
|
||||
line = trim(line);
|
||||
line.trim();
|
||||
|
||||
if(!strncmp(line.c_str(), "name=", 5))
|
||||
if(line.beginsWith("name="))
|
||||
{
|
||||
return line.substr(5);
|
||||
}
|
||||
@@ -108,25 +107,23 @@ std::string GetDefaultActivityForPackage(const std::string &deviceID, const std:
|
||||
|
||||
size_t numOfLines = lines.size();
|
||||
const char *intentFilter = "android.intent.action.MAIN:";
|
||||
size_t intentFilterSize = strlen(intentFilter);
|
||||
|
||||
for(size_t idx = 0; idx < numOfLines; idx++)
|
||||
{
|
||||
std::string line = trim(lines[idx]);
|
||||
if(!strncmp(line.c_str(), intentFilter, intentFilterSize) && idx + 1 < numOfLines)
|
||||
lines[idx].trim();
|
||||
|
||||
if(lines[idx].beginsWith(intentFilter) && idx + 1 < numOfLines)
|
||||
{
|
||||
std::string activityName = trim(lines[idx + 1]);
|
||||
size_t startPos = activityName.find("/");
|
||||
if(startPos == std::string::npos)
|
||||
rdcstr activityName = lines[idx + 1].trimmed();
|
||||
int startPos = activityName.find('/');
|
||||
if(startPos < 0)
|
||||
{
|
||||
RDCWARN("Failed to find default activity");
|
||||
return "";
|
||||
}
|
||||
size_t endPos = activityName.find(" ", startPos + 1);
|
||||
if(endPos == std::string::npos)
|
||||
{
|
||||
endPos = activityName.length();
|
||||
}
|
||||
int endPos = activityName.find(' ', startPos + 1);
|
||||
if(endPos < 0)
|
||||
endPos = activityName.count();
|
||||
return activityName.substr(startPos + 1, endPos - startPos - 1);
|
||||
}
|
||||
}
|
||||
@@ -143,22 +140,24 @@ int GetCurrentPID(const std::string &deviceID, const std::string &packageName)
|
||||
Process::ProcessResult pidOutput =
|
||||
adbExecCommand(deviceID, StringFormat::Fmt("shell ps -A | grep %s", packageName.c_str()));
|
||||
|
||||
std::string output = trim(pidOutput.strStdout);
|
||||
size_t space = output.find_first_of("\t ");
|
||||
rdcstr &output = pidOutput.strStdout;
|
||||
|
||||
output.trim();
|
||||
int space = output.find_first_of("\t ");
|
||||
|
||||
// if we didn't get a response, try without the -A as some android devices don't support that
|
||||
// parameter
|
||||
if(output.empty() || output.find(packageName) == std::string::npos || space == std::string::npos)
|
||||
if(output.empty() || output.find(packageName) == -1 || space == -1)
|
||||
{
|
||||
pidOutput =
|
||||
adbExecCommand(deviceID, StringFormat::Fmt("shell ps | grep %s", packageName.c_str()));
|
||||
|
||||
output = trim(pidOutput.strStdout);
|
||||
output.trim();
|
||||
space = output.find_first_of("\t ");
|
||||
}
|
||||
|
||||
// if we still didn't get a response, sleep and try again next time
|
||||
if(output.empty() || output.find(packageName) == std::string::npos || space == std::string::npos)
|
||||
if(output.empty() || output.find(packageName) == -1 || space == -1)
|
||||
{
|
||||
Threading::Sleep(200);
|
||||
continue;
|
||||
@@ -190,14 +189,15 @@ bool CheckAndroidServerVersion(const std::string &deviceID, ABI abi)
|
||||
if(dump.empty())
|
||||
RDCERR("Unable to pm dump %s", packageName.c_str());
|
||||
|
||||
std::string versionCode = trim(GetFirstMatchingLine(dump, "versionCode="));
|
||||
std::string versionName = trim(GetFirstMatchingLine(dump, "versionName="));
|
||||
rdcstr versionCode = GetFirstMatchingLine(dump, "versionCode=").trimmed();
|
||||
rdcstr versionName = GetFirstMatchingLine(dump, "versionName=").trimmed();
|
||||
|
||||
// versionCode is not alone in this line, isolate it
|
||||
if(versionCode != "")
|
||||
{
|
||||
size_t spaceOffset = versionCode.find(' ');
|
||||
versionCode.erase(spaceOffset);
|
||||
int32_t spaceOffset = versionCode.find(' ');
|
||||
if(spaceOffset >= 0)
|
||||
versionCode.erase(spaceOffset, ~0U);
|
||||
|
||||
versionCode.erase(0, strlen("versionCode="));
|
||||
}
|
||||
@@ -260,8 +260,8 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID)
|
||||
if(FileIO::IsRelativePath(customPath))
|
||||
customPath = libDir + "/" + customPath;
|
||||
|
||||
if(!endswith(customPath, "/"))
|
||||
customPath += "/";
|
||||
if(customPath.back() != '/'))
|
||||
customPath += '/';
|
||||
|
||||
paths.push_back(customPath);
|
||||
#endif
|
||||
@@ -331,8 +331,8 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID)
|
||||
|
||||
if(!success)
|
||||
{
|
||||
RDCLOG("Failed to install APK. stdout: %s, stderr: %s", trim(adbInstall.strStdout).c_str(),
|
||||
trim(adbInstall.strStderror).c_str());
|
||||
RDCLOG("Failed to install APK. stdout: %s, stderr: %s",
|
||||
adbInstall.strStdout.trimmed().c_str(), adbInstall.strStderror.trimmed().c_str());
|
||||
RDCLOG("Retrying...");
|
||||
adbExecCommand(deviceID, "install -r \"" + apk + "\"");
|
||||
|
||||
@@ -363,7 +363,7 @@ ReplayStatus InstallRenderDocServer(const std::string &deviceID)
|
||||
return ReplayStatus::AndroidAPKInstallFailed;
|
||||
}
|
||||
|
||||
size_t lines = adbCheck.strStdout.find('\n') == std::string::npos ? 1 : 2;
|
||||
size_t lines = adbCheck.strStdout.find('\n') == -1 ? 1 : 2;
|
||||
|
||||
if(lines != abis.size())
|
||||
RDCWARN("Installation of some apks failed!");
|
||||
@@ -416,15 +416,15 @@ rdcarray<rdcstr> EnumerateDevices()
|
||||
{
|
||||
rdcarray<rdcstr> ret;
|
||||
|
||||
std::string adbStdout = Android::adbExecCommand("", "devices", ".", true).strStdout;
|
||||
rdcstr adbStdout = Android::adbExecCommand("", "devices", ".", true).strStdout;
|
||||
|
||||
std::vector<std::string> lines;
|
||||
rdcarray<rdcstr> lines;
|
||||
split(adbStdout, lines, '\n');
|
||||
for(const std::string &line : lines)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
rdcarray<rdcstr> tokens;
|
||||
split(line, tokens, '\t');
|
||||
if(tokens.size() == 2 && trim(tokens[1]) == "device")
|
||||
if(tokens.size() == 2 && tokens[1].trimmed() == "device")
|
||||
ret.push_back(tokens[0]);
|
||||
}
|
||||
|
||||
@@ -485,14 +485,13 @@ struct AndroidRemoteServer : public RemoteServer
|
||||
{
|
||||
SCOPED_TIMER("Fetching android packages and activities");
|
||||
|
||||
std::string adbStdout =
|
||||
Android::adbExecCommand(m_deviceID, "shell pm list packages -3").strStdout;
|
||||
rdcstr adbStdout = Android::adbExecCommand(m_deviceID, "shell pm list packages -3").strStdout;
|
||||
|
||||
std::vector<std::string> lines;
|
||||
rdcarray<rdcstr> lines;
|
||||
split(adbStdout, lines, '\n');
|
||||
|
||||
std::vector<PathEntry> packages;
|
||||
for(const std::string &line : lines)
|
||||
for(const rdcstr &line : lines)
|
||||
{
|
||||
// hide our own internal packages
|
||||
if(strstr(line.c_str(), "package:org.renderdoc."))
|
||||
@@ -501,7 +500,7 @@ struct AndroidRemoteServer : public RemoteServer
|
||||
if(!strncmp(line.c_str(), "package:", 8))
|
||||
{
|
||||
PathEntry pkg;
|
||||
pkg.filename = trim(line.substr(8));
|
||||
pkg.filename = line.substr(8).trimmed();
|
||||
pkg.size = 0;
|
||||
pkg.lastmod = 0;
|
||||
pkg.flags = PathProperty::Directory;
|
||||
@@ -826,12 +825,12 @@ struct AndroidController : public IDeviceProtocolHandler
|
||||
return;
|
||||
}
|
||||
|
||||
std::string packagesOutput =
|
||||
trim(Android::adbExecCommand(deviceID,
|
||||
"shell pm list packages " RENDERDOC_ANDROID_PACKAGE_BASE)
|
||||
.strStdout);
|
||||
rdcstr packagesOutput =
|
||||
Android::adbExecCommand(deviceID,
|
||||
"shell pm list packages " RENDERDOC_ANDROID_PACKAGE_BASE)
|
||||
.strStdout.trimmed();
|
||||
|
||||
std::vector<std::string> packages;
|
||||
rdcarray<rdcstr> packages;
|
||||
split(packagesOutput, packages, '\n');
|
||||
|
||||
std::vector<Android::ABI> abis = Android::GetSupportedABIs(deviceID);
|
||||
@@ -1034,10 +1033,9 @@ ExecuteResult AndroidRemoteServer::ExecuteAndInject(const char *a, const char *w
|
||||
|
||||
std::string installedPath = Android::GetPathForPackage(m_deviceID, packageName);
|
||||
|
||||
std::string RDCLib =
|
||||
trim(Android::adbExecCommand(
|
||||
m_deviceID, "shell ls " + installedPath + "/lib/*/" RENDERDOC_ANDROID_LIBRARY)
|
||||
.strStdout);
|
||||
rdcstr RDCLib = Android::adbExecCommand(m_deviceID, "shell ls " + installedPath +
|
||||
"/lib/*/" RENDERDOC_ANDROID_LIBRARY)
|
||||
.strStdout.trimmed();
|
||||
|
||||
// some versions of adb/android return the error message on stdout, so try to detect those and
|
||||
// clear the output.
|
||||
@@ -1046,7 +1044,7 @@ ExecuteResult AndroidRemoteServer::ExecuteAndInject(const char *a, const char *w
|
||||
|
||||
// some versions of adb/android also don't print any error message at all! Look to see if the
|
||||
// wildcard glob is still present.
|
||||
if(RDCLib.find("/lib/*/" RENDERDOC_ANDROID_LIBRARY) != std::string::npos)
|
||||
if(RDCLib.find("/lib/*/" RENDERDOC_ANDROID_LIBRARY) >= 0)
|
||||
RDCLib.clear();
|
||||
|
||||
if(RDCLib.empty())
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include <sstream>
|
||||
#include "3rdparty/miniz/miniz.h"
|
||||
#include "api/replay/version.h"
|
||||
#include "core/core.h"
|
||||
@@ -40,21 +39,22 @@ bool RemoveAPKSignature(const std::string &apk)
|
||||
std::string aapt = getToolPath(ToolDir::BuildTools, "aapt", false);
|
||||
|
||||
// Get the list of files in META-INF
|
||||
std::string fileList = execCommand(aapt, "list \"" + apk + "\"").strStdout;
|
||||
rdcstr fileList = execCommand(aapt, "list \"" + apk + "\"").strStdout;
|
||||
if(fileList.empty())
|
||||
return false;
|
||||
|
||||
// Walk through the output. If it starts with META-INF, remove it.
|
||||
uint32_t fileCount = 0;
|
||||
uint32_t matchCount = 0;
|
||||
std::istringstream contents(fileList);
|
||||
std::string line;
|
||||
std::string prefix("META-INF");
|
||||
while(std::getline(contents, line))
|
||||
|
||||
rdcarray<rdcstr> lines;
|
||||
split(fileList, lines, '\n');
|
||||
|
||||
for(rdcstr &line : lines)
|
||||
{
|
||||
line = trim(line);
|
||||
line.trim();
|
||||
fileCount++;
|
||||
if(line.compare(0, prefix.size(), prefix) == 0)
|
||||
if(line.beginsWith("META-INF"))
|
||||
{
|
||||
RDCDEBUG("Match found, removing %s", line.c_str());
|
||||
execCommand(aapt, "remove \"" + apk + "\" " + line);
|
||||
@@ -66,10 +66,11 @@ bool RemoveAPKSignature(const std::string &apk)
|
||||
// Ensure no hits on second pass through
|
||||
RDCDEBUG("Walk through file list again, ensure signature removed");
|
||||
fileList = execCommand(aapt, "list \"" + apk + "\"").strStdout;
|
||||
std::istringstream recheck(fileList);
|
||||
while(std::getline(recheck, line))
|
||||
split(fileList, lines, '\n');
|
||||
for(rdcstr &line : lines)
|
||||
{
|
||||
if(line.compare(0, prefix.size(), prefix) == 0)
|
||||
line.trim();
|
||||
if(line.beginsWith("META-INF"))
|
||||
{
|
||||
RDCERR("Match found, that means removal failed! %s", line.c_str());
|
||||
return false;
|
||||
@@ -103,6 +104,7 @@ bool ExtractAndRemoveManifest(const std::string &apk, std::vector<byte> &manifes
|
||||
RDCLOG("Got manifest of %zu bytes", sz);
|
||||
|
||||
manifest.insert(manifest.begin(), buf, buf + sz);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,13 +123,14 @@ bool ExtractAndRemoveManifest(const std::string &apk, std::vector<byte> &manifes
|
||||
RDCDEBUG("Removing AndroidManifest.xml");
|
||||
execCommand(aapt, "remove \"" + apk + "\" AndroidManifest.xml");
|
||||
|
||||
std::string fileList = execCommand(aapt, "list \"" + apk + "\"").strStdout;
|
||||
std::vector<std::string> files;
|
||||
rdcstr fileList = execCommand(aapt, "list \"" + apk + "\"").strStdout;
|
||||
rdcarray<rdcstr> files;
|
||||
split(fileList, files, ' ');
|
||||
|
||||
for(const std::string &f : files)
|
||||
for(rdcstr &f : files)
|
||||
{
|
||||
if(trim(f) == "AndroidManifest.xml")
|
||||
f.trim();
|
||||
if(f == "AndroidManifest.xml")
|
||||
{
|
||||
RDCERR("AndroidManifest.xml found, that means removal failed!");
|
||||
return false;
|
||||
@@ -224,6 +227,7 @@ std::string GetAndroidDebugKey()
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
bool DebugSignAPK(const std::string &apk, const std::string &workDir)
|
||||
{
|
||||
RDCLOG("Signing with debug key");
|
||||
@@ -263,19 +267,14 @@ bool DebugSignAPK(const std::string &apk, const std::string &workDir)
|
||||
}
|
||||
|
||||
// Check for signature
|
||||
std::string list = execCommand(aapt, "list \"" + apk + "\"").strStdout;
|
||||
rdcstr list = execCommand(aapt, "list \"" + apk + "\"").strStdout;
|
||||
|
||||
// Walk through the output. If it starts with META-INF, we're good
|
||||
std::istringstream contents(list);
|
||||
std::string line;
|
||||
std::string prefix("META-INF");
|
||||
while(std::getline(contents, line))
|
||||
list.insert(0, '\n');
|
||||
|
||||
if(list.find("\nMETA-INF") >= 0)
|
||||
{
|
||||
if(line.compare(0, prefix.size(), prefix) == 0)
|
||||
{
|
||||
RDCLOG("Signature found, continuing...");
|
||||
return true;
|
||||
}
|
||||
RDCLOG("Signature found, continuing...");
|
||||
return true;
|
||||
}
|
||||
|
||||
RDCERR("re-sign of APK failed!");
|
||||
@@ -439,29 +438,28 @@ bool HasRootAccess(const std::string &deviceID)
|
||||
|
||||
result = adbExecCommand(deviceID, "root");
|
||||
|
||||
std::string whoami = trim(adbExecCommand(deviceID, "shell whoami").strStdout);
|
||||
rdcstr whoami = adbExecCommand(deviceID, "shell whoami").strStdout.trimmed();
|
||||
if(whoami == "root")
|
||||
return true;
|
||||
|
||||
std::string checksu =
|
||||
trim(adbExecCommand(deviceID, "shell test -e /system/xbin/su && echo found").strStdout);
|
||||
rdcstr checksu =
|
||||
adbExecCommand(deviceID, "shell test -e /system/xbin/su && echo found").strStdout.trimmed();
|
||||
if(checksu == "found")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string GetFirstMatchingLine(const std::string &haystack, const std::string &needle)
|
||||
rdcstr GetFirstMatchingLine(const rdcstr &haystack, const rdcstr &needle)
|
||||
{
|
||||
size_t needleOffset = haystack.find(needle);
|
||||
int needleOffset = haystack.find(needle);
|
||||
|
||||
if(needleOffset == std::string::npos)
|
||||
return "";
|
||||
if(needleOffset == -1)
|
||||
return rdcstr();
|
||||
|
||||
size_t nextLine = haystack.find('\n', needleOffset + 1);
|
||||
int nextLine = haystack.find('\n', needleOffset + 1);
|
||||
|
||||
return haystack.substr(needleOffset,
|
||||
nextLine == std::string::npos ? nextLine : nextLine - needleOffset);
|
||||
return haystack.substr(needleOffset, nextLine == -1 ? ~0U : size_t(nextLine - needleOffset));
|
||||
}
|
||||
|
||||
bool IsDebuggable(const std::string &deviceID, const std::string &packageName)
|
||||
|
||||
@@ -354,8 +354,7 @@ void initAdb()
|
||||
Process::ProcessResult res = {};
|
||||
Process::LaunchProcess(adb.c_str(), workdir.c_str(), "start-server", true, &res);
|
||||
|
||||
if(res.strStdout.find("daemon") != std::string::npos ||
|
||||
res.strStderror.find("daemon") != std::string::npos)
|
||||
if(res.strStdout.find("daemon") >= 0 || res.strStderror.find("daemon") >= 0)
|
||||
{
|
||||
RDCLOG("Started adb server");
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "android_utils.h"
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include "core/core.h"
|
||||
#include "strings/string_utils.h"
|
||||
|
||||
@@ -110,7 +109,7 @@ ABI GetABI(const std::string &abiName)
|
||||
|
||||
std::vector<ABI> GetSupportedABIs(const std::string &deviceID)
|
||||
{
|
||||
std::string adbAbi = trim(adbExecCommand(deviceID, "shell getprop ro.product.cpu.abi").strStdout);
|
||||
rdcstr adbAbi = adbExecCommand(deviceID, "shell getprop ro.product.cpu.abi").strStdout.trimmed();
|
||||
|
||||
// these returned lists should be such that the first entry is the 'lowest command denominator' -
|
||||
// typically 32-bit.
|
||||
@@ -145,30 +144,30 @@ std::string GetRenderDocPackageForABI(ABI abi, char sep)
|
||||
|
||||
std::string GetPathForPackage(const std::string &deviceID, const std::string &packageName)
|
||||
{
|
||||
std::string pkgPath = trim(adbExecCommand(deviceID, "shell pm path " + packageName).strStdout);
|
||||
rdcstr pkgPath = adbExecCommand(deviceID, "shell pm path " + packageName).strStdout.trimmed();
|
||||
|
||||
// if there are multiple slices, the path will be returned on many lines. Take only the first
|
||||
// line, assuming all of the apks are in the same directory
|
||||
if(pkgPath.find("\n") != std::string::npos)
|
||||
if(pkgPath.find("\n") >= 0)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
rdcarray<rdcstr> lines;
|
||||
split(pkgPath, lines, '\n');
|
||||
pkgPath = trim(lines[0]);
|
||||
pkgPath = lines[0].trimmed();
|
||||
}
|
||||
|
||||
if(pkgPath.empty() || pkgPath.find("package:") != 0 || pkgPath.find("base.apk") == std::string::npos)
|
||||
if(pkgPath.empty() || pkgPath.find("package:") != 0 || pkgPath.find("base.apk") == -1)
|
||||
return pkgPath;
|
||||
|
||||
pkgPath.erase(pkgPath.begin(), pkgPath.begin() + strlen("package:"));
|
||||
pkgPath.erase(pkgPath.end() - strlen("base.apk"), pkgPath.end());
|
||||
pkgPath.erase(0, strlen("package:"));
|
||||
pkgPath.erase(pkgPath.size() - strlen("base.apk"), ~0U);
|
||||
|
||||
return pkgPath;
|
||||
}
|
||||
|
||||
bool IsSupported(std::string deviceID)
|
||||
{
|
||||
std::string api =
|
||||
trim(Android::adbExecCommand(deviceID, "shell getprop ro.build.version.sdk").strStdout);
|
||||
rdcstr api =
|
||||
Android::adbExecCommand(deviceID, "shell getprop ro.build.version.sdk").strStdout.trimmed();
|
||||
|
||||
int apiVersion = atoi(api.c_str());
|
||||
|
||||
@@ -186,8 +185,8 @@ bool IsSupported(std::string deviceID)
|
||||
|
||||
bool SupportsNativeLayers(const rdcstr &deviceID)
|
||||
{
|
||||
std::string api =
|
||||
trim(Android::adbExecCommand(deviceID, "shell getprop ro.build.version.sdk").strStdout);
|
||||
rdcstr api =
|
||||
Android::adbExecCommand(deviceID, "shell getprop ro.build.version.sdk").strStdout.trimmed();
|
||||
|
||||
int apiVersion = atoi(api.c_str());
|
||||
|
||||
@@ -203,24 +202,22 @@ std::string DetermineInstalledABI(const std::string &deviceID, const std::string
|
||||
RDCLOG("Checking installed ABI for %s", packageName.c_str());
|
||||
std::string abi;
|
||||
|
||||
std::string dump = adbExecCommand(deviceID, "shell pm dump " + packageName).strStdout;
|
||||
rdcstr dump = adbExecCommand(deviceID, "shell pm dump " + packageName).strStdout;
|
||||
if(dump.empty())
|
||||
RDCERR("Unable to pm dump %s", packageName.c_str());
|
||||
|
||||
// Walk through the output and look for primaryCpuAbi
|
||||
std::istringstream contents(dump);
|
||||
std::string line;
|
||||
std::string prefix("primaryCpuAbi=");
|
||||
while(std::getline(contents, line))
|
||||
rdcstr prefix = "primaryCpuAbi=";
|
||||
int offset = dump.find("primaryCpuAbi=");
|
||||
|
||||
if(offset >= 0)
|
||||
{
|
||||
line = trim(line);
|
||||
if(line.compare(0, prefix.size(), prefix) == 0)
|
||||
{
|
||||
// Extract the abi
|
||||
abi = line.substr(line.find_last_of("=") + 1);
|
||||
RDCLOG("primaryCpuAbi found: %s", abi.c_str());
|
||||
break;
|
||||
}
|
||||
offset = dump.find('=', offset) + 1;
|
||||
|
||||
int newline = dump.find('\n', offset);
|
||||
|
||||
if(newline >= 0)
|
||||
abi = dump.substr(offset, newline - offset).trimmed();
|
||||
}
|
||||
|
||||
if(abi.empty())
|
||||
@@ -240,10 +237,10 @@ rdcstr GetFriendlyName(const rdcstr &deviceID)
|
||||
// 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 =
|
||||
trim(Android::adbExecCommand(deviceID, "shell getprop ro.product.model").strStdout);
|
||||
rdcstr manuf =
|
||||
Android::adbExecCommand(deviceID, "shell getprop ro.product.manufacturer").strStdout.trimmed();
|
||||
rdcstr model =
|
||||
Android::adbExecCommand(deviceID, "shell getprop ro.product.model").strStdout.trimmed();
|
||||
|
||||
std::string combined;
|
||||
|
||||
@@ -660,25 +657,25 @@ void LogcatThread::Tick()
|
||||
std::string command =
|
||||
StringFormat::Fmt("logcat -t %u -v brief -s renderdoc:* libc:* DEBUG:*", lineBacklog);
|
||||
|
||||
std::string logcat = trim(Android::adbExecCommand(deviceID, command, ".", true).strStdout);
|
||||
rdcstr logcat = Android::adbExecCommand(deviceID, command, ".", true).strStdout.trimmed();
|
||||
|
||||
std::vector<std::string> lines;
|
||||
rdcarray<rdcstr> lines;
|
||||
split(logcat, lines, '\n');
|
||||
|
||||
// remove \n from any lines right now to prevent it breaking further processing
|
||||
for(std::string &line : lines)
|
||||
for(rdcstr &line : lines)
|
||||
if(!line.empty() && line.back() == '\r')
|
||||
line.pop_back();
|
||||
|
||||
// only do any processing if we had a line last time that we know to start from.
|
||||
if(!lastLogcatLine.empty())
|
||||
{
|
||||
auto it = std::find(lines.begin(), lines.end(), lastLogcatLine);
|
||||
int idx = lines.indexOf(lastLogcatLine);
|
||||
|
||||
if(it != lines.end())
|
||||
if(idx >= 0)
|
||||
{
|
||||
// remove everything up to and including that line
|
||||
lines.erase(lines.begin(), it + 1);
|
||||
lines.erase(0, idx + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ enum class ToolDir
|
||||
std::string getToolPath(ToolDir subdir, const std::string &toolname, bool checkExist);
|
||||
bool toolExists(const std::string &path);
|
||||
|
||||
std::string GetFirstMatchingLine(const std::string &haystack, const std::string &needle);
|
||||
rdcstr GetFirstMatchingLine(const rdcstr &haystack, const rdcstr &needle);
|
||||
|
||||
bool IsSupported(std::string deviceID);
|
||||
bool SupportsNativeLayers(const rdcstr &deviceID);
|
||||
|
||||
Reference in New Issue
Block a user