blob: adeca90ddc696f4d6ccf83a996202a537beafb0a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
|