bool AndroidRunnerWorkerBase::adbShellAmNeedsQuotes() { // Between Android SDK Tools version 24.3.1 and 24.3.4 the quoting // needs for the 'adb shell am start ...' parameters changed. // Run a test to find out on what side of the fence we live. // The command will fail with a complaint about the "--dummy" // option on newer SDKs, and with "No intent supplied" on older ones. // In case the test itself fails assume a new SDK. Utils::SynchronousProcess adb; adb.setTimeoutS(10); Utils::SynchronousProcessResponse response = adb.run(m_adb, selector() << "shell" << "am" << "start" << "-e" << "dummy" << "dummy --dummy"); if (response.result == Utils::SynchronousProcessResponse::StartFailed || response.result != Utils::SynchronousProcessResponse::Finished) return true; const QString output = response.allOutput(); const bool oldSdk = output.contains("Error: No intent supplied"); return !oldSdk; }
void UncrustifySettings::createDocumentationFile() const { Utils::SynchronousProcess process; process.setTimeoutS(2); Utils::SynchronousProcessResponse response = process.run(command(), QStringList() << QLatin1String("--show-config")); if (response.result != Utils::SynchronousProcessResponse::Finished) return; QFile file(documentationFilePath()); const QFileInfo fi(file); if (!fi.exists()) fi.dir().mkpath(fi.absolutePath()); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) return; bool contextWritten = false; QXmlStreamWriter stream(&file); stream.setAutoFormatting(true); stream.writeStartDocument("1.0", true); stream.writeComment("Created " + QDateTime::currentDateTime().toString(Qt::ISODate)); stream.writeStartElement(Constants::DOCUMENTATION_XMLROOT); const QStringList lines = response.allOutput().split(QLatin1Char('\n')); const int totalLines = lines.count(); for (int i = 0; i < totalLines; ++i) { const QString &line = lines.at(i); if (line.startsWith('#') || line.trimmed().isEmpty()) continue; const int firstSpace = line.indexOf(' '); const QString keyword = line.left(firstSpace); const QString options = line.right(line.size() - firstSpace).trimmed(); QStringList docu; while (++i < totalLines) { const QString &subline = lines.at(i); if (line.startsWith('#') || subline.trimmed().isEmpty()) { const QString text = "<p><span class=\"option\">" + keyword + "</span> <span class=\"param\">" + options + "</span></p><p>" + docu.join(' ').toHtmlEscaped() + "</p>"; stream.writeStartElement(Constants::DOCUMENTATION_XMLENTRY); stream.writeTextElement(Constants::DOCUMENTATION_XMLKEY, keyword); stream.writeTextElement(Constants::DOCUMENTATION_XMLDOC, text); stream.writeEndElement(); contextWritten = true; break; } else { docu << subline; } } } stream.writeEndElement(); stream.writeEndDocument(); // An empty file causes error messages and a contextless file preventing this function to run // again in order to generate the documentation successfully. Thus delete the file. if (!contextWritten) { file.close(); file.remove(); } }
void AndroidCreateKeystoreCertificate::on_buttonBox_accepted() { if (!validateUserInput()) return; m_keystoreFilePath = Utils::FileName::fromString(QFileDialog::getSaveFileName(this, tr("Keystore file name"), QDir::homePath() + QLatin1String("/android_release.keystore"), tr("Keystore files (*.keystore *.jks)"))); if (m_keystoreFilePath.isEmpty()) return; QString distinguishedNames(QString::fromLatin1("CN=%1, O=%2, L=%3, C=%4") .arg(ui->commonNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,"))) .arg(ui->organizationNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,"))) .arg(ui->localityNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,"))) .arg(ui->countryLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,")))); if (ui->organizationUnitLineEdit->text().length()) distinguishedNames += QLatin1String(", OU=") + ui->organizationUnitLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,")); if (ui->stateNameLineEdit->text().length()) distinguishedNames += QLatin1String(", S=") + ui->stateNameLineEdit->text().replace(QLatin1Char(','), QLatin1String("\\,")); const QString command = AndroidConfigurations::currentConfig().keytoolPath().toString(); QStringList params; params << QLatin1String("-genkey") << QLatin1String("-keyalg") << QLatin1String("RSA") << QLatin1String("-keystore") << m_keystoreFilePath.toString() << QLatin1String("-storepass") << keystorePassword() << QLatin1String("-alias") << certificateAlias() << QLatin1String("-keysize") << ui->keySizeSpinBox->text() << QLatin1String("-validity") << ui->validitySpinBox->text() << QLatin1String("-keypass") << certificatePassword() << QLatin1String("-dname") << distinguishedNames; Utils::SynchronousProcess genKeyCertProc; genKeyCertProc.setTimeoutS(15); Utils::SynchronousProcessResponse response = genKeyCertProc.run(command, params); if (response.result != Utils::SynchronousProcessResponse::Finished || response.exitCode != 0) { QMessageBox::critical(this, tr("Error"), response.exitMessage(command, 15) + QLatin1Char('\n') + response.allOutput()); return; } accept(); }