diff options
| author | 2015-11-25 16:48:41 -0500 | |
|---|---|---|
| committer | 2015-11-25 16:48:41 -0500 | |
| commit | 8e640722c62692818ab840d50b3758f89a41a54e (patch) | |
| tree | 38197eb1688a5afc338081ea17e15f938976e422 /Plugins/DbAndroid/adbmanager.h | |
| parent | 9618f0ebbf4b88045247c01ce8c8f58203508ebf (diff) | |
Imported Upstream version 3.0.7upstream/3.0.7
Diffstat (limited to 'Plugins/DbAndroid/adbmanager.h')
| -rw-r--r-- | Plugins/DbAndroid/adbmanager.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Plugins/DbAndroid/adbmanager.h b/Plugins/DbAndroid/adbmanager.h new file mode 100644 index 0000000..adeca90 --- /dev/null +++ b/Plugins/DbAndroid/adbmanager.h @@ -0,0 +1,65 @@ +#ifndef ADBMANAGER_H +#define ADBMANAGER_H + +#include <QObject> +#include <QProcess> +#include <QtConcurrent/QtConcurrent> + +class DbAndroid; +class QTimer; + +class AdbManager : public QObject +{ + Q_OBJECT + public: + struct Device + { + QString id; + QString fullName; + }; + + AdbManager(DbAndroid* plugin); + ~AdbManager(); + + const QStringList& getDevices(bool forceSyncUpdate = false); + Device getDetails(const QString& deviceId); + QList<Device> getDeviceDetails(); + QHash<QString,QPair<int,int>> getForwards(); + int makeForwardFor(const QString& device, int targetPort); + QString findAdb(); + bool testCurrentAdb(); + bool testAdb(const QString& adbPath, bool quiet = false); + bool execBytes(const QStringList& arguments, QByteArray* stdOut = nullptr, QByteArray* stdErr = nullptr); + bool exec(const QStringList& arguments, QString* stdOut = nullptr, QString* stdErr = nullptr); + + static QByteArray encode(const QString& input); + static QString decode(const QByteArray& input); + + private: + bool execLongCommand(const QStringList& arguments, QProcess& proc, QByteArray* stdErr); + bool waitForProc(QProcess& proc, bool quiet = false); + bool ensureAdbRunning(); + QStringList getDevicesInternal(bool emitSignal); + void syncDeviceListUpdate(); + void updateDetails(const QStringList& devices); + + DbAndroid* plugin; + QTimer* adbRunMonitor = nullptr; + QStringList currentDeviceList; + QHash<QString,Device> currentDeviceDetails; + QFuture<QStringList> updateDevicesFuture; + + private slots: + void updateDeviceList(); + void handleNewDeviceList(const QStringList& devices); + void handleNewDetails(const QList<Device>& devices); + + signals: + void internalDeviceListUpdate(const QStringList& devices); + void deviceListChanged(const QStringList& devices); + void deviceDetailsChanged(const QList<Device>& details); +}; + +Q_DECLARE_METATYPE(QList<AdbManager::Device>) + +#endif // ADBMANAGER_H |
