Commit d7f96e32 authored by Daniel Teske's avatar Daniel Teske

Android Deploy Options: Clean up ui

Task-number: QTCREATORBUG-9208

Change-Id: I1b1864908a24af3cd7c576831656267a6390b583
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent e2591965
...@@ -83,10 +83,9 @@ void AndroidDeployStep::ctor() ...@@ -83,10 +83,9 @@ void AndroidDeployStep::ctor()
setDefaultDisplayName(tr("Deploy to Android device")); setDefaultDisplayName(tr("Deploy to Android device"));
m_deployAction = NoDeploy; m_deployAction = NoDeploy;
m_useLocalQtLibs = false;
if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target()->kit())) if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target()->kit()))
if (qt->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0)) if (qt->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0))
m_useLocalQtLibs = true; m_deployAction = BundleLibraries;
} }
bool AndroidDeployStep::init() bool AndroidDeployStep::init()
...@@ -118,7 +117,6 @@ bool AndroidDeployStep::init() ...@@ -118,7 +117,6 @@ bool AndroidDeployStep::init()
m_apkPathDebug = AndroidManager::apkPath(target(), AndroidManager::DebugBuild).toString(); m_apkPathDebug = AndroidManager::apkPath(target(), AndroidManager::DebugBuild).toString();
m_apkPathRelease = AndroidManager::apkPath(target(), AndroidManager::ReleaseBuildSigned).toString(); m_apkPathRelease = AndroidManager::apkPath(target(), AndroidManager::ReleaseBuildSigned).toString();
m_buildDirectory = static_cast<Qt4Project *>(target()->project())->rootQt4ProjectNode()->buildDir(); m_buildDirectory = static_cast<Qt4Project *>(target()->project())->rootQt4ProjectNode()->buildDir();
m_runQASIPackagePath = m_QASIPackagePath;
m_runDeployAction = m_deployAction; m_runDeployAction = m_deployAction;
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit()); ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
if (!tc || tc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) { if (!tc || tc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) {
...@@ -148,15 +146,15 @@ AndroidDeployStep::AndroidDeployAction AndroidDeployStep::deployAction() ...@@ -148,15 +146,15 @@ AndroidDeployStep::AndroidDeployAction AndroidDeployStep::deployAction()
return m_deployAction; return m_deployAction;
} }
bool AndroidDeployStep::useLocalQtLibs()
{
return m_useLocalQtLibs;
}
bool AndroidDeployStep::fromMap(const QVariantMap &map) bool AndroidDeployStep::fromMap(const QVariantMap &map)
{ {
m_useLocalQtLibs = map.value(QLatin1String(USE_LOCAL_QT_KEY), false).toBool();
m_deployAction = AndroidDeployAction(map.value(QLatin1String(DEPLOY_ACTION_KEY), NoDeploy).toInt()); m_deployAction = AndroidDeployAction(map.value(QLatin1String(DEPLOY_ACTION_KEY), NoDeploy).toInt());
QVariant useLocalQt = map.value(QLatin1String(USE_LOCAL_QT_KEY));
if (useLocalQt.isValid()) { // old settings
if (useLocalQt.toBool() && m_deployAction == NoDeploy)
m_deployAction = BundleLibraries;
}
if (m_deployAction == InstallQASI) if (m_deployAction == InstallQASI)
m_deployAction = NoDeploy; m_deployAction = NoDeploy;
return ProjectExplorer::BuildStep::fromMap(map); return ProjectExplorer::BuildStep::fromMap(map);
...@@ -165,7 +163,6 @@ bool AndroidDeployStep::fromMap(const QVariantMap &map) ...@@ -165,7 +163,6 @@ bool AndroidDeployStep::fromMap(const QVariantMap &map)
QVariantMap AndroidDeployStep::toMap() const QVariantMap AndroidDeployStep::toMap() const
{ {
QVariantMap map = ProjectExplorer::BuildStep::toMap(); QVariantMap map = ProjectExplorer::BuildStep::toMap();
map.insert(QLatin1String(USE_LOCAL_QT_KEY), m_useLocalQtLibs);
map.insert(QLatin1String(DEPLOY_ACTION_KEY), m_deployAction); map.insert(QLatin1String(DEPLOY_ACTION_KEY), m_deployAction);
return map; return map;
} }
...@@ -184,7 +181,7 @@ void AndroidDeployStep::cleanLibsOnDevice() ...@@ -184,7 +181,7 @@ void AndroidDeployStep::cleanLibsOnDevice()
QProcess *process = new QProcess(this); QProcess *process = new QProcess(this);
QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber); QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber);
arguments << QLatin1String("shell") << QLatin1String("rm") << QLatin1String("-r") << QLatin1String("/data/local/tmp/qt"); arguments << QLatin1String("shell") << QLatin1String("rm") << QLatin1String("-r") << QLatin1String("/data/local/tmp/qt");
connect(process, SIGNAL(finished(int)), this, SLOT(cleanLibsFinished())); connect(process, SIGNAL(finished(int)), this, SLOT(processFinished()));
const QString adb = AndroidConfigurations::instance().adbToolPath().toString(); const QString adb = AndroidConfigurations::instance().adbToolPath().toString();
Core::MessageManager::instance()->printToOutputPane(adb + QLatin1String(" ") Core::MessageManager::instance()->printToOutputPane(adb + QLatin1String(" ")
+ arguments.join(QLatin1String(" ")), + arguments.join(QLatin1String(" ")),
...@@ -194,7 +191,7 @@ void AndroidDeployStep::cleanLibsOnDevice() ...@@ -194,7 +191,7 @@ void AndroidDeployStep::cleanLibsOnDevice()
delete process; delete process;
} }
void AndroidDeployStep::cleanLibsFinished() void AndroidDeployStep::processFinished()
{ {
QProcess *process = qobject_cast<QProcess *>(sender()); QProcess *process = qobject_cast<QProcess *>(sender());
QTC_ASSERT(process, return); QTC_ASSERT(process, return);
...@@ -204,22 +201,35 @@ void AndroidDeployStep::cleanLibsFinished() ...@@ -204,22 +201,35 @@ void AndroidDeployStep::cleanLibsFinished()
process->deleteLater(); process->deleteLater();
} }
void AndroidDeployStep::setDeployAction(AndroidDeployStep::AndroidDeployAction deploy) void AndroidDeployStep::installQASIPackage(const QString &packagePath)
{ {
m_deployAction = deploy; const QString targetArch = AndroidManager::targetArch(target());
const QString targetSDK = AndroidManager::targetSDK(target());
int deviceAPILevel = targetSDK.mid(targetSDK.indexOf(QLatin1Char('-')) + 1).toInt();
QString deviceSerialNumber = AndroidConfigurations::instance().getDeployDeviceSerialNumber(&deviceAPILevel, targetArch);
if (!deviceSerialNumber.length()) {
Core::MessageManager::instance()->printToOutputPane(tr("Could not run adb. No device found."), Core::MessageManager::NoModeSwitch);
return;
}
AndroidManager::updateDeploymentSettings(target()); QProcess *process = new QProcess(this);
} QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber);
arguments << QLatin1String("install") << QLatin1String("-r ") << packagePath;
void AndroidDeployStep::setDeployQASIPackagePath(const QString &package) connect(process, SIGNAL(finished(int)), this, SLOT(processFinished()));
{ const QString adb = AndroidConfigurations::instance().adbToolPath().toString();
m_QASIPackagePath = package; Core::MessageManager::instance()->printToOutputPane(adb + QLatin1String(" ")
setDeployAction(InstallQASI); + arguments.join(QLatin1String(" ")),
Core::MessageManager::NoModeSwitch);
process->start(adb, arguments);
if (!process->waitForFinished(500))
delete process;
} }
void AndroidDeployStep::setUseLocalQtLibs(bool useLocal) void AndroidDeployStep::setDeployAction(AndroidDeployStep::AndroidDeployAction deploy)
{ {
m_useLocalQtLibs = useLocal; m_deployAction = deploy;
AndroidManager::updateDeploymentSettings(target()); AndroidManager::updateDeploymentSettings(target());
} }
...@@ -453,17 +463,6 @@ bool AndroidDeployStep::deployPackage() ...@@ -453,17 +463,6 @@ bool AndroidDeployStep::deployPackage()
AndroidPackageCreationStep::removeDirectory(tempPath); AndroidPackageCreationStep::removeDirectory(tempPath);
} }
if (m_runDeployAction == InstallQASI) {
if (!runCommand(deployProc, AndroidConfigurations::instance().adbToolPath().toString(),
AndroidDeviceInfo::adbSelector(m_deviceSerialNumber)
<< QLatin1String("install") << QLatin1String("-r ") << m_runQASIPackagePath)) {
raiseError(tr("Qt Android smart installer installation failed"));
disconnect(deployProc, 0, this, 0);
deployProc->deleteLater();
return false;
}
emit resetDelopyAction();
}
deployProc->setWorkingDirectory(m_androidDirPath.toString()); deployProc->setWorkingDirectory(m_androidDirPath.toString());
writeOutput(tr("Installing package onto %1.").arg(m_deviceSerialNumber)); writeOutput(tr("Installing package onto %1.").arg(m_deviceSerialNumber));
......
...@@ -75,9 +75,10 @@ class AndroidDeployStep : public ProjectExplorer::BuildStep ...@@ -75,9 +75,10 @@ class AndroidDeployStep : public ProjectExplorer::BuildStep
public: public:
enum AndroidDeployAction enum AndroidDeployAction
{ {
NoDeploy, NoDeploy, // use ministro
DeployLocal, DeployLocal,
InstallQASI InstallQASI, // unused old value
BundleLibraries
}; };
public: public:
...@@ -89,28 +90,25 @@ public: ...@@ -89,28 +90,25 @@ public:
int deviceAPILevel(); int deviceAPILevel();
AndroidDeployAction deployAction(); AndroidDeployAction deployAction();
bool useLocalQtLibs();
bool fromMap(const QVariantMap &map); bool fromMap(const QVariantMap &map);
QVariantMap toMap() const; QVariantMap toMap() const;
void cleanLibsOnDevice(); void cleanLibsOnDevice();
void installQASIPackage(const QString &packagePath);
public slots: public slots:
void setDeployAction(AndroidDeployAction deploy); void setDeployAction(AndroidDeployAction deploy);
void setDeployQASIPackagePath(const QString &package);
void setUseLocalQtLibs(bool useLocal);
signals: signals:
void done(); void done();
void error(); void error();
void resetDelopyAction();
private slots: private slots:
bool deployPackage(); bool deployPackage();
void handleBuildOutput(); void handleBuildOutput();
void handleBuildError(); void handleBuildError();
void cleanLibsFinished(); void processFinished();
private: private:
AndroidDeployStep(ProjectExplorer::BuildStepList *bc, AndroidDeployStep(ProjectExplorer::BuildStepList *bc,
...@@ -140,7 +138,6 @@ private: ...@@ -140,7 +138,6 @@ private:
QString m_QASIPackagePath; QString m_QASIPackagePath;
AndroidDeployAction m_deployAction; AndroidDeployAction m_deployAction;
bool m_useLocalQtLibs;
// members to transfer data from init() to run // members to transfer data from init() to run
QString m_packageName; QString m_packageName;
......
...@@ -47,21 +47,26 @@ AndroidDeployStepWidget::AndroidDeployStepWidget(AndroidDeployStep *step) : ...@@ -47,21 +47,26 @@ AndroidDeployStepWidget::AndroidDeployStepWidget(AndroidDeployStep *step) :
{ {
ui->setupUi(this); ui->setupUi(this);
ui->useLocalQtLibs->setChecked(m_step->useLocalQtLibs());
switch (m_step->deployAction()) { switch (m_step->deployAction()) {
case AndroidDeployStep::NoDeploy:
ui->ministroOption->setChecked(true);
break;
case AndroidDeployStep::DeployLocal: case AndroidDeployStep::DeployLocal:
ui->deployQtLibs->setChecked(true); ui->temporaryQtOption->setChecked(true);
break;
case AndroidDeployStep::BundleLibraries:
ui->bundleQtOption->setChecked(true);
break; break;
default: default:
ui->devicesQtLibs->setChecked(true); ui->ministroOption->setChecked(true);
break; break;
} }
connect(m_step, SIGNAL(resetDelopyAction()), SLOT(resetAction())); connect(ui->ministroOption, SIGNAL(clicked()), SLOT(setMinistro()));
connect(ui->devicesQtLibs, SIGNAL(clicked()), SLOT(resetAction())); connect(ui->temporaryQtOption, SIGNAL(clicked()), SLOT(setDeployLocalQtLibs()));
connect(ui->deployQtLibs, SIGNAL(clicked()), SLOT(setDeployLocalQtLibs())); connect(ui->bundleQtOption, SIGNAL(clicked()), SLOT(setBundleQtLibs()));
connect(ui->chooseButton, SIGNAL(clicked()), SLOT(setQASIPackagePath())); connect(ui->chooseButton, SIGNAL(clicked()), SLOT(setQASIPackagePath()));
connect(ui->useLocalQtLibs, SIGNAL(stateChanged(int)), SLOT(useLocalQtLibsStateChanged(int)));
connect(ui->cleanLibsPushButton, SIGNAL(clicked()), SLOT(cleanLibsOnDevice())); connect(ui->cleanLibsPushButton, SIGNAL(clicked()), SLOT(cleanLibsOnDevice()));
} }
...@@ -80,9 +85,8 @@ QString AndroidDeployStepWidget::summaryText() const ...@@ -80,9 +85,8 @@ QString AndroidDeployStepWidget::summaryText() const
return displayName(); return displayName();
} }
void AndroidDeployStepWidget::resetAction() void AndroidDeployStepWidget::setMinistro()
{ {
ui->devicesQtLibs->setChecked(true);
m_step->setDeployAction(AndroidDeployStep::NoDeploy); m_step->setDeployAction(AndroidDeployStep::NoDeploy);
} }
...@@ -91,19 +95,20 @@ void AndroidDeployStepWidget::setDeployLocalQtLibs() ...@@ -91,19 +95,20 @@ void AndroidDeployStepWidget::setDeployLocalQtLibs()
m_step->setDeployAction(AndroidDeployStep::DeployLocal); m_step->setDeployAction(AndroidDeployStep::DeployLocal);
} }
void AndroidDeployStepWidget::setBundleQtLibs()
{
m_step->setDeployAction(AndroidDeployStep::BundleLibraries);
}
void AndroidDeployStepWidget::setQASIPackagePath() void AndroidDeployStepWidget::setQASIPackagePath()
{ {
QString packagePath = QString packagePath =
QFileDialog::getOpenFileName(this, tr("Qt Android Smart Installer"), QFileDialog::getOpenFileName(this, tr("Qt Android Smart Installer"),
QDir::homePath(), tr("Android package (*.apk)")); QDir::homePath(), tr("Android package (*.apk)"));
if (packagePath.length()) if (!packagePath.isEmpty())
m_step->setDeployQASIPackagePath(packagePath); m_step->installQASIPackage(packagePath);
} }
void AndroidDeployStepWidget::useLocalQtLibsStateChanged(int state)
{
m_step->setUseLocalQtLibs(state == Qt::Checked);
}
void AndroidDeployStepWidget::cleanLibsOnDevice() void AndroidDeployStepWidget::cleanLibsOnDevice()
{ {
......
...@@ -49,10 +49,11 @@ public: ...@@ -49,10 +49,11 @@ public:
~AndroidDeployStepWidget(); ~AndroidDeployStepWidget();
private slots: private slots:
void resetAction(); void setMinistro();
void setDeployLocalQtLibs(); void setDeployLocalQtLibs();
void setBundleQtLibs();
void setQASIPackagePath(); void setQASIPackagePath();
void useLocalQtLibsStateChanged(int);
void cleanLibsOnDevice(); void cleanLibsOnDevice();
private: private:
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>560</width> <width>678</width>
<height>145</height> <height>155</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -19,138 +19,88 @@ ...@@ -19,138 +19,88 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item row="0" column="0"> <item>
<widget class="QRadioButton" name="devicesQtLibs"> <widget class="QGroupBox" name="groupBox">
<property name="toolTip"> <property name="title">
<string>Use Qt libraries from device</string> <string>Qt Deployment</string>
</property>
<property name="text">
<string>Use Qt libraries from device</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="ministroOption">
<property name="toolTip">
<string>Use the external Ministro application to download and maintain Qt libraries.</string>
</property>
<property name="text">
<string>Use Ministro service to install Qt</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="temporaryQtOption">
<property name="toolTip">
<string>Push local Qt libraries to device. You must have Qt libraries compiled for that platform.
The APK will not be usable on any other device.</string>
</property>
<property name="text">
<string>Deploy local Qt libraries to temporary directory</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bundleQtOption">
<property name="toolTip">
<string>Creates a standalone APK.</string>
</property>
<property name="text">
<string>Bundle Qt libraries in APK</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QGroupBox" name="groupBox_2">
<item> <property name="title">
<widget class="QRadioButton" name="deployQtLibs"> <string>Advanced Actions</string>
<property name="toolTip">
<string>Push local Qt libraries to device.
You must have Qt libraries compiled for that platform</string>
</property>
<property name="text">
<string>Deploy local Qt libraries</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useLocalQtLibs">
<property name="toolTip">
<string>Check this option to force the application to use local Qt libraries instead of system libraries.</string>
</property>
<property name="text">
<string>Use local Qt libraries</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cleanLibsPushButton">
<property name="text">
<string>Clean Libs on Device</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="installQASI">
<property name="toolTip">
<string>Choose and install Ministro system wide Qt shared libraries.
This option is useful when you want to try your application on devices which don't have Android Market (e.g. Android Emulator).</string>
</property>
<property name="text">
<string>Install Ministro, system-wide Qt shared libraries installer</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="chooseButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Choose APK</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>41</height>
</size>
</property> </property>
</spacer> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="cleanLibsPushButton">
<property name="text">
<string>Clean Temporary Libraries Directory on Device</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="chooseButton">
<property name="text">
<string>Install Ministro from APK</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>installQASI</sender>
<signal>toggled(bool)</signal>
<receiver>chooseButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>119</x>
<y>68</y>
</hint>
<hint type="destinationlabel">
<x>272</x>
<y>64</y>
</hint>
</hints>
</connection>
<connection>
<sender>deployQtLibs</sender>
<signal>clicked(bool)</signal>
<receiver>useLocalQtLibs</receiver>
<slot>setChecked(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>138</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>343</x>
<y>44</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>
...@@ -319,8 +319,7 @@ bool AndroidManager::bundleQt(ProjectExplorer::Target *target) ...@@ -319,8 +319,7 @@ bool AndroidManager::bundleQt(ProjectExplorer::Target *target)
AndroidRunConfiguration *androidRunConfiguration = qobject_cast<AndroidRunConfiguration *>(runConfiguration); AndroidRunConfiguration *androidRunConfiguration = qobject_cast<AndroidRunConfiguration *>(runConfiguration);
if (androidRunConfiguration != 0) { if (androidRunConfiguration != 0) {
AndroidDeployStep *deployStep = androidRunConfiguration->deployStep(); AndroidDeployStep *deployStep = androidRunConfiguration->deployStep();
return deployStep->deployAction() == AndroidDeployStep::NoDeploy return deployStep->deployAction() == AndroidDeployStep::BundleLibraries;
&& deployStep->useLocalQtLibs();
} }
return false; return false;
...@@ -340,9 +339,10 @@ bool AndroidManager::updateDeploymentSettings(ProjectExplorer::Target *target) ...@@ -340,9 +339,10 @@ bool AndroidManager::updateDeploymentSettings(ProjectExplorer::Target *target)
return false; return false;