diff --git a/renderdoc/android/android.cpp b/renderdoc/android/android.cpp index 2d9483500..344ae28a4 100644 --- a/renderdoc/android/android.cpp +++ b/renderdoc/android/android.cpp @@ -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( diff --git a/renderdoc/android/android.h b/renderdoc/android/android.h index fb534ea98..46909afd9 100644 --- a/renderdoc/android/android.h +++ b/renderdoc/android/android.h @@ -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, diff --git a/renderdoc/core/remote_server.cpp b/renderdoc/core/remote_server.cpp index 71cd2f39f..d8f2efc20 100644 --- a/renderdoc/core/remote_server.cpp +++ b/renderdoc/core/remote_server.cpp @@ -1223,6 +1223,10 @@ public: uint32_t ExecuteAndInject(const char *a, const char *w, const char *c, const rdcarray &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); diff --git a/renderdoc/os/posix/android/android_process.cpp b/renderdoc/os/posix/android/android_process.cpp index 38119f230..336798e05 100644 --- a/renderdoc/os/posix/android/android_process.cpp +++ b/renderdoc/os/posix/android/android_process.cpp @@ -24,6 +24,7 @@ #include #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(); +} diff --git a/renderdoc/os/posix/apple/apple_process.cpp b/renderdoc/os/posix/apple/apple_process.cpp index aebcfa179..c427102d2 100644 --- a/renderdoc/os/posix/apple/apple_process.cpp +++ b/renderdoc/os/posix/apple/apple_process.cpp @@ -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); +} \ No newline at end of file diff --git a/renderdoc/os/posix/linux/linux_process.cpp b/renderdoc/os/posix/linux/linux_process.cpp index 127452c4a..d4f0d6ad4 100644 --- a/renderdoc/os/posix/linux/linux_process.cpp +++ b/renderdoc/os/posix/linux/linux_process.cpp @@ -133,3 +133,8 @@ bool OSUtility::DebuggerPresent() { return debuggerPresent; } + +const char *Process::GetEnvVariable(const char *name) +{ + return getenv(name); +} \ No newline at end of file diff --git a/renderdoc/os/posix/posix_libentry.cpp b/renderdoc/os/posix/posix_libentry.cpp index ff0436ee9..fc533c521 100644 --- a/renderdoc/os/posix/posix_libentry.cpp +++ b/renderdoc/os/posix/posix_libentry.cpp @@ -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) { diff --git a/renderdoc/os/posix/posix_process.cpp b/renderdoc/os/posix/posix_process.cpp index c7638514a..4fffe0676 100644 --- a/renderdoc/os/posix/posix_process.cpp +++ b/renderdoc/os/posix/posix_process.cpp @@ -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)