Commit bb0573a8 authored by BogDan Vatra's avatar BogDan Vatra Committed by Tobias Hunger

Fix Android plugin.

Change-Id: I56533be94fc868d04bd1d289ff9d3c381391d41b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent a1d4afad
...@@ -35,7 +35,8 @@ HEADERS += \ ...@@ -35,7 +35,8 @@ HEADERS += \
androiddeployconfiguration.h \ androiddeployconfiguration.h \
androidcreatekeystorecertificate.h \ androidcreatekeystorecertificate.h \
javaparser.h \ javaparser.h \
androidplugin.h androidplugin.h \
androiddevicefactory.h
SOURCES += \ SOURCES += \
androidconfigurations.cpp \ androidconfigurations.cpp \
...@@ -61,7 +62,8 @@ SOURCES += \ ...@@ -61,7 +62,8 @@ SOURCES += \
androiddeployconfiguration.cpp \ androiddeployconfiguration.cpp \
androidcreatekeystorecertificate.cpp \ androidcreatekeystorecertificate.cpp \
javaparser.cpp \ javaparser.cpp \
androidplugin.cpp androidplugin.cpp \
androiddevicefactory.cpp
FORMS += \ FORMS += \
......
...@@ -214,7 +214,8 @@ void AndroidConfigurations::setConfig(const AndroidConfig &devConfigs) ...@@ -214,7 +214,8 @@ void AndroidConfigurations::setConfig(const AndroidConfig &devConfigs)
void AndroidConfigurations::updateAvailablePlatforms() void AndroidConfigurations::updateAvailablePlatforms()
{ {
m_availablePlatforms.clear(); m_availablePlatforms.clear();
QDirIterator it(m_config.ndkLocation.appendPath(QLatin1String("platforms")).toString(), QStringList() << QLatin1String("android-*"), QDir::Dirs); Utils::FileName path = m_config.ndkLocation;
QDirIterator it(path.appendPath(QLatin1String("platforms")).toString(), QStringList() << QLatin1String("android-*"), QDir::Dirs);
while (it.hasNext()) { while (it.hasNext()) {
const QString &fileName = it.next(); const QString &fileName = it.next();
m_availablePlatforms.push_back(fileName.mid(fileName.lastIndexOf(QLatin1Char('-')) + 1).toInt()); m_availablePlatforms.push_back(fileName.mid(fileName.lastIndexOf(QLatin1Char('-')) + 1).toInt());
...@@ -282,7 +283,7 @@ Utils::FileName AndroidConfigurations::androidToolPath() const ...@@ -282,7 +283,7 @@ Utils::FileName AndroidConfigurations::androidToolPath() const
return path.appendPath(QLatin1String("tools/android"ANDROID_BAT_SUFFIX)); return path.appendPath(QLatin1String("tools/android"ANDROID_BAT_SUFFIX));
#else #else
Utils::FileName path = m_config.sdkLocation; Utils::FileName path = m_config.sdkLocation;
return path.appendPath(QLatin1String("tools/android"ANDROID_EXE_SUFFIX)); return path.appendPath(QLatin1String("tools/android"));
#endif #endif
} }
......
...@@ -67,6 +67,7 @@ const char ANDROID_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Android", "Androi ...@@ -67,6 +67,7 @@ const char ANDROID_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Android", "Androi
const char ANDROID_SETTINGS_CATEGORY_ICON[] = ":/android/images/QtAndroid.png"; const char ANDROID_SETTINGS_CATEGORY_ICON[] = ":/android/images/QtAndroid.png";
const char ANDROID_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android"; const char ANDROID_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android";
const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android"; const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android";
const char ANDROID_DEVICE_TYPE[] = "Android.Device.Type";
} }
} // namespace Android } // namespace Android
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
using namespace Android::Internal; using namespace Android::Internal;
AndroidDeployConfiguration::AndroidDeployConfiguration(ProjectExplorer::Target *parent) AndroidDeployConfiguration::AndroidDeployConfiguration(ProjectExplorer::Target *parent, Core::Id id)
:DeployConfiguration(parent, Core::Id(ANDROID_DEPLOYCONFIGURATION_ID)) :DeployConfiguration(parent, id)
{ {
setDisplayName(tr("Deploy to Android device")); setDisplayName(tr("Deploy to Android device"));
setDefaultDisplayName(displayName()); setDefaultDisplayName(displayName());
...@@ -75,7 +75,7 @@ bool AndroidDeployConfigurationFactory::canCreate(ProjectExplorer::Target *paren ...@@ -75,7 +75,7 @@ bool AndroidDeployConfigurationFactory::canCreate(ProjectExplorer::Target *paren
ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id) ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id)
{ {
Q_UNUSED(id); Q_UNUSED(id);
AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent); AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent, id);
if (!dc) if (!dc)
return 0; return 0;
dc->stepList()->insertStep(0, new AndroidPackageInstallationStep(dc->stepList())); dc->stepList()->insertStep(0, new AndroidPackageInstallationStep(dc->stepList()));
...@@ -86,14 +86,16 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::create( ...@@ -86,14 +86,16 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::create(
bool AndroidDeployConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const bool AndroidDeployConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
{ {
return canCreate(parent, ProjectExplorer::idFromMap(map)); if (!canHandle(parent))
return false;
return ProjectExplorer::idFromMap(map).toString().startsWith(ANDROID_DC_PREFIX);
} }
ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map) ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map)
{ {
if (!canRestore(parent, map)) if (!canRestore(parent, map))
return 0; return 0;
AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent); AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent, ProjectExplorer::idFromMap(map));
if (dc->fromMap(map)) if (dc->fromMap(map))
return dc; return dc;
...@@ -117,13 +119,13 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::clone(P ...@@ -117,13 +119,13 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::clone(P
QList<Core::Id> AndroidDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const QList<Core::Id> AndroidDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
{ {
if (!AndroidManager::supportsAndroid(parent))
return QList<Core::Id>();
QList<Core::Id> result; QList<Core::Id> result;
if (!canHandle(parent))
return result;
Qt4ProjectManager::Qt4Project *project = static_cast<Qt4ProjectManager::Qt4Project *>(parent->project()); Qt4ProjectManager::Qt4Project *project = static_cast<Qt4ProjectManager::Qt4Project *>(parent->project());
foreach (const QString &id, project->applicationProFilePathes(QLatin1String(ANDROID_DC_PREFIX))) foreach (const QString &id, project->applicationProFilePathes(QLatin1String(ANDROID_DC_PREFIX)))
result << Core::Id(id.toUtf8().constData()); result << Core::Id(id);
return result; return result;
} }
...@@ -133,3 +135,8 @@ QString AndroidDeployConfigurationFactory::displayNameForId(const Core::Id id) c ...@@ -133,3 +135,8 @@ QString AndroidDeployConfigurationFactory::displayNameForId(const Core::Id id) c
return tr("Deploy on Android"); return tr("Deploy on Android");
return QString(); return QString();
} }
bool AndroidDeployConfigurationFactory::canHandle(ProjectExplorer::Target *parent) const
{
return AndroidManager::supportsAndroid(parent);
}
...@@ -48,7 +48,7 @@ class AndroidDeployConfiguration : public ProjectExplorer::DeployConfiguration ...@@ -48,7 +48,7 @@ class AndroidDeployConfiguration : public ProjectExplorer::DeployConfiguration
friend class AndroidDeployConfigurationFactory; friend class AndroidDeployConfigurationFactory;
public: public:
AndroidDeployConfiguration(ProjectExplorer::Target *parent); AndroidDeployConfiguration(ProjectExplorer::Target *parent, Core::Id id);
virtual ~AndroidDeployConfiguration(); virtual ~AndroidDeployConfiguration();
protected: protected:
AndroidDeployConfiguration(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *source); AndroidDeployConfiguration(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *source);
...@@ -72,6 +72,9 @@ public: ...@@ -72,6 +72,9 @@ public:
QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const; QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const;
// used to translate the ids to names to display to the user // used to translate the ids to names to display to the user
QString displayNameForId(const Core::Id id) const; QString displayNameForId(const Core::Id id) const;
private:
bool canHandle(ProjectExplorer::Target *parent) const;
}; };
} // namespace Internal } // namespace Internal
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 BogDan Vatra <bog_dan_ro@yahoo.com>
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "androiddevicefactory.h"
#include "androidconstants.h"
#include <coreplugin/id.h>
namespace Android {
namespace Internal {
AndroidDeviceFactory::AndroidDeviceFactory()
{ setObjectName(QLatin1String("AndroidDeviceFactory")); }
QString AndroidDeviceFactory::displayNameForId(Core::Id type) const
{
if (type == Core::Id(Constants::ANDROID_DEVICE_TYPE))
return tr("Android Device");
return QString();
}
QList<Core::Id> AndroidDeviceFactory::availableCreationIds() const
{
return QList<Core::Id>() << Core::Id(Constants::ANDROID_DEVICE_TYPE);
}
bool AndroidDeviceFactory::canCreate() const
{
return false;
}
ProjectExplorer::IDevice::Ptr AndroidDeviceFactory::create(Core::Id id) const
{
return ProjectExplorer::IDevice::Ptr();
}
bool AndroidDeviceFactory::canRestore(const QVariantMap &map) const
{
return false;
}
ProjectExplorer::IDevice::Ptr AndroidDeviceFactory::restore(const QVariantMap &map) const
{
return ProjectExplorer::IDevice::Ptr();
}
} // namespace Internal
} // namespace Android
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 BogDan Vatra <bog_dan_ro@yahoo.com>
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANDROIDDEVICEFACTORY_H
#define ANDROIDDEVICEFACTORY_H
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace Android {
namespace Internal {
class AndroidDeviceFactory : public ProjectExplorer::IDeviceFactory
{
public:
AndroidDeviceFactory();
QString displayNameForId(Core::Id type) const;
QList<Core::Id> availableCreationIds() const;
bool canCreate() const;
ProjectExplorer::IDevice::Ptr create(Core::Id id) const;
bool canRestore(const QVariantMap &map) const;
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const;
};
} // namespace Internal
} // namespace Android
#endif // ANDROIDDEVICEFACTORY_H
...@@ -432,10 +432,15 @@ bool AndroidManager::createAndroidTemplatesIfNecessary(ProjectExplorer::Target * ...@@ -432,10 +432,15 @@ bool AndroidManager::createAndroidTemplatesIfNecessary(ProjectExplorer::Target *
} }
} }
Utils::FileName src = androidPath;
src.appendPath("src");
Utils::FileName res = androidPath;
res.appendPath("res");
if (!forceUpdate && androidPath.toFileInfo().exists() if (!forceUpdate && androidPath.toFileInfo().exists()
&& manifestPath(target).toFileInfo().exists() && manifestPath(target).toFileInfo().exists()
&& androidPath.append(QLatin1String("/src")).toFileInfo().exists() && src.toFileInfo().exists()
&& androidPath.append(QLatin1String("/res")).toFileInfo().exists()) && res.toFileInfo().exists())
return true; return true;
forceUpdate &= androidPath.toFileInfo().exists(); forceUpdate &= androidPath.toFileInfo().exists();
......
...@@ -152,15 +152,17 @@ bool AndroidPackageCreationStep::init() ...@@ -152,15 +152,17 @@ bool AndroidPackageCreationStep::init()
// Copying // Copying
m_androidDir = AndroidManager::dirPath(target()); m_androidDir = AndroidManager::dirPath(target());
Utils::FileName path = m_androidDir;
Utils::FileName androidLibPath; Utils::FileName androidLibPath;
if (project->rootQt4ProjectNode()->variableValue(Qt4ProjectManager::ConfigVar).contains(QLatin1String("x86"))) if (project->rootQt4ProjectNode()->variableValue(Qt4ProjectManager::ConfigVar).contains(QLatin1String("x86")))
androidLibPath = m_androidDir.appendPath(QLatin1String("libs/x86")); androidLibPath = path.appendPath(QLatin1String("libs/x86"));
else if (project->rootQt4ProjectNode() else if (project->rootQt4ProjectNode()
->variableValue(Qt4ProjectManager::ConfigVar).contains(QLatin1String("armeabi-v7a"))) ->variableValue(Qt4ProjectManager::ConfigVar).contains(QLatin1String("armeabi-v7a")))
androidLibPath = m_androidDir.appendPath(QLatin1String("libs/armeabi-v7a")); androidLibPath = path.appendPath(QLatin1String("libs/armeabi-v7a"));
else else
androidLibPath = m_androidDir.appendPath(QLatin1String("libs/armeabi")); androidLibPath = path.appendPath(QLatin1String("libs/armeabi"));
m_gdbServerDestination = androidLibPath.appendPath(QLatin1String("gdbserver")); path = m_androidDir;
m_gdbServerDestination = path.appendPath(QLatin1String("gdbserver"));
m_gdbServerSource = AndroidConfigurations::instance().gdbServerPath(target()->activeRunConfiguration()->abi().architecture()); m_gdbServerSource = AndroidConfigurations::instance().gdbServerPath(target()->activeRunConfiguration()->abi().architecture());
m_debugBuild = bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild; m_debugBuild = bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild;
......
...@@ -227,9 +227,9 @@ void AndroidPackageCreationWidget::initGui() ...@@ -227,9 +227,9 @@ void AndroidPackageCreationWidget::initGui()
m_fileSystemWatcher->addPath(AndroidManager::manifestPath(target).toString()); m_fileSystemWatcher->addPath(AndroidManager::manifestPath(target).toString());
m_fileSystemWatcher->addPath(AndroidManager::srcPath(target).toString()); m_fileSystemWatcher->addPath(AndroidManager::srcPath(target).toString());
connect(m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), connect(m_fileSystemWatcher, SIGNAL(directoryChanged(QString)),
this, SIGNAL(updateAndroidProjectInfo())); this, SLOT(updateAndroidProjectInfo()));
connect(m_fileSystemWatcher, SIGNAL(fileChanged(QString)), this, connect(m_fileSystemWatcher, SIGNAL(fileChanged(QString)), this,
SIGNAL(updateAndroidProjectInfo())); SLOT(updateAndroidProjectInfo()));
m_ui->packageNameLineEdit->setValidator(new QRegExpValidator(QRegExp(packageNameRegExp), this)); m_ui->packageNameLineEdit->setValidator(new QRegExpValidator(QRegExp(packageNameRegExp), this));
connect(m_ui->packageNameLineEdit, SIGNAL(editingFinished()), SLOT(setPackageName())); connect(m_ui->packageNameLineEdit, SIGNAL(editingFinished()), SLOT(setPackageName()));
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "androidconstants.h" #include "androidconstants.h"
#include "androidconfigurations.h" #include "androidconfigurations.h"
#include "androiddeploystepfactory.h" #include "androiddeploystepfactory.h"
#include "androiddevicefactory.h"
#include "androidconfigurations.h" #include "androidconfigurations.h"
#include "androidmanager.h" #include "androidmanager.h"
#include "androidpackagecreationfactory.h" #include "androidpackagecreationfactory.h"
...@@ -74,6 +75,7 @@ bool AndroidPlugin::initialize(const QStringList &arguments, ...@@ -74,6 +75,7 @@ bool AndroidPlugin::initialize(const QStringList &arguments,
addAutoReleasedObject(new Internal::AndroidQtVersionFactory); addAutoReleasedObject(new Internal::AndroidQtVersionFactory);
addAutoReleasedObject(new Internal::AndroidToolChainFactory); addAutoReleasedObject(new Internal::AndroidToolChainFactory);
addAutoReleasedObject(new Internal::AndroidDeployConfigurationFactory); addAutoReleasedObject(new Internal::AndroidDeployConfigurationFactory);
addAutoReleasedObject(new Internal::AndroidDeviceFactory);
return true; return true;
} }
......
...@@ -217,12 +217,12 @@ bool AndroidSettingsWidget::checkNDK(const Utils::FileName &location) ...@@ -217,12 +217,12 @@ bool AndroidSettingsWidget::checkNDK(const Utils::FileName &location)
QMessageBox::critical(this, tr("Android SDK Folder"), tr("\"%1\" doesn't seem to be an Android NDK top folder").arg(location.toUserOutput())); QMessageBox::critical(this, tr("Android SDK Folder"), tr("\"%1\" doesn't seem to be an Android NDK top folder").arg(location.toUserOutput()));
return false; return false;
} }
m_androidConfig.ndkLocation = location;
m_ui->toolchainVersionComboBox->setEnabled(true); m_ui->toolchainVersionComboBox->setEnabled(true);
m_ui->GdbLocationLineEdit->setEnabled(true); m_ui->GdbLocationLineEdit->setEnabled(true);
m_ui->GdbLocationPushButton->setEnabled(true); m_ui->GdbLocationPushButton->setEnabled(true);
m_ui->GdbserverLocationLineEdit->setEnabled(true); m_ui->GdbserverLocationLineEdit->setEnabled(true);
m_ui->GdbserverLocationPushButton->setEnabled(true); m_ui->GdbserverLocationPushButton->setEnabled(true);
fillToolchainVersions();
return true; return true;
} }
...@@ -243,10 +243,10 @@ void AndroidSettingsWidget::sdkLocationEditingFinished() ...@@ -243,10 +243,10 @@ void AndroidSettingsWidget::sdkLocationEditingFinished()
void AndroidSettingsWidget::ndkLocationEditingFinished() void AndroidSettingsWidget::ndkLocationEditingFinished()
{ {
Utils::FileName location = Utils::FileName::fromUserInput(m_ui->NDKLocationLineEdit->text()); Utils::FileName location = Utils::FileName::fromUserInput(m_ui->NDKLocationLineEdit->text());
if (checkNDK(location)) if (!checkNDK(location))
return; return;
m_androidConfig.ndkLocation = location;
saveSettings(true); saveSettings(true);
fillToolchainVersions();
} }
void AndroidSettingsWidget::fillToolchainVersions() void AndroidSettingsWidget::fillToolchainVersions()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment