forked from qt-creator/qt-creator
iOS: Use stdout of smctl commands
Avoid MessageTracer logs being fed to the device listing json document Change-Id: Ia35b39d787d2df27e6f743e0b6dc401799c383db Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -155,7 +155,7 @@ void IosSettingsWidget::onCreate()
|
||||
.arg(name).arg(response.simUdid), Utils::StdOutFormat);
|
||||
} else {
|
||||
statusDialog->addMessage(tr("Simulator device (%1) creation failed.\nError: %2").
|
||||
arg(name).arg(QString::fromUtf8(response.commandOutput)),
|
||||
arg(name).arg(response.commandOutput),
|
||||
Utils::StdErrFormat);
|
||||
}
|
||||
};
|
||||
|
@@ -926,7 +926,7 @@ void IosSimulatorToolHandlerPrivate::installAppOnSimulator()
|
||||
didTransferApp(m_bundlePath, m_deviceId, IosToolHandler::Success);
|
||||
} else {
|
||||
errorMsg(IosToolHandler::tr("Application install on simulator failed. %1")
|
||||
.arg(QString::fromLocal8Bit(response.commandOutput)));
|
||||
.arg(response.commandOutput));
|
||||
didTransferApp(m_bundlePath, m_deviceId, IosToolHandler::Failure);
|
||||
}
|
||||
emit q->finished(q);
|
||||
@@ -990,7 +990,7 @@ void IosSimulatorToolHandlerPrivate::launchAppOnSimulator(const QStringList &ext
|
||||
} else {
|
||||
m_pid = -1;
|
||||
errorMsg(IosToolHandler::tr("Application launch on simulator failed. %1")
|
||||
.arg(QString::fromLocal8Bit(response.commandOutput)));
|
||||
.arg(response.commandOutput));
|
||||
didStartApp(m_bundlePath, m_deviceId, Ios::IosToolHandler::Failure);
|
||||
stop(-1);
|
||||
q->finished(q);
|
||||
|
@@ -77,17 +77,17 @@ static bool checkForTimeout(const chrono::high_resolution_clock::time_point &sta
|
||||
return timedOut;
|
||||
}
|
||||
|
||||
static bool runCommand(QString command, const QStringList &args, QByteArray *output)
|
||||
static bool runCommand(QString command, const QStringList &args, QString *output)
|
||||
{
|
||||
Utils::SynchronousProcess p;
|
||||
p.setTimeoutS(-1);
|
||||
Utils::SynchronousProcessResponse resp = p.runBlocking(command, args);
|
||||
if (output)
|
||||
*output = resp.allRawOutput();
|
||||
*output = resp.stdOut();
|
||||
return resp.result == Utils::SynchronousProcessResponse::Finished;
|
||||
}
|
||||
|
||||
static bool runSimCtlCommand(QStringList args, QByteArray *output)
|
||||
static bool runSimCtlCommand(QStringList args, QString *output)
|
||||
{
|
||||
args.prepend("simctl");
|
||||
return runCommand("xcrun", args, output);
|
||||
@@ -100,11 +100,10 @@ static bool launchSimulator(const QString &simUdid) {
|
||||
|
||||
if (IosConfigurations::xcodeVersion() >= QVersionNumber(9)) {
|
||||
// For XCode 9 boot the second device instead of launching simulator app twice.
|
||||
QByteArray psOutput;
|
||||
QString psOutput;
|
||||
if (runCommand("ps", {"-A", "-o", "comm"}, &psOutput)) {
|
||||
QByteArray simulatorCommand = simulatorAppPath.toLatin1();
|
||||
for (const QByteArray &comm : psOutput.split('\n')) {
|
||||
if (comm == simulatorCommand)
|
||||
for (const QString &comm : psOutput.split('\n')) {
|
||||
if (comm == simulatorAppPath)
|
||||
return runSimCtlCommand(QStringList({"boot", simUdid}), nullptr);
|
||||
}
|
||||
} else {
|
||||
@@ -120,9 +119,9 @@ static bool launchSimulator(const QString &simUdid) {
|
||||
static QList<DeviceTypeInfo> getAvailableDeviceTypes()
|
||||
{
|
||||
QList<DeviceTypeInfo> deviceTypes;
|
||||
QByteArray output;
|
||||
QString output;
|
||||
runSimCtlCommand({"list", "-j", deviceTypeTag}, &output);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(output);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
||||
if (!doc.isNull()) {
|
||||
const QJsonArray runtimesArray = doc.object().value(deviceTypeTag).toArray();
|
||||
foreach (const QJsonValue deviceTypeValue, runtimesArray) {
|
||||
@@ -144,9 +143,9 @@ static QList<DeviceTypeInfo> getAvailableDeviceTypes()
|
||||
static QList<RuntimeInfo> getAvailableRuntimes()
|
||||
{
|
||||
QList<RuntimeInfo> runtimes;
|
||||
QByteArray output;
|
||||
QString output;
|
||||
runSimCtlCommand({"list", "-j", runtimesTag}, &output);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(output);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
||||
if (!doc.isNull()) {
|
||||
const QJsonArray runtimesArray = doc.object().value(runtimesTag).toArray();
|
||||
foreach (const QJsonValue runtimeValue, runtimesArray) {
|
||||
@@ -220,9 +219,9 @@ QList<SimulatorInfo> SimulatorControl::availableSimulators()
|
||||
static QList<SimulatorInfo> getAllSimulatorDevices()
|
||||
{
|
||||
QList<SimulatorInfo> simulatorDevices;
|
||||
QByteArray output;
|
||||
QString output;
|
||||
runSimCtlCommand({"list", "-j", devicesTag}, &output);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(output);
|
||||
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
||||
if (!doc.isNull()) {
|
||||
const QJsonObject runtimeObject = doc.object().value(devicesTag).toObject();
|
||||
foreach (const QString &runtime, runtimeObject.keys()) {
|
||||
@@ -512,7 +511,7 @@ void SimulatorControlPrivate::launchApp(QFutureInterface<SimulatorControl::Respo
|
||||
}
|
||||
|
||||
if (runSimCtlCommand(args, &response.commandOutput)) {
|
||||
const QByteArray pIdStr = response.commandOutput.trimmed().split(' ').last().trimmed();
|
||||
const QString pIdStr = response.commandOutput.trimmed().split(' ').last().trimmed();
|
||||
bool validPid = false;
|
||||
response.pID = pIdStr.toLongLong(&validPid);
|
||||
response.success = validPid;
|
||||
@@ -566,7 +565,7 @@ void SimulatorControlPrivate::createSimulator(QFutureInterface<SimulatorControl:
|
||||
deviceType.identifier,
|
||||
runtime.identifier},
|
||||
&response.commandOutput);
|
||||
response.simUdid = response.success ? QString::fromLatin1(response.commandOutput.trimmed())
|
||||
response.simUdid = response.success ? response.commandOutput.trimmed()
|
||||
: QString();
|
||||
}
|
||||
|
||||
|
@@ -84,7 +84,7 @@ public:
|
||||
QString simUdid;
|
||||
bool success = false;
|
||||
qint64 pID = -1;
|
||||
QByteArray commandOutput = "";
|
||||
QString commandOutput = "";
|
||||
};
|
||||
|
||||
public:
|
||||
|
@@ -98,10 +98,10 @@ void SimulatorOperationDialog::addMessage(const SimulatorInfo &siminfo,
|
||||
addMessage(tr("%1, %2\nOperation %3 completed successfully.").arg(siminfo.name)
|
||||
.arg(siminfo.runtimeName).arg(context), Utils::StdOutFormat);
|
||||
} else {
|
||||
QByteArray erroMsg = response.commandOutput.trimmed();
|
||||
QString erroMsg = response.commandOutput.trimmed();
|
||||
QString message = tr("%1, %2\nOperation %3 failed.\nUDID: %4\nError: %5").arg(siminfo.name)
|
||||
.arg(siminfo.runtimeName).arg(context).arg(siminfo.identifier)
|
||||
.arg(erroMsg.isEmpty() ? tr("Unknown") : QString::fromUtf8(erroMsg));
|
||||
.arg(erroMsg.isEmpty() ? tr("Unknown") : erroMsg);
|
||||
addMessage(message, Utils::StdErrFormat);
|
||||
qCDebug(iosCommon) << message;
|
||||
}
|
||||
|
Reference in New Issue
Block a user