From d19a495ee04e293828f5fc411f767b4f0c8ab63d Mon Sep 17 00:00:00 2001 From: "tabi.katalin" Date: Tue, 27 Nov 2018 10:18:48 +0100 Subject: [PATCH] Handle launching more apps on Android We can check whether an Android app has already been connected to RenderDoc, and warn the user to close the previous app before launching a new one. --- qrenderdoc/Windows/MainWindow.cpp | 20 ++++++++++++++++++++ qrenderdoc/Windows/MainWindow.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index 7dda93953..6fe38e761 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -508,6 +508,16 @@ void MainWindow::OnCaptureTrigger(const QString &exe, const QString &workingDir, return; LambdaThread *th = new LambdaThread([this, exe, workingDir, cmdLine, env, opts, callback]() { + + if(isCapturableAppRunningOnAndroid()) + { + RDDialog::warning(this, tr("RenderDoc is already capturing an app on this device"), + tr("A running app on this device is already being captured with RenderDoc. " + "First please close the app then try to launch again."), + QMessageBox::Ok); + return; + } + QString capturefile = m_Ctx.TempCaptureFilename(QFileInfo(exe).baseName()); ExecuteResult ret = @@ -2848,3 +2858,13 @@ void MainWindow::showLaunchError(ReplayStatus status) } GUIInvoke::call(this, [this, title, message]() { RDDialog::warning(this, title, message); }); } + +bool MainWindow::isCapturableAppRunningOnAndroid() +{ + if(!m_Ctx.Replay().CurrentRemote() || !m_Ctx.Replay().CurrentRemote()->IsADB()) + return false; + + rdcstr host = m_Ctx.Replay().CurrentRemote()->hostname; + uint32_t ident = RENDERDOC_EnumerateRemoteTargets(host.c_str(), 0); + return ident != 0; +} diff --git a/qrenderdoc/Windows/MainWindow.h b/qrenderdoc/Windows/MainWindow.h index adbfeedb5..9315fdc3a 100644 --- a/qrenderdoc/Windows/MainWindow.h +++ b/qrenderdoc/Windows/MainWindow.h @@ -250,4 +250,6 @@ private: void FillRemotesMenu(QMenu *menu, bool includeLocalhost); void showLaunchError(ReplayStatus status); + + bool isCapturableAppRunningOnAndroid(); };