2012-04-18 20:30:57 +03:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-04-18 20:30:57 +03:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#ifndef ANDROIDRUNNER_H
|
|
|
|
|
#define ANDROIDRUNNER_H
|
|
|
|
|
|
|
|
|
|
#include "androidconfigurations.h"
|
|
|
|
|
|
2013-05-03 12:41:58 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QTimer>
|
2014-11-18 15:14:40 +01:00
|
|
|
#include <QTcpSocket>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <QThread>
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QMutex>
|
|
|
|
|
|
|
|
|
|
namespace Android {
|
2014-07-04 14:28:55 +02:00
|
|
|
class AndroidRunConfiguration;
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
namespace Internal {
|
2012-08-09 01:56:51 +02:00
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
class AndroidRunner : public QThread
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2014-11-18 15:14:40 +01:00
|
|
|
enum DebugHandShakeType {
|
|
|
|
|
PingPongFiles,
|
|
|
|
|
SocketHandShake
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
public:
|
2013-05-03 12:41:58 +02:00
|
|
|
AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig,
|
|
|
|
|
ProjectExplorer::RunMode runMode);
|
2012-04-18 20:30:57 +03:00
|
|
|
~AndroidRunner();
|
|
|
|
|
|
|
|
|
|
QString displayName() const;
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void start();
|
2012-12-18 14:25:07 +02:00
|
|
|
void stop();
|
2013-04-18 10:01:05 +02:00
|
|
|
void handleRemoteDebuggerRunning();
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
signals:
|
2013-02-27 15:12:36 +01:00
|
|
|
void remoteServerRunning(const QByteArray &serverChannel, int pid);
|
|
|
|
|
void remoteProcessStarted(int gdbServerPort, int qmlPort);
|
2012-04-18 20:30:57 +03:00
|
|
|
void remoteProcessFinished(const QString &errString = QString());
|
|
|
|
|
|
|
|
|
|
void remoteOutput(const QByteArray &output);
|
|
|
|
|
void remoteErrorOutput(const QByteArray &output);
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void checkPID();
|
|
|
|
|
void logcatReadStandardError();
|
|
|
|
|
void logcatReadStandardOutput();
|
|
|
|
|
void asyncStart();
|
|
|
|
|
|
|
|
|
|
private:
|
2013-02-27 15:12:36 +01:00
|
|
|
void adbKill(qint64 pid);
|
|
|
|
|
QStringList selector() const { return m_selector; }
|
|
|
|
|
void forceStop();
|
|
|
|
|
QByteArray runPs();
|
|
|
|
|
void findPs();
|
2014-03-13 17:33:47 +01:00
|
|
|
void logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError);
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QProcess m_adbLogcatProcess;
|
2013-02-27 15:12:36 +01:00
|
|
|
QTimer m_checkPIDTimer;
|
|
|
|
|
bool m_wasStarted;
|
2014-02-12 12:24:56 +01:00
|
|
|
int m_tries;
|
2013-02-27 15:12:36 +01:00
|
|
|
|
2014-03-13 17:33:47 +01:00
|
|
|
QByteArray m_stdoutBuffer;
|
|
|
|
|
QByteArray m_stderrBuffer;
|
2012-04-18 20:30:57 +03:00
|
|
|
QString m_intentName;
|
|
|
|
|
QString m_packageName;
|
|
|
|
|
QString m_deviceSerialNumber;
|
|
|
|
|
qint64 m_processPID;
|
2012-06-24 19:32:45 -07:00
|
|
|
bool m_useCppDebugger;
|
|
|
|
|
bool m_useQmlDebugger;
|
2013-05-03 12:41:58 +02:00
|
|
|
bool m_useQmlProfiler;
|
2013-02-27 15:12:36 +01:00
|
|
|
ushort m_localGdbServerPort; // Local end of forwarded debug socket.
|
2013-04-18 10:01:05 +02:00
|
|
|
quint16 m_qmlPort;
|
2012-04-18 20:30:57 +03:00
|
|
|
bool m_useLocalQtLibs;
|
2013-02-27 15:12:36 +01:00
|
|
|
QString m_pingFile;
|
|
|
|
|
QString m_pongFile;
|
|
|
|
|
QString m_gdbserverPath;
|
|
|
|
|
QString m_gdbserverCommand;
|
|
|
|
|
QString m_gdbserverSocket;
|
2012-04-18 20:30:57 +03:00
|
|
|
QString m_localLibs;
|
|
|
|
|
QString m_localJars;
|
2013-01-06 16:23:08 +02:00
|
|
|
QString m_localJarsInitClasses;
|
2013-02-27 15:12:36 +01:00
|
|
|
QString m_adb;
|
|
|
|
|
bool m_isBusyBox;
|
|
|
|
|
QStringList m_selector;
|
2012-04-18 20:30:57 +03:00
|
|
|
QMutex m_mutex;
|
2014-11-18 15:14:40 +01:00
|
|
|
DebugHandShakeType m_handShakeMethod;
|
|
|
|
|
QTcpSocket *m_socket;
|
|
|
|
|
bool m_customPort;
|
2012-04-18 20:30:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Android
|
|
|
|
|
|
|
|
|
|
#endif // ANDROIDRUNNER_H
|