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