diff options
author | BogDan Vatra <bog_dan_ro@yahoo.com> | 2012-06-23 12:24:44 +0300 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2012-06-23 11:53:33 +0200 |
commit | bb0573a8aa8257ea1175d2a44d2207d8ea01837a (patch) | |
tree | 83356d0dec37b10f4afd718011c0b637aaacbef3 | |
parent | a1d4afad676f596280cf9f59fc765c3990051603 (diff) | |
download | qt-creator-bb0573a8aa8257ea1175d2a44d2207d8ea01837a.tar.gz |
Fix Android plugin.
Change-Id: I56533be94fc868d04bd1d289ff9d3c381391d41b
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
-rw-r--r-- | src/plugins/android/android.pro | 6 | ||||
-rw-r--r-- | src/plugins/android/androidconfigurations.cpp | 5 | ||||
-rw-r--r-- | src/plugins/android/androidconstants.h | 1 | ||||
-rw-r--r-- | src/plugins/android/androiddeployconfiguration.cpp | 25 | ||||
-rw-r--r-- | src/plugins/android/androiddeployconfiguration.h | 5 | ||||
-rw-r--r-- | src/plugins/android/androiddevicefactory.cpp | 77 | ||||
-rw-r--r-- | src/plugins/android/androiddevicefactory.h | 58 | ||||
-rw-r--r-- | src/plugins/android/androidmanager.cpp | 9 | ||||
-rw-r--r-- | src/plugins/android/androidpackagecreationstep.cpp | 10 | ||||
-rw-r--r-- | src/plugins/android/androidpackagecreationwidget.cpp | 4 | ||||
-rw-r--r-- | src/plugins/android/androidplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/android/androidsettingswidget.cpp | 6 |
12 files changed, 183 insertions, 25 deletions
diff --git a/src/plugins/android/android.pro b/src/plugins/android/android.pro index 2ebfd680bd..324fd6d387 100644 --- a/src/plugins/android/android.pro +++ b/src/plugins/android/android.pro @@ -35,7 +35,8 @@ HEADERS += \ androiddeployconfiguration.h \ androidcreatekeystorecertificate.h \ javaparser.h \ - androidplugin.h + androidplugin.h \ + androiddevicefactory.h SOURCES += \ androidconfigurations.cpp \ @@ -61,7 +62,8 @@ SOURCES += \ androiddeployconfiguration.cpp \ androidcreatekeystorecertificate.cpp \ javaparser.cpp \ - androidplugin.cpp + androidplugin.cpp \ + androiddevicefactory.cpp FORMS += \ diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 1873728735..f51aa3b5b7 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -214,7 +214,8 @@ void AndroidConfigurations::setConfig(const AndroidConfig &devConfigs) void AndroidConfigurations::updateAvailablePlatforms() { 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()) { const QString &fileName = it.next(); m_availablePlatforms.push_back(fileName.mid(fileName.lastIndexOf(QLatin1Char('-')) + 1).toInt()); @@ -282,7 +283,7 @@ Utils::FileName AndroidConfigurations::androidToolPath() const return path.appendPath(QLatin1String("tools/android"ANDROID_BAT_SUFFIX)); #else Utils::FileName path = m_config.sdkLocation; - return path.appendPath(QLatin1String("tools/android"ANDROID_EXE_SUFFIX)); + return path.appendPath(QLatin1String("tools/android")); #endif } diff --git a/src/plugins/android/androidconstants.h b/src/plugins/android/androidconstants.h index e05c93784a..0f849e4198 100644 --- a/src/plugins/android/androidconstants.h +++ b/src/plugins/android/androidconstants.h @@ -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_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android"; const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android"; +const char ANDROID_DEVICE_TYPE[] = "Android.Device.Type"; } } // namespace Android diff --git a/src/plugins/android/androiddeployconfiguration.cpp b/src/plugins/android/androiddeployconfiguration.cpp index c07219b793..8a936d790a 100644 --- a/src/plugins/android/androiddeployconfiguration.cpp +++ b/src/plugins/android/androiddeployconfiguration.cpp @@ -45,8 +45,8 @@ using namespace Android::Internal; -AndroidDeployConfiguration::AndroidDeployConfiguration(ProjectExplorer::Target *parent) - :DeployConfiguration(parent, Core::Id(ANDROID_DEPLOYCONFIGURATION_ID)) +AndroidDeployConfiguration::AndroidDeployConfiguration(ProjectExplorer::Target *parent, Core::Id id) + :DeployConfiguration(parent, id) { setDisplayName(tr("Deploy to Android device")); setDefaultDisplayName(displayName()); @@ -75,7 +75,7 @@ bool AndroidDeployConfigurationFactory::canCreate(ProjectExplorer::Target *paren ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::create(ProjectExplorer::Target *parent, const Core::Id id) { Q_UNUSED(id); - AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent); + AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent, id); if (!dc) return 0; dc->stepList()->insertStep(0, new AndroidPackageInstallationStep(dc->stepList())); @@ -86,14 +86,16 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::create( 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) { if (!canRestore(parent, map)) return 0; - AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent); + AndroidDeployConfiguration *dc = new AndroidDeployConfiguration(parent, ProjectExplorer::idFromMap(map)); if (dc->fromMap(map)) return dc; @@ -117,13 +119,13 @@ ProjectExplorer::DeployConfiguration *AndroidDeployConfigurationFactory::clone(P QList<Core::Id> AndroidDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const { - if (!AndroidManager::supportsAndroid(parent)) - return QList<Core::Id>(); - QList<Core::Id> result; + if (!canHandle(parent)) + return result; + Qt4ProjectManager::Qt4Project *project = static_cast<Qt4ProjectManager::Qt4Project *>(parent->project()); foreach (const QString &id, project->applicationProFilePathes(QLatin1String(ANDROID_DC_PREFIX))) - result << Core::Id(id.toUtf8().constData()); + result << Core::Id(id); return result; } @@ -133,3 +135,8 @@ QString AndroidDeployConfigurationFactory::displayNameForId(const Core::Id id) c return tr("Deploy on Android"); return QString(); } + +bool AndroidDeployConfigurationFactory::canHandle(ProjectExplorer::Target *parent) const +{ + return AndroidManager::supportsAndroid(parent); +} diff --git a/src/plugins/android/androiddeployconfiguration.h b/src/plugins/android/androiddeployconfiguration.h index 546470076c..27e7293782 100644 --- a/src/plugins/android/androiddeployconfiguration.h +++ b/src/plugins/android/androiddeployconfiguration.h @@ -48,7 +48,7 @@ class AndroidDeployConfiguration : public ProjectExplorer::DeployConfiguration friend class AndroidDeployConfigurationFactory; public: - AndroidDeployConfiguration(ProjectExplorer::Target *parent); + AndroidDeployConfiguration(ProjectExplorer::Target *parent, Core::Id id); virtual ~AndroidDeployConfiguration(); protected: AndroidDeployConfiguration(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *source); @@ -72,6 +72,9 @@ public: QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const; // used to translate the ids to names to display to the user QString displayNameForId(const Core::Id id) const; + +private: + bool canHandle(ProjectExplorer::Target *parent) const; }; } // namespace Internal diff --git a/src/plugins/android/androiddevicefactory.cpp b/src/plugins/android/androiddevicefactory.cpp new file mode 100644 index 0000000000..4692b3a6b6 --- /dev/null +++ b/src/plugins/android/androiddevicefactory.cpp @@ -0,0 +1,77 @@ +/************************************************************************** +** +** 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 diff --git a/src/plugins/android/androiddevicefactory.h b/src/plugins/android/androiddevicefactory.h new file mode 100644 index 0000000000..499663b894 --- /dev/null +++ b/src/plugins/android/androiddevicefactory.h @@ -0,0 +1,58 @@ +/************************************************************************** +** +** 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 diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp index b95c2bdb3f..d88f056d25 100644 --- a/src/plugins/android/androidmanager.cpp +++ b/src/plugins/android/androidmanager.cpp @@ -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() && manifestPath(target).toFileInfo().exists() - && androidPath.append(QLatin1String("/src")).toFileInfo().exists() - && androidPath.append(QLatin1String("/res")).toFileInfo().exists()) + && src.toFileInfo().exists() + && res.toFileInfo().exists()) return true; forceUpdate &= androidPath.toFileInfo().exists(); diff --git a/src/plugins/android/androidpackagecreationstep.cpp b/src/plugins/android/androidpackagecreationstep.cpp index dccfe9423b..293201a8ec 100644 --- a/src/plugins/android/androidpackagecreationstep.cpp +++ b/src/plugins/android/androidpackagecreationstep.cpp @@ -152,15 +152,17 @@ bool AndroidPackageCreationStep::init() // Copying m_androidDir = AndroidManager::dirPath(target()); + Utils::FileName path = m_androidDir; Utils::FileName androidLibPath; 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() ->variableValue(Qt4ProjectManager::ConfigVar).contains(QLatin1String("armeabi-v7a"))) - androidLibPath = m_androidDir.appendPath(QLatin1String("libs/armeabi-v7a")); + androidLibPath = path.appendPath(QLatin1String("libs/armeabi-v7a")); else - androidLibPath = m_androidDir.appendPath(QLatin1String("libs/armeabi")); - m_gdbServerDestination = androidLibPath.appendPath(QLatin1String("gdbserver")); + androidLibPath = path.appendPath(QLatin1String("libs/armeabi")); + path = m_androidDir; + m_gdbServerDestination = path.appendPath(QLatin1String("gdbserver")); m_gdbServerSource = AndroidConfigurations::instance().gdbServerPath(target()->activeRunConfiguration()->abi().architecture()); m_debugBuild = bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild; diff --git a/src/plugins/android/androidpackagecreationwidget.cpp b/src/plugins/android/androidpackagecreationwidget.cpp index 046ec769f0..48faf3956a 100644 --- a/src/plugins/android/androidpackagecreationwidget.cpp +++ b/src/plugins/android/androidpackagecreationwidget.cpp @@ -227,9 +227,9 @@ void AndroidPackageCreationWidget::initGui() m_fileSystemWatcher->addPath(AndroidManager::manifestPath(target).toString()); m_fileSystemWatcher->addPath(AndroidManager::srcPath(target).toString()); connect(m_fileSystemWatcher, SIGNAL(directoryChanged(QString)), - this, SIGNAL(updateAndroidProjectInfo())); + this, SLOT(updateAndroidProjectInfo())); connect(m_fileSystemWatcher, SIGNAL(fileChanged(QString)), this, - SIGNAL(updateAndroidProjectInfo())); + SLOT(updateAndroidProjectInfo())); m_ui->packageNameLineEdit->setValidator(new QRegExpValidator(QRegExp(packageNameRegExp), this)); connect(m_ui->packageNameLineEdit, SIGNAL(editingFinished()), SLOT(setPackageName())); diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp index 37703f8558..9197ea4574 100644 --- a/src/plugins/android/androidplugin.cpp +++ b/src/plugins/android/androidplugin.cpp @@ -35,6 +35,7 @@ #include "androidconstants.h" #include "androidconfigurations.h" #include "androiddeploystepfactory.h" +#include "androiddevicefactory.h" #include "androidconfigurations.h" #include "androidmanager.h" #include "androidpackagecreationfactory.h" @@ -74,6 +75,7 @@ bool AndroidPlugin::initialize(const QStringList &arguments, addAutoReleasedObject(new Internal::AndroidQtVersionFactory); addAutoReleasedObject(new Internal::AndroidToolChainFactory); addAutoReleasedObject(new Internal::AndroidDeployConfigurationFactory); + addAutoReleasedObject(new Internal::AndroidDeviceFactory); return true; } diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 0c9b86338d..ec6fca61d4 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -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())); return false; } + m_androidConfig.ndkLocation = location; m_ui->toolchainVersionComboBox->setEnabled(true); m_ui->GdbLocationLineEdit->setEnabled(true); m_ui->GdbLocationPushButton->setEnabled(true); m_ui->GdbserverLocationLineEdit->setEnabled(true); m_ui->GdbserverLocationPushButton->setEnabled(true); - fillToolchainVersions(); return true; } @@ -243,10 +243,10 @@ void AndroidSettingsWidget::sdkLocationEditingFinished() void AndroidSettingsWidget::ndkLocationEditingFinished() { Utils::FileName location = Utils::FileName::fromUserInput(m_ui->NDKLocationLineEdit->text()); - if (checkNDK(location)) + if (!checkNDK(location)) return; - m_androidConfig.ndkLocation = location; saveSettings(true); + fillToolchainVersions(); } void AndroidSettingsWidget::fillToolchainVersions() |