File tree 8 files changed +321
-0
lines changed
8 files changed +321
-0
lines changed Original file line number Diff line number Diff line change
1
+ # This file is used to ignore files which are generated
2
+ # ----------------------------------------------------------------------------
3
+
4
+ * ~
5
+ * .autosave
6
+ * .a
7
+ * .core
8
+ * .moc
9
+ * .o
10
+ * .obj
11
+ * .orig
12
+ * .rej
13
+ * .so
14
+ * .so. *
15
+ * _pch.h.cpp
16
+ * _resource.rc
17
+ * .qm
18
+ . # *
19
+ * . * #
20
+ core
21
+ ! core /
22
+ tags
23
+ .DS_Store
24
+ .directory
25
+ * .debug
26
+ Makefile *
27
+ * .prl
28
+ * .app
29
+ moc_ * .cpp
30
+ ui_ * .h
31
+ qrc_ * .cpp
32
+ Thumbs.db
33
+ * .res
34
+ * .rc
35
+ /.qmake.cache
36
+ /.qmake.stash
37
+ /build- *
38
+
39
+ # qtcreator generated files
40
+ * .pro.user *
41
+ CMakeLists.txt.user
42
+
43
+ # xemacs temporary files
44
+ * .flc
45
+
46
+ # Vim temporary files
47
+ . * .swp
48
+
49
+ # Visual Studio generated files
50
+ * .ib_pdb_index
51
+ * .idb
52
+ * .ilk
53
+ * .pdb
54
+ * .sln
55
+ * .suo
56
+ * .vcproj
57
+ * vcproj. * . * .user
58
+ * .ncb
59
+ * .sdf
60
+ * .opensdf
61
+ * .vcxproj
62
+ * vcxproj. *
63
+
64
+ # MinGW generated files
65
+ * .Debug
66
+ * .Release
67
+
68
+ # Python byte code
69
+ * .pyc
70
+
71
+ # Binaries
72
+ # --------
73
+ * .dll
74
+ * .exe
75
+
Original file line number Diff line number Diff line change
1
+ # -------------------------------------------------
2
+ #
3
+ # Project created by QtCreator 2019-05-06T12:13:40
4
+ #
5
+ # -------------------------------------------------
6
+
7
+ QT += core gui
8
+
9
+ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10
+
11
+ TARGET = DivvyDroid
12
+ TEMPLATE = app
13
+
14
+ # The following define makes your compiler emit warnings if you use
15
+ # any feature of Qt which has been marked as deprecated (the exact warnings
16
+ # depend on your compiler). Please consult the documentation of the
17
+ # deprecated API in order to know how to port your code away from it.
18
+ DEFINES += QT_DEPRECATED_WARNINGS
19
+
20
+ # You can also make your code fail to compile if you use deprecated APIs.
21
+ # In order to do so, uncomment the following line.
22
+ # You can also select to disable deprecated APIs only up to a certain version of Qt.
23
+ # DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
24
+
25
+ CONFIG += c++11
26
+
27
+ SOURCES += \
28
+ adbshell.cpp \
29
+ main.cpp \
30
+ mainwindow.cpp
31
+
32
+ HEADERS += \
33
+ adbshell.h \
34
+ mainwindow.h
35
+
36
+ FORMS += \
37
+ mainwindow.ui
38
+
39
+ # Default rules for deployment.
40
+ qnx: target.path = /tmp/ $${TARGET }/bin
41
+ else: unix :!android: target.path = /opt/ $${TARGET }/bin
42
+ !isEmpty (target.path ): INSTALLS += target
Original file line number Diff line number Diff line change
1
+ #include " adbshell.h"
2
+
3
+ #include < QDebug>
4
+
5
+ #define SHELL_RC_SEPARATOR " -!-!SHELL-RC!-!-"
6
+
7
+ AdbShell::AdbShell (QObject *parent)
8
+ : QProcess(parent)
9
+ {
10
+ connect (this , &AdbShell::stateChanged, [](ProcessState state){
11
+ qDebug () << " ADB SHELL state:" << state;
12
+ });
13
+
14
+ start (QStringLiteral (" adb" ), QStringList () << QStringLiteral (" shell" ) << QStringLiteral (" -T" ));
15
+ }
16
+
17
+ AdbShell::~AdbShell ()
18
+ {
19
+ waitForStarted ();
20
+ write (" exit\n " );
21
+ waitForFinished ();
22
+ }
23
+
24
+ AdbShell::Res
25
+ AdbShell::execute (QByteArray command)
26
+ {
27
+ waitForStarted ();
28
+ write (command);
29
+ write (" \n echo \" :$?" SHELL_RC_SEPARATOR " \"\n " );
30
+ waitForBytesWritten ();
31
+
32
+ AdbShell::Res res;
33
+ do {
34
+ waitForReadyRead ();
35
+ res.out .append (readAllStandardOutput ());
36
+ res.err .append (readAllStandardError ());
37
+ } while (!res.out .endsWith (SHELL_RC_SEPARATOR " \n " ));
38
+
39
+ int i = res.out .size () - sizeof (SHELL_RC_SEPARATOR);
40
+ while (i > 0 && res.out .at (i) != ' :' )
41
+ i--;
42
+ res.rc = res.out .mid (i + 1 ).toInt ();
43
+ res.out .truncate (i);
44
+ qDebug () << " SHELL " << command << " ; rc:" << res.rc ;
45
+
46
+ return res;
47
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef ADBSHELL_H
2
+ #define ADBSHELL_H
3
+
4
+ #include < QProcess>
5
+
6
+ class AdbShell : public QProcess
7
+ {
8
+ public:
9
+ struct Res {
10
+ int rc;
11
+ QByteArray out;
12
+ QByteArray err;
13
+ };
14
+
15
+ AdbShell (QObject *parent = nullptr );
16
+ virtual ~AdbShell ();
17
+
18
+ Res execute (QByteArray command);
19
+ };
20
+
21
+ #endif // ADBSHELL_H
Original file line number Diff line number Diff line change
1
+ #include " mainwindow.h"
2
+ #include < QApplication>
3
+
4
+ int main (int argc, char *argv[])
5
+ {
6
+ QApplication a (argc, argv);
7
+ MainWindow w;
8
+ w.show ();
9
+
10
+ return a.exec ();
11
+ }
Original file line number Diff line number Diff line change
1
+ #include " mainwindow.h"
2
+ #include " ui_mainwindow.h"
3
+
4
+ #include < QElapsedTimer>
5
+ #include < QDebug>
6
+
7
+ MainWindow::MainWindow (QWidget *parent)
8
+ : QMainWindow(parent),
9
+ ui(new Ui::MainWindow),
10
+ m_screenTimer(this ),
11
+ m_shell(this )
12
+ {
13
+ ui->setupUi (this );
14
+
15
+ connect (&m_screenTimer, &QTimer::timeout, [&](){
16
+ QElapsedTimer timer;
17
+ timer.start ();
18
+ AdbShell::Res res = m_shell.execute (" /system/bin/screencap -j" );
19
+ qDebug () << " SCREEN frame retrieved in" << timer.elapsed () << " ms" ;
20
+ QImage img (QImage::fromData (res.out ).scaledToWidth (360 , Qt::SmoothTransformation));
21
+ ui->screen ->setPixmap (QPixmap::fromImage (img));
22
+ });
23
+ m_screenTimer.start (40 );
24
+ }
25
+
26
+ MainWindow::~MainWindow ()
27
+ {
28
+ delete ui;
29
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef MAINWINDOW_H
2
+ #define MAINWINDOW_H
3
+
4
+ #include < QMainWindow>
5
+ #include < QTimer>
6
+ #include " adbshell.h"
7
+
8
+
9
+ namespace Ui {
10
+ class MainWindow ;
11
+ }
12
+
13
+ class MainWindow : public QMainWindow
14
+ {
15
+ Q_OBJECT
16
+
17
+ public:
18
+ explicit MainWindow (QWidget *parent = nullptr );
19
+ ~MainWindow ();
20
+
21
+ private:
22
+ Ui::MainWindow *ui;
23
+
24
+ QTimer m_screenTimer;
25
+ AdbShell m_shell;
26
+ };
27
+
28
+ #endif // MAINWINDOW_H
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <ui version =" 4.0" >
3
+ <class >MainWindow</class >
4
+ <widget class =" QMainWindow" name =" MainWindow" >
5
+ <property name =" geometry" >
6
+ <rect >
7
+ <x >0</x >
8
+ <y >0</y >
9
+ <width >320</width >
10
+ <height >480</height >
11
+ </rect >
12
+ </property >
13
+ <property name =" windowTitle" >
14
+ <string notr =" true" >DivvyDroid</string >
15
+ </property >
16
+ <widget class =" QWidget" name =" centralWidget" >
17
+ <layout class =" QVBoxLayout" name =" verticalLayout" >
18
+ <property name =" spacing" >
19
+ <number >0</number >
20
+ </property >
21
+ <property name =" leftMargin" >
22
+ <number >0</number >
23
+ </property >
24
+ <property name =" topMargin" >
25
+ <number >0</number >
26
+ </property >
27
+ <property name =" rightMargin" >
28
+ <number >0</number >
29
+ </property >
30
+ <property name =" bottomMargin" >
31
+ <number >0</number >
32
+ </property >
33
+ <item >
34
+ <widget class =" QLabel" name =" screen" >
35
+ <property name =" scaledContents" >
36
+ <bool >false</bool >
37
+ </property >
38
+ <property name =" alignment" >
39
+ <set >Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set >
40
+ </property >
41
+ </widget >
42
+ </item >
43
+ </layout >
44
+ </widget >
45
+ <widget class =" QMenuBar" name =" menuBar" >
46
+ <property name =" geometry" >
47
+ <rect >
48
+ <x >0</x >
49
+ <y >0</y >
50
+ <width >320</width >
51
+ <height >30</height >
52
+ </rect >
53
+ </property >
54
+ </widget >
55
+ <widget class =" QToolBar" name =" mainToolBar" >
56
+ <attribute name =" toolBarArea" >
57
+ <enum >TopToolBarArea</enum >
58
+ </attribute >
59
+ <attribute name =" toolBarBreak" >
60
+ <bool >false</bool >
61
+ </attribute >
62
+ </widget >
63
+ <widget class =" QStatusBar" name =" statusBar" />
64
+ </widget >
65
+ <layoutdefault spacing =" 6" margin =" 11" />
66
+ <resources />
67
+ <connections />
68
+ </ui >
You can’t perform that action at this time.
0 commit comments