summaryrefslogtreecommitdiff
path: root/gui/androidutils.h
blob: 44f6c156c3de3a17f9846815bccf35a7f26d4df4 (plain)
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
66
67
68
69
70
71
72
73
#ifndef ANDROIDUTILS_H
#define ANDROIDUTILS_H

#include <QList>
#include <QObject>
#include <QString>

class QByteArray;
class QStringList;


struct AndroidDeviceInfo
{
    QString serialNumber;
    enum State { OkState, UnAuthorizedState, OfflineState };
    State state;
    bool unauthorized;
    enum AndroidDeviceType { Hardware, Emulator };
    AndroidDeviceType type;

    static QStringList adbSelector(const QString &serialNumber);
    static QString adbPath();
};

class AndroidUtils : public QObject
{
    Q_OBJECT
public:
    struct FileInfo
    {
        FileInfo();

        enum Type {
            File,
            Directory
        };
        Type type;
        QString name;
        qint64 size;
    };

    typedef QList<FileInfo>  FileInfoList;

    enum UpdateType {
        PushLocalToDevice,
        PullFromDeviceToLocal
    };

public:
    AndroidUtils();

    void reloadAdb();

    QString serialNumber() const;

    bool runAdb(const QStringList &params, QByteArray *output = 0) const;
    FileInfoList ls(const QString &path) const;

    bool sameFile(const QString &localPath, const QString &devicePath);
    bool updateFile(const QString &localPath, const QString &devicePath, UpdateType updateType);

signals:
    void statusMessage(const QString &message);

private slots:
    void processReadyRead();

private:
    QString m_adbPath;
    mutable qint64 m_wait;
    mutable QString m_serialNumber;
};
#endif // ANDROIDUTILS_H