Skip to content

Commit

Permalink
feat: support install flags
Browse files Browse the repository at this point in the history
支持安装标志
  • Loading branch information
mhduiy committed Dec 28, 2024
1 parent 156fe56 commit a0ffe14
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 9 deletions.
20 changes: 19 additions & 1 deletion src/cpp/adb/adbinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,28 @@ AppDetailInfo ADBInterface::getAppDetailInfo(const QString &deviceCode, const QS
}


bool ADBInterface::installApp(const QString &deviceCode, const QString &path)
bool ADBInterface::installApp(const QString &deviceCode, const QString &path,
bool r, bool s, bool d, bool g)
{
QStringList args;
args << "-s" << deviceCode << "install" << path;

if (r) {
args << "-r";
}

if (s) {
args << "-s";
}

if (d) {
args << "-d";
}

if (g) {
args << "-g";
}

m_adbTools->executeCommand(ADBTools::ADB, args, "", INT_MAX);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/adb/adbinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public slots:
QList<AppListInfo> getSoftListInfo(const QString &deviceCode);
AppDetailInfo getAppDetailInfo(const QString &deviceCode, const QString &packageName);

bool installApp(const QString &deviceCode, const QString &path); //安装软件
bool installApp(const QString &deviceCode, const QString &path, bool r, bool s, bool d, bool g); // 安装软件
bool clearData(const QString &deviceCode, const QString &packageName); //清除数据
bool unfreezeApp(const QString &deviceCode, const QString &packageName); //解冻软件
bool freezeApp(const QString &deviceCode, const QString &packageName); //冻结软件
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/appPageTool/appDetailControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ void AppDetailControl::updateInfo(const QString &packageName)
QMetaObject::invokeMethod(m_appHelper, "updateDetailInfo", Qt::QueuedConnection, Q_ARG(QString, packageName));
}

void AppDetailControl::installApp(const QString &path)
void AppDetailControl::installApp(const QString &path, bool r, bool s, bool d, bool g)
{
qWarning() << "main Thread" << QThread::currentThreadId();
QMetaObject::invokeMethod(m_appHelper, "installApp", Qt::QueuedConnection, Q_ARG(QString, path));
QMetaObject::invokeMethod(m_appHelper, "installApp", Qt::QueuedConnection, Q_ARG(QString, path), Q_ARG(bool, r), Q_ARG(bool, s), Q_ARG(bool, d), Q_ARG(bool, g));
}

void AppDetailControl::clearData(const QString &packageName)
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/appPageTool/appDetailControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AppDetailControl : public QObject
QVariant getAppId() {return m_info.appid;} ;

Q_INVOKABLE void updateInfo(const QString &packageName);
Q_INVOKABLE void installApp(const QString &Path);
Q_INVOKABLE void installApp(const QString &Path, bool r = false, bool s = false, bool d = false, bool g = false);
Q_INVOKABLE void clearData(const QString &packageName);
Q_INVOKABLE void uninstallApp(const QString &packageName);
Q_INVOKABLE void freezeApp(const QString &packageName);
Expand Down
5 changes: 3 additions & 2 deletions src/cpp/appPageTool/appHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AppHelper::AppHelper(QObject *parent)

}

void AppHelper::installApp(const QString &path)
void AppHelper::installApp(const QString &path, bool r, bool s, bool d, bool g)
{
const QString &deviceCode = ConnectManager::instance()->currentDeviceCode();
QString filePath;
Expand All @@ -26,8 +26,9 @@ void AppHelper::installApp(const QString &path)
if (!QFile::exists(filePath)) {
NotificationController::instance()->send("安装失败", "安装文件不合法", NotificationController::Error);
}

NotificationController::instance()->send("正在安装", "开始安装,请耐心等待");
ADBInterface::instance()->installApp(deviceCode, filePath);
ADBInterface::instance()->installApp(deviceCode, filePath, r, s, d, g);
NotificationController::instance()->send("安装成功", "安装执行完成");
emit requestUpdateSoftList();
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/appPageTool/appHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AppHelper : public QObject
explicit AppHelper(QObject *parent = nullptr);

public slots:
void installApp(const QString &Path);
void installApp(const QString &Path, bool r = false, bool s = false, bool d = false, bool g = false);
void clearData(const QString &packageName);
void uninstallApp(const QString &packageName);
void freezeApp(const QString &packageName);
Expand Down
9 changes: 8 additions & 1 deletion src/qml/pages/DeviceAppPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ ItemPage {
}

MWrapper {
id: installWrapper
property var flags: [false, false, false, false]
Layout.fillWidth: true
Layout.fillHeight: true
title: "安装软件到设备"
Expand All @@ -308,6 +310,11 @@ ItemPage {
}
MSwitchButton {
Layout.preferredWidth: 50
status: installWrapper.flags[index]

onStatusChanged: {
installWrapper.flags[index] = status
}
}
}
}
Expand All @@ -334,7 +341,7 @@ ItemPage {
text: "开始安装"
btnType: MButton.FBtnType.Suggest
onClicked: {
AppDetailControl.installApp(appPackagePathEdit.editItem.text);
AppDetailControl.installApp(appPackagePathEdit.editItem.text, installWrapper.flags[0], installWrapper.flags[1], installWrapper.flags[2], installWrapper.flags[3]);
}
}
}
Expand Down

0 comments on commit a0ffe14

Please sign in to comment.