forked from qt-creator/qt-creator
Fix Android plugin.
Change-Id: I56533be94fc868d04bd1d289ff9d3c381391d41b Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
a1d4afad67
commit
bb0573a8aa
@@ -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 += \
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
77
src/plugins/android/androiddevicefactory.cpp
Normal file
77
src/plugins/android/androiddevicefactory.cpp
Normal file
@@ -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
|
58
src/plugins/android/androiddevicefactory.h
Normal file
58
src/plugins/android/androiddevicefactory.h
Normal file
@@ -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
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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()));
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user