mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-04 14:48:37 +00:00
完善日志输出
This commit is contained in:
parent
6e58137be9
commit
b3f584f9de
7 changed files with 48 additions and 20 deletions
|
@ -43,7 +43,6 @@ void AdbProcess::initSignals()
|
||||||
//P7C0218510000537 unauthorized ,手机端此时弹出调试认证,要允许调试
|
//P7C0218510000537 unauthorized ,手机端此时弹出调试认证,要允许调试
|
||||||
emit adbProcessResult(AER_ERROR_EXEC);
|
emit adbProcessResult(AER_ERROR_EXEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "adb return " << exitCode << "exit status " << exitStatus;
|
qDebug() << "adb return " << exitCode << "exit status " << exitStatus;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -60,14 +59,14 @@ void AdbProcess::initSignals()
|
||||||
|
|
||||||
connect(this, &QProcess::readyReadStandardError, this,
|
connect(this, &QProcess::readyReadStandardError, this,
|
||||||
[this](){
|
[this](){
|
||||||
m_errorOutput = QString::fromLocal8Bit(readAllStandardError()).trimmed();
|
m_errorOutput = QString::fromLocal8Bit(readAllStandardError()).trimmed();
|
||||||
qDebug() << "AdbProcess::error:" << m_errorOutput;
|
qWarning(QString("AdbProcess::error:%1").arg(m_errorOutput).toUtf8());
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &QProcess::readyReadStandardOutput, this,
|
connect(this, &QProcess::readyReadStandardOutput, this,
|
||||||
[this](){
|
[this](){
|
||||||
m_standardOutput = QString::fromLocal8Bit(readAllStandardOutput()).trimmed();
|
m_standardOutput = QString::fromLocal8Bit(readAllStandardOutput()).trimmed();
|
||||||
qDebug() << "AdbProcess::std out:" << m_standardOutput;
|
qInfo(QString("AdbProcess::out:%1").arg(m_standardOutput).toUtf8());
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &QProcess::started, this,
|
connect(this, &QProcess::started, this,
|
||||||
|
|
|
@ -15,18 +15,21 @@ Dialog::Dialog(QWidget *parent) :
|
||||||
|
|
||||||
connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
|
connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
|
||||||
QString log = "";
|
QString log = "";
|
||||||
|
bool newLine = true;
|
||||||
|
|
||||||
switch (processResult) {
|
switch (processResult) {
|
||||||
case AdbProcess::AER_SUCCESS_START:
|
case AdbProcess::AER_SUCCESS_START:
|
||||||
log = "adb run";
|
log = "adb run";
|
||||||
|
newLine = false;
|
||||||
break;
|
break;
|
||||||
case AdbProcess::AER_ERROR_EXEC:
|
case AdbProcess::AER_ERROR_EXEC:
|
||||||
log = m_adb.getErrorOut();
|
//log = m_adb.getErrorOut();
|
||||||
break;
|
break;
|
||||||
case AdbProcess::AER_ERROR_MISSING_BINARY:
|
case AdbProcess::AER_ERROR_MISSING_BINARY:
|
||||||
log = "adb not find";
|
log = "adb not find";
|
||||||
break;
|
break;
|
||||||
case AdbProcess::AER_SUCCESS_EXEC:
|
case AdbProcess::AER_SUCCESS_EXEC:
|
||||||
log = m_adb.getStdOut();
|
//log = m_adb.getStdOut();
|
||||||
QStringList args = m_adb.arguments();
|
QStringList args = m_adb.arguments();
|
||||||
if (args.contains("devices")) {
|
if (args.contains("devices")) {
|
||||||
QStringList devices = m_adb.getDevicesSerialFromStdOut();
|
QStringList devices = m_adb.getDevicesSerialFromStdOut();
|
||||||
|
@ -42,7 +45,7 @@ Dialog::Dialog(QWidget *parent) :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!log.isEmpty()) {
|
if (!log.isEmpty()) {
|
||||||
outLog(log);
|
outLog(log, newLine);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -58,7 +61,7 @@ void Dialog::on_updateDevice_clicked()
|
||||||
if (checkAdbRun()) {
|
if (checkAdbRun()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
outLog("update devices...");
|
outLog("update devices...", false);
|
||||||
m_adb.execute("", QStringList() << "devices");
|
m_adb.execute("", QStringList() << "devices");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +90,7 @@ void Dialog::on_wirelessConnectBtn_clicked()
|
||||||
addr += ":";
|
addr += ":";
|
||||||
addr += ui->devicePortEdt->text().trimmed();
|
addr += ui->devicePortEdt->text().trimmed();
|
||||||
}
|
}
|
||||||
outLog("wireless connect...");
|
outLog("wireless connect...", false);
|
||||||
QStringList adbArgs;
|
QStringList adbArgs;
|
||||||
adbArgs << "connect";
|
adbArgs << "connect";
|
||||||
adbArgs << addr;
|
adbArgs << addr;
|
||||||
|
@ -99,7 +102,7 @@ void Dialog::on_startAdbdBtn_clicked()
|
||||||
if (checkAdbRun()) {
|
if (checkAdbRun()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
outLog("start devices adbd...");
|
outLog("start devices adbd...", false);
|
||||||
// adb tcpip 5555
|
// adb tcpip 5555
|
||||||
QStringList adbArgs;
|
QStringList adbArgs;
|
||||||
adbArgs << "tcpip";
|
adbArgs << "tcpip";
|
||||||
|
@ -107,9 +110,12 @@ void Dialog::on_startAdbdBtn_clicked()
|
||||||
m_adb.execute(ui->serialEdt->text().trimmed(), adbArgs);
|
m_adb.execute(ui->serialEdt->text().trimmed(), adbArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::outLog(const QString &log)
|
void Dialog::outLog(const QString &log, bool newLine)
|
||||||
{
|
{
|
||||||
ui->outEdit->append(log);
|
ui->outEdit->append(log);
|
||||||
|
if (newLine) {
|
||||||
|
ui->outEdit->append("<br/>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Dialog::checkAdbRun()
|
bool Dialog::checkAdbRun()
|
||||||
|
@ -126,7 +132,7 @@ void Dialog::on_getIPBtn_clicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
outLog("get ip...");
|
outLog("get ip...", false);
|
||||||
// adb -s P7C0218510000537 shell ifconfig wlan0
|
// adb -s P7C0218510000537 shell ifconfig wlan0
|
||||||
// or
|
// or
|
||||||
// adb -s P7C0218510000537 shell ip -f inet addr show wlan0
|
// adb -s P7C0218510000537 shell ip -f inet addr show wlan0
|
||||||
|
|
|
@ -20,6 +20,8 @@ public:
|
||||||
explicit Dialog(QWidget *parent = 0);
|
explicit Dialog(QWidget *parent = 0);
|
||||||
~Dialog();
|
~Dialog();
|
||||||
|
|
||||||
|
void outLog(const QString& log, bool newLine = true);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_updateDevice_clicked();
|
void on_updateDevice_clicked();
|
||||||
|
|
||||||
|
@ -34,7 +36,6 @@ private slots:
|
||||||
void on_getIPBtn_clicked();
|
void on_getIPBtn_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void outLog(const QString& log);
|
|
||||||
bool checkAdbRun();
|
bool checkAdbRun();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>442</width>
|
<width>442</width>
|
||||||
<height>412</height>
|
<height>486</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
|
|
@ -6,12 +6,18 @@
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
|
|
||||||
|
Dialog* g_mainDlg = Q_NULLPTR;
|
||||||
|
|
||||||
|
QtMessageHandler g_oldMessageHandler = Q_NULLPTR;
|
||||||
|
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
//QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
|
//QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||||
//QApplication::setAttribute(Qt::AA_UseOpenGLES);
|
//QApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||||
//QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
//QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
||||||
|
|
||||||
|
g_oldMessageHandler = qInstallMessageHandler(myMessageOutput);
|
||||||
Decoder::init();
|
Decoder::init();
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
|
@ -30,11 +36,27 @@ int main(int argc, char *argv[])
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog* w = new Dialog;
|
g_mainDlg = new Dialog;
|
||||||
w->show();
|
g_mainDlg->show();
|
||||||
|
|
||||||
int ret = a.exec();
|
int ret = a.exec();
|
||||||
|
|
||||||
Decoder::deInit();
|
Decoder::deInit();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
|
{
|
||||||
|
if (g_oldMessageHandler) {
|
||||||
|
g_oldMessageHandler(type, context, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QtDebugMsg < type) {
|
||||||
|
if (g_mainDlg && !msg.contains("app_proces")) {
|
||||||
|
g_mainDlg->outLog(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (QtFatalMsg == type) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -368,7 +368,7 @@ void Server::onWorkProcessResult(AdbProcess::ADB_EXEC_RESULT processResult)
|
||||||
#endif
|
#endif
|
||||||
startServerByStep();
|
startServerByStep();
|
||||||
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
||||||
qCritical("adb push");
|
qCritical("adb push failed");
|
||||||
m_serverStartStep = SSS_NULL;
|
m_serverStartStep = SSS_NULL;
|
||||||
emit serverStartResult(false);
|
emit serverStartResult(false);
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ void Server::onWorkProcessResult(AdbProcess::ADB_EXEC_RESULT processResult)
|
||||||
m_serverStartStep = SSS_EXECUTE_SERVER;
|
m_serverStartStep = SSS_EXECUTE_SERVER;
|
||||||
startServerByStep();
|
startServerByStep();
|
||||||
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
||||||
qCritical("adb reverse");
|
qCritical("adb reverse failed");
|
||||||
m_tunnelForward = true;
|
m_tunnelForward = true;
|
||||||
m_serverStartStep = SSS_ENABLE_TUNNEL_FORWARD;
|
m_serverStartStep = SSS_ENABLE_TUNNEL_FORWARD;
|
||||||
startServerByStep();
|
startServerByStep();
|
||||||
|
@ -389,7 +389,7 @@ void Server::onWorkProcessResult(AdbProcess::ADB_EXEC_RESULT processResult)
|
||||||
m_serverStartStep = SSS_EXECUTE_SERVER;
|
m_serverStartStep = SSS_EXECUTE_SERVER;
|
||||||
startServerByStep();
|
startServerByStep();
|
||||||
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
||||||
qCritical("adb forward");
|
qCritical("adb forward failed");
|
||||||
m_serverStartStep = SSS_NULL;
|
m_serverStartStep = SSS_NULL;
|
||||||
emit serverStartResult(false);
|
emit serverStartResult(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
|
||||||
|
|
||||||
connect(m_server, &Server::serverStartResult, this, [this](bool success){
|
connect(m_server, &Server::serverStartResult, this, [this](bool success){
|
||||||
if (success) {
|
if (success) {
|
||||||
m_server->connectTo();
|
m_server->connectTo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue