forked from qt-creator/qt-creator
Android: Simplify removeForwardPort()
There is no need to split the output into separate lines and search for port number in each line afterwards. Search for port number in the whole output instead. Change-Id: Id020bd5a73080be30b6cef47853e027235105ae3 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -761,22 +761,9 @@ void AndroidRunnerWorker::handleJdbSettled()
|
||||
|
||||
void AndroidRunnerWorker::removeForwardPort(const QString &port)
|
||||
{
|
||||
bool found = false;
|
||||
SdkToolResult result = AndroidManager::runAdbCommand({"forward", "--list"});
|
||||
|
||||
QString string = result.stdOut();
|
||||
const auto lines = string.split('\n');
|
||||
for (const QString &line : lines) {
|
||||
if (line.contains(port)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
QStringList removeForward{"forward", "--remove", port};
|
||||
runAdb(removeForward);
|
||||
}
|
||||
const SdkToolResult result = AndroidManager::runAdbCommand({"forward", "--list"});
|
||||
if (result.stdOut().contains(port))
|
||||
runAdb({"forward", "--remove", port});
|
||||
}
|
||||
|
||||
void AndroidRunnerWorker::onProcessIdChanged(const PidUserPair &pidUser)
|
||||
|
Reference in New Issue
Block a user