parent
7ec3f5d7c6
commit
131340dc02
@ -0,0 +1,45 @@
|
|||||||
|
#include "filehandler.h"
|
||||||
|
|
||||||
|
#define DEVICE_SDCARD_PATH "/sdcard/"
|
||||||
|
|
||||||
|
FileHandler::FileHandler(QObject *parent)
|
||||||
|
: QObject (parent)
|
||||||
|
{
|
||||||
|
connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
|
||||||
|
switch (processResult) {
|
||||||
|
case AdbProcess::AER_ERROR_START:
|
||||||
|
case AdbProcess::AER_ERROR_EXEC:
|
||||||
|
case AdbProcess::AER_ERROR_MISSING_BINARY:
|
||||||
|
emit fileHandlerResult(FAR_ERROR_EXEC);
|
||||||
|
break;
|
||||||
|
case AdbProcess::AER_SUCCESS_EXEC:
|
||||||
|
emit fileHandlerResult(FAR_SUCCESS_EXEC);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
FileHandler::~FileHandler()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileHandler::pushFileRequest(const QString &serial, const QString &file)
|
||||||
|
{
|
||||||
|
if (m_adb.isRuning()) {
|
||||||
|
emit fileHandlerResult(FAR_IS_RUNNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_adb.push(serial, file, DEVICE_SDCARD_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileHandler::installApkRequest(const QString &serial, const QString &apkFile)
|
||||||
|
{
|
||||||
|
if (m_adb.isRuning()) {
|
||||||
|
emit fileHandlerResult(FAR_IS_RUNNING);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_adb.install(serial, apkFile);
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef FILEHANDLER_H
|
||||||
|
#define FILEHANDLER_H
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "adbprocess.h"
|
||||||
|
|
||||||
|
class FileHandler : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum FILE_HANDLER_RESULT {
|
||||||
|
FAR_IS_RUNNING, // 正在执行
|
||||||
|
FAR_SUCCESS_EXEC, // 执行成功
|
||||||
|
FAR_ERROR_EXEC, // 执行失败
|
||||||
|
};
|
||||||
|
|
||||||
|
FileHandler(QObject *parent = nullptr);
|
||||||
|
virtual ~FileHandler();
|
||||||
|
|
||||||
|
void pushFileRequest(const QString& serial, const QString& file);
|
||||||
|
void installApkRequest(const QString& serial, const QString& apkFile);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fileHandlerResult(FILE_HANDLER_RESULT processResult);
|
||||||
|
|
||||||
|
private:
|
||||||
|
AdbProcess m_adb;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FILEHANDLER_H
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
HEADERS += \
|
||||||
|
$$PWD/filehandler.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/filehandler.cpp
|
||||||
Loading…
Reference in new issue