From c0015b4f63fb35248fecac7815da2c038f2b6e26 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Sun, 18 Nov 2018 13:02:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3adb=20devices=20crash?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QtScrcpy/adb/adbprocess.cpp | 8 ++++++++ QtScrcpy/adb/adbprocess.h | 1 + QtScrcpy/dialog.cpp | 12 ++++-------- QtScrcpy/dialog.h | 3 --- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/QtScrcpy/adb/adbprocess.cpp b/QtScrcpy/adb/adbprocess.cpp index ad95e5d..c37ac9a 100644 --- a/QtScrcpy/adb/adbprocess.cpp +++ b/QtScrcpy/adb/adbprocess.cpp @@ -97,6 +97,14 @@ bool AdbProcess::isRuning() } } +void AdbProcess::setShowTouchesEnabled(const QString &serial, bool enabled) +{ + QStringList adbArgs; + adbArgs << "shell" << "settings" << "put" << "system" << "show_touches"; + adbArgs << (enabled ? "1" : "0"); + execute(serial, adbArgs); +} + void AdbProcess::forward(const QString& serial, quint16 localPort, const QString& deviceSocketName) { QStringList adbArgs; diff --git a/QtScrcpy/adb/adbprocess.h b/QtScrcpy/adb/adbprocess.h index 0ea3e95..f891816 100644 --- a/QtScrcpy/adb/adbprocess.h +++ b/QtScrcpy/adb/adbprocess.h @@ -28,6 +28,7 @@ public: void install(const QString& serial, const QString& local); void removePath(const QString& serial, const QString& path); bool isRuning(); + void setShowTouchesEnabled(const QString& serial, bool enabled); static const QString& getAdbPath(); diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index 0697a39..0ebe23f 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -25,10 +25,12 @@ void Dialog::on_adbProcess_clicked() { AdbProcess* adb = new AdbProcess(); connect(adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){ - Q_UNUSED(processResult); - sender()->deleteLater(); + if (AdbProcess::AER_SUCCESS_START != processResult) { + sender()->deleteLater(); + } }); adb->execute("", QStringList() << "devices"); + //adb->setShowTouchesEnabled("P7C0218510000537", true); } void Dialog::on_startServerBtn_clicked() @@ -45,9 +47,3 @@ void Dialog::on_stopServerBtn_clicked() m_videoForm->close(); } } - -void Dialog::keyPressEvent(QKeyEvent *event) -{ - qDebug() << event->key(); - return QDialog::keyPressEvent(event); -} diff --git a/QtScrcpy/dialog.h b/QtScrcpy/dialog.h index b09a94f..d61f600 100644 --- a/QtScrcpy/dialog.h +++ b/QtScrcpy/dialog.h @@ -26,9 +26,6 @@ private slots: void on_stopServerBtn_clicked(); -protected: - void keyPressEvent(QKeyEvent *event); - private: Ui::Dialog *ui;