diff --git a/qrenderdoc/Code/Interface/PersistantConfig.cpp b/qrenderdoc/Code/Interface/PersistantConfig.cpp index ccc444e66..a1c956a60 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.cpp +++ b/qrenderdoc/Code/Interface/PersistantConfig.cpp @@ -172,7 +172,7 @@ void PersistantConfig::AddAndroidHosts() { for(int i = RemoteHosts.count() - 1; i >= 0; i--) { - if(RemoteHosts[i]->Hostname.startsWith(lit("adb:"))) + if(RemoteHosts[i]->IsHostADB()) delete RemoteHosts.takeAt(i); } @@ -193,6 +193,8 @@ void PersistantConfig::AddAndroidHosts() { RemoteHost *host = new RemoteHost(); host->Hostname = lit("adb:") + hostName; + // Just a command to display in the GUI and allow Launch() to be called. + host->RunCommand = lit("org.renderdoc.renderdoccmd"); RemoteHosts.push_back(host); } } diff --git a/qrenderdoc/Code/Interface/RemoteHost.cpp b/qrenderdoc/Code/Interface/RemoteHost.cpp index 1e8c153d7..dbd8f7d84 100644 --- a/qrenderdoc/Code/Interface/RemoteHost.cpp +++ b/qrenderdoc/Code/Interface/RemoteHost.cpp @@ -102,8 +102,17 @@ void RemoteHost::CheckStatus() void RemoteHost::Launch() { + int WAIT_TIME = 2000; + + if(IsHostADB()) + { + RENDERDOC_StartAndroidRemoteServer(); + QThread::msleep(WAIT_TIME); + return; + } + RDProcess process; process.start(RunCommand); - process.waitForFinished(2000); + process.waitForFinished(WAIT_TIME); process.detach(); } diff --git a/qrenderdoc/Code/Interface/RemoteHost.h b/qrenderdoc/Code/Interface/RemoteHost.h index 16c9651ea..0b245c61f 100644 --- a/qrenderdoc/Code/Interface/RemoteHost.h +++ b/qrenderdoc/Code/Interface/RemoteHost.h @@ -56,6 +56,8 @@ public: QString Hostname; DOCUMENT("The command to run locally to try to launch the server remotely."); QString RunCommand; + + bool IsHostADB() const { return Hostname.startsWith(lit("adb:")); } }; DECLARE_REFLECTION_STRUCT(RemoteHost); \ No newline at end of file diff --git a/qrenderdoc/Windows/Dialogs/RemoteManager.cpp b/qrenderdoc/Windows/Dialogs/RemoteManager.cpp index 177d77f45..de53c92d0 100644 --- a/qrenderdoc/Windows/Dialogs/RemoteManager.cpp +++ b/qrenderdoc/Windows/Dialogs/RemoteManager.cpp @@ -325,7 +325,11 @@ void RemoteManager::updateConnectButton() if(host) { - if(host->Hostname == lit("localhost")) + bool isLocalhost = host->Hostname == lit("localhost"); + if(isLocalhost || host->IsHostADB()) + ui->runCommand->setEnabled(false); + + if(isLocalhost) { ui->connect->setEnabled(false); } diff --git a/renderdoccmd/renderdoccmd_android.cpp b/renderdoccmd/renderdoccmd_android.cpp index 10f99aa9a..3ec454e1e 100644 --- a/renderdoccmd/renderdoccmd_android.cpp +++ b/renderdoccmd/renderdoccmd_android.cpp @@ -103,6 +103,8 @@ vector getRenderdoccmdArgs() iss >> sub; ret.push_back(sub); } + android_state->activity->vm->DetachCurrentThread(); + return ret; } @@ -116,10 +118,10 @@ void handle_cmd(android_app *app, int32_t cmd) if(!args.size()) break; // Nothing for APK to do. renderdoccmd(GlobalEnvironment(), args); + // activity is done and should be closed + ANativeActivity_finish(android_state->activity); break; } - case APP_CMD_TERM_WINDOW: break; - default: __android_log_print(ANDROID_LOG_INFO, LOGCAT_TAG, "event not handled: %d", cmd); } }