Android: Don't pass error string

Instead, emit remoteProcessFinished() directly from the
startDebuggerServer() function. Make this function void.

Change-Id: Ibeeb2a1e3aabb9b3021203003e31a7b44eef573e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Jarek Kobus
2024-07-23 06:06:32 +02:00
parent 529f8c453c
commit b52bded0a7
2 changed files with 12 additions and 20 deletions

View File

@@ -402,7 +402,7 @@ void AndroidRunnerWorker::setAndroidDeviceInfo(const AndroidDeviceInfo &info)
<< m_deviceSerialNumber << m_apiLevel; << m_deviceSerialNumber << m_apiLevel;
} }
void Android::Internal::AndroidRunnerWorker::asyncStartLogcat() void AndroidRunnerWorker::asyncStartLogcat()
{ {
// Its assumed that the device or avd returned by selector() is online. // Its assumed that the device or avd returned by selector() is online.
// Start the logcat process before app starts. // Start the logcat process before app starts.
@@ -555,16 +555,11 @@ void AndroidRunnerWorker::startNativeDebugging()
} }
} }
} }
QString debuggerServerErr; startDebuggerServer(packageDir, debugServerFile);
if (!startDebuggerServer(packageDir, debugServerFile, &debuggerServerErr)) {
emit remoteProcessFinished(debuggerServerErr);
return;
}
} }
bool AndroidRunnerWorker::startDebuggerServer(const QString &packageDir, void AndroidRunnerWorker::startDebuggerServer(const QString &packageDir,
const QString &debugServerFile, const QString &debugServerFile)
QString *errorStr)
{ {
QStringList adbArgs = {"shell", "run-as", m_packageName}; QStringList adbArgs = {"shell", "run-as", m_packageName};
if (m_processUser > 0) if (m_processUser > 0)
@@ -581,9 +576,8 @@ bool AndroidRunnerWorker::startDebuggerServer(const QString &packageDir,
if (!m_debugServerProcess) { if (!m_debugServerProcess) {
qCDebug(androidRunWorkerLog) << "Debugger process failed to start" << lldbServerErr; qCDebug(androidRunWorkerLog) << "Debugger process failed to start" << lldbServerErr;
if (errorStr) emit remoteProcessFinished(Tr::tr("Failed to start debugger server."));
*errorStr = Tr::tr("Failed to start debugger server."); return;
return false;
} }
qCDebug(androidRunWorkerLog) << "Debugger process started"; qCDebug(androidRunWorkerLog) << "Debugger process started";
m_debugServerProcess->setObjectName("AndroidDebugServerProcess"); m_debugServerProcess->setObjectName("AndroidDebugServerProcess");
@@ -601,25 +595,23 @@ bool AndroidRunnerWorker::startDebuggerServer(const QString &packageDir,
if (!m_debugServerProcess) { if (!m_debugServerProcess) {
qCDebug(androidRunWorkerLog) << "Debugger process failed to start" << gdbServerErr; qCDebug(androidRunWorkerLog) << "Debugger process failed to start" << gdbServerErr;
if (errorStr) emit remoteProcessFinished(Tr::tr("Failed to start debugger server."));
*errorStr = Tr::tr("Failed to start debugger server."); return;
return false;
} }
qCDebug(androidRunWorkerLog) << "Debugger process started"; qCDebug(androidRunWorkerLog) << "Debugger process started";
m_debugServerProcess->setObjectName("AndroidDebugServerProcess"); m_debugServerProcess->setObjectName("AndroidDebugServerProcess");
// TODO: Repeats 3 times, refactor...
const QString port = "tcp:" + m_localDebugServerPort.toString(); const QString port = "tcp:" + m_localDebugServerPort.toString();
const QStringList removeForward{"forward", "--remove", port}; const QStringList removeForward{"forward", "--remove", port};
removeForwardPort(port); removeForwardPort(port);
if (!runAdb({"forward", port, if (!runAdb({"forward", port,
"localfilesystem:" + gdbServerSocket})) { "localfilesystem:" + gdbServerSocket})) {
if (errorStr) emit remoteProcessFinished(Tr::tr("Failed to forward C++ debugging ports."));
*errorStr = Tr::tr("Failed to forward C++ debugging ports."); return;
return false;
} }
m_afterFinishAdbCommands.push_back(removeForward.join(' ')); m_afterFinishAdbCommands.push_back(removeForward.join(' '));
} }
return true;
} }
void AndroidRunnerWorker::asyncStart() void AndroidRunnerWorker::asyncStart()

View File

@@ -62,7 +62,7 @@ private:
void asyncStartHelper(); void asyncStartHelper();
void startNativeDebugging(); void startNativeDebugging();
bool startDebuggerServer(const QString &packageDir, const QString &debugServerFile, QString *errorStr = nullptr); void startDebuggerServer(const QString &packageDir, const QString &debugServerFile);
bool deviceFileExists(const QString &filePath); bool deviceFileExists(const QString &filePath);
bool packageFileExists(const QString& filePath); bool packageFileExists(const QString& filePath);
bool uploadDebugServer(const QString &debugServerFileName); bool uploadDebugServer(const QString &debugServerFileName);