Use android properties to pass capture options to the device

This commit is contained in:
baldurk
2018-02-14 19:22:23 +00:00
parent 468c6c1e80
commit 04fac1d6f8
8 changed files with 44 additions and 14 deletions
+6 -1
View File
@@ -122,7 +122,8 @@ int GetCurrentPID(const std::string &deviceID, const std::string &packageName)
return 0;
}
uint32_t StartAndroidPackageForCapture(const char *host, const char *package)
uint32_t StartAndroidPackageForCapture(const char *host, const char *package,
const CaptureOptions &opts)
{
int index = 0;
std::string deviceID;
@@ -142,6 +143,10 @@ uint32_t StartAndroidPackageForCapture(const char *host, const char *package)
// enable the vulkan layer (will only be used by vulkan programs)
adbExecCommand(deviceID, "shell setprop debug.vulkan.layers " RENDERDOC_VULKAN_LAYER_NAME);
// set our property with the capture options encoded, to be picked up by the library on the device
adbExecCommand(deviceID, StringFormat::Fmt("shell setprop debug.rdoc.RENDERDOC_CAPTUREOPTS %s",
opts.EncodeAsString().c_str()));
std::string installedPath = GetPathForPackage(deviceID, packageName);
std::string RDCLib = trim(
+2 -1
View File
@@ -31,7 +31,8 @@
namespace Android
{
bool IsHostADB(const char *hostname);
uint32_t StartAndroidPackageForCapture(const char *host, const char *package);
uint32_t StartAndroidPackageForCapture(const char *host, const char *package,
const CaptureOptions &opts);
void ResetCaptureSettings(const std::string &deviceID);
void ExtractDeviceIDAndIndex(const std::string &hostname, int &index, std::string &deviceID);
Process::ProcessResult adbExecCommand(const std::string &deviceID, const std::string &args,
+5 -5
View File
@@ -1223,6 +1223,10 @@ public:
uint32_t ExecuteAndInject(const char *a, const char *w, const char *c,
const rdcarray<EnvironmentModification> &env, const CaptureOptions &opts)
{
std::string app = a && a[0] ? a : "";
std::string workingDir = w && w[0] ? w : "";
std::string cmdline = c && c[0] ? c : "";
const char *host = hostname().c_str();
if(Android::IsHostADB(host))
{
@@ -1235,7 +1239,7 @@ public:
ok = Ping();
});
uint32_t ret = Android::StartAndroidPackageForCapture(host, a);
uint32_t ret = Android::StartAndroidPackageForCapture(host, app.c_str(), opts);
Atomic::Inc32(&done);
@@ -1245,10 +1249,6 @@ public:
return ret;
}
std::string app = a && a[0] ? a : "";
std::string workingDir = w && w[0] ? w : "";
std::string cmdline = c && c[0] ? c : "";
{
WRITE_DATA_SCOPE();
SCOPED_SERIALISE_CHUNK(eRemoteServer_ExecuteAndInject);
@@ -24,6 +24,7 @@
#include <unistd.h>
#include "os/os_specific.h"
#include "strings/string_utils.h"
extern char **environ;
@@ -138,3 +139,21 @@ bool OSUtility::DebuggerPresent()
{
return debuggerPresent;
}
const char *Process::GetEnvVariable(const char *name)
{
// we fake environment variables with properties
Process::ProcessResult result;
Process::LaunchProcess("getprop", ".",
StringFormat::Fmt("debug.rdoc.%s variable_is_not_set", name).c_str(), true,
&result);
static std::string settingsOutput;
settingsOutput = trim(result.strStdout);
if(settingsOutput == "variable_is_not_set")
return NULL;
return settingsOutput.c_str();
}
@@ -154,3 +154,8 @@ bool OSUtility::DebuggerPresent()
return info.kp_proc.p_flag & P_TRACED;
#endif
}
const char *Process::GetEnvVariable(const char *name)
{
return getenv(name);
}
@@ -133,3 +133,8 @@ bool OSUtility::DebuggerPresent()
{
return debuggerPresent;
}
const char *Process::GetEnvVariable(const char *name)
{
return getenv(name);
}
+2 -2
View File
@@ -48,8 +48,8 @@ void library_loaded()
{
RenderDoc::Inst().Initialise();
char *logfile = getenv("RENDERDOC_LOGFILE");
char *opts = getenv("RENDERDOC_CAPTUREOPTS");
const char *logfile = Process::GetEnvVariable("RENDERDOC_LOGFILE");
const char *opts = Process::GetEnvVariable("RENDERDOC_CAPTUREOPTS");
if(opts)
{
-5
View File
@@ -214,11 +214,6 @@ void Process::ApplyEnvironmentModification()
modifications.clear();
}
const char *Process::GetEnvVariable(const char *name)
{
return getenv(name);
}
static void CleanupStringArray(char **arr, char **invalid)
{
if(arr != invalid)