Skip to content

Commit f1bd3aa

Browse files
committed
feat: [Update Delivery] Merge update delivery related functionality into Control Center update client
Integrate the update delivery logic from v20 into the v25 Control Center update module: Add an update delivery master switch in the Control Center update advanced settings interface. When the switch is enabled, the interface displays two sub-items: Update Delivery - Upload Speed Limit and Update Delivery - Download Speed Limit. Each sub-item has its own control switch and speed limit input field. Simultaneously, call the relevant SetP2pEnable interface of lastore-daemon, which will attempt to start the upgrade-delivery system service during the next update check of lastore. The switches and input fields for Update Delivery - Upload Speed Limit and Update Delivery - Download Speed Limit independently control the enabling/disabling of upload/download speed limits and their specific values. These values are set by calling the SetDeliveryUploadSpeedLimit and SetDeliveryDownloadSpeedLimit interfaces of lastore-daemon, which are then applied by lastore. The update delivery speed limit configuration supports backend-driven busy/idle time speed limit policies via the update platform. When such policies are active, the Control Center will gray out the Update Delivery - Upload Speed Limit and Update Delivery - Download Speed Limit sub-items accordingly, preventing user modifications. Each operation on the master switch triggers a refresh of the status values for various sub-items. The status values are read from the upgrade-delivery service. Log: Integrate v20 update delivery functionality into v25 Task: https://pms.uniontech.com/task-view-387713.html Influence: New update delivery logic added to the Control Center update module feat: 【更新传递】控制中心更新客户端合入更新传递相关功能 v20的更新传递逻辑合入v25控制中心更新模块 1.添加更新传递总开关在控制中心更新高级设置界面。当开关打开时,界面展示更新传递-上传限速、更新传递-下载限速两个子项,每个子项有各自的控制开关和限速值输入框,同时调用lastore-daemon的SetP2pEnable相关接口,在lastore的下次检查更新时尝试拉起upgrade-delivery系统服务 2.更新传递-上传限速、更新传递-下载限速两个子项的开关和输入框各自控制上传、下载限速的开启和关闭以及具体数值,具体通过调用lastore-daemon的SetDeliveryUploadSpeedLimit和SetDeliveryDownloadSpeedLimit接口交由lastore来实际设置值。 3.更新传递的限速配置支持通过更新平台后端下发忙闲时的限速策略,此时控制中心会根据这一策略适时置灰更新传递-上传限速、更新传递-下载限速两个子项,禁止用户修改 4.每次操作总开关时会适时的刷新各种子项的状态值,具体是从upgrade-delivery服务中读取对应的属性值 Log: v20更新传递功能合入v25 Task: https://pms.uniontech.com/task-view-387713.html Influence: 控制中心更新模块新增更新传递逻辑
1 parent 80a07bc commit f1bd3aa

19 files changed

Lines changed: 859 additions & 157 deletions
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
#include "updateassistant.h"
5+
6+
UpdateAssistant::UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
7+
: QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
8+
, d_ptr(new UpdateAssistantPrivate)
9+
{
10+
QDBusConnection::systemBus().connect("org.deepin.upgradedelivery", "/org/deepin/upgradedelivery", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onPropertyChanged(QString, QVariantMap, QStringList)));
11+
}
12+
13+
UpdateAssistant::~UpdateAssistant()
14+
{
15+
}
16+
17+
void UpdateAssistant::onPropertyChanged(const QString& interfaceName,
18+
const QVariantMap& changedProperties,
19+
const QStringList& invalidatedProperties)
20+
{
21+
if (interfaceName != staticInterfaceName())
22+
return;
23+
24+
if (changedProperties.contains("UploadLimitSpeed")) {
25+
Q_EMIT UploadLimitSpeedChanged(uploadLimitSpeed());
26+
}
27+
if (changedProperties.contains("DownloadLimitSpeed")) {
28+
Q_EMIT DownloadLimitSpeedChanged(downloadLimitSpeed());
29+
}
30+
31+
return;
32+
}
33+
34+
void UpdateAssistant::CallQueued(const QString &callName, const QList<QVariant> &args)
35+
{
36+
if (d_ptr->m_waittingCalls.contains(callName)) {
37+
d_ptr->m_waittingCalls[callName] = args;
38+
return;
39+
}
40+
if (d_ptr->m_processingCalls.contains(callName)) {
41+
d_ptr->m_waittingCalls.insert(callName, args);
42+
} else {
43+
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args));
44+
connect(watcher, &QDBusPendingCallWatcher::finished, this, &UpdateAssistant::onPendingCallFinished);
45+
d_ptr->m_processingCalls.insert(callName, watcher);
46+
}
47+
}
48+
49+
void UpdateAssistant::onPendingCallFinished(QDBusPendingCallWatcher *w)
50+
{
51+
if (!w)
52+
return;
53+
w->deleteLater();
54+
const auto callName = d_ptr->m_processingCalls.key(w);
55+
Q_ASSERT(!callName.isEmpty());
56+
if (callName.isEmpty())
57+
return;
58+
d_ptr->m_processingCalls.remove(callName);
59+
if (!d_ptr->m_waittingCalls.contains(callName))
60+
return;
61+
const auto args = d_ptr->m_waittingCalls.take(callName);
62+
CallQueued(callName, args);
63+
}

src/common/dbus/updateassistant.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
2+
//
3+
// SPDX-License-Identifier: GPL-3.0-or-later
4+
#ifndef UPDATEASSISTANT_H
5+
#define UPDATEASSISTANT_H
6+
7+
#include <QtCore/QObject>
8+
#include <QtCore/QByteArray>
9+
#include <QtCore/QList>
10+
#include <QtCore/QMap>
11+
#include <QtCore/QString>
12+
#include <QtCore/QStringList>
13+
#include <QtCore/QVariant>
14+
#include <QtDBus/QtDBus>
15+
16+
//#include "module/updatedatastructs.h"
17+
18+
#define TRANSIMISSION_MAX_SPEED 102400
19+
#define TRANSIMISSION_MIN_SPEED 0
20+
#define TRANSIMISSION_SERVICE_ENABLED 1
21+
22+
class UpdateAssistantPrivate
23+
{
24+
public:
25+
UpdateAssistantPrivate() = default;
26+
27+
public:
28+
QMap<QString, QDBusPendingCallWatcher *> m_processingCalls;
29+
QMap<QString, QList<QVariant>> m_waittingCalls;
30+
};
31+
32+
/*
33+
* Proxy class for interface org.deepin.updateassistant
34+
*/
35+
class UpdateAssistant: public QDBusAbstractInterface
36+
{
37+
Q_OBJECT
38+
public:
39+
static inline const char *staticInterfaceName()
40+
{ return "org.deepin.upgradedelivery"; }
41+
42+
public:
43+
UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);
44+
45+
~UpdateAssistant();
46+
47+
Q_PROPERTY(QString UploadLimitSpeed READ uploadLimitSpeed NOTIFY UploadLimitSpeedChanged)
48+
inline QString uploadLimitSpeed() const
49+
{ return qvariant_cast<QString>(internalPropGet("UploadLimitSpeed")); }
50+
51+
Q_PROPERTY(QString DownloadLimitSpeed READ downloadLimitSpeed NOTIFY DownloadLimitSpeedChanged)
52+
inline QString downloadLimitSpeed() const
53+
{ return qvariant_cast<QString>(internalPropGet("DownloadLimitSpeed")); }
54+
55+
public Q_SLOTS: // METHODS
56+
57+
inline QDBusPendingReply<void> SetUploadRateLimit(int speed)
58+
{
59+
QList<QVariant> argumentList;
60+
argumentList << QVariant::fromValue(speed);
61+
return asyncCallWithArgumentList(QStringLiteral("SetUploadRateLimit"), argumentList);
62+
}
63+
64+
inline QDBusPendingReply<void> SetDownloadRateLimit(int speed)
65+
{
66+
QList<QVariant> argumentList;
67+
argumentList << QVariant::fromValue(speed);
68+
return asyncCallWithArgumentList(QStringLiteral("SetDownloadRateLimit"), argumentList);
69+
}
70+
71+
Q_SIGNALS: // SIGNALS
72+
// begin property changed signals
73+
void propertyChanged(const QString &propertyName, const QVariant &value);
74+
void UploadLimitSpeedChanged(const QString & speed) const;
75+
void DownloadLimitSpeedChanged(const QString & speed) const;
76+
77+
public Q_SLOTS:
78+
void CallQueued(const QString &callName, const QList<QVariant> &args);
79+
80+
private Q_SLOTS:
81+
void onPendingCallFinished(QDBusPendingCallWatcher *w);
82+
void onPropertyChanged(const QString& interfaceName,
83+
const QVariantMap& changedProperties,
84+
const QStringList& invalidatedProperties);
85+
86+
private:
87+
UpdateAssistantPrivate *d_ptr;
88+
};
89+
90+
#endif // UPDATEASSISTANT_H

src/common/dbus/updatedbusproxy.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ QString UpdateDBusProxy::updateStatus()
207207
return qvariant_cast<QString>(m_managerInter->property("UpdateStatus"));
208208
}
209209

210+
bool UpdateDBusProxy::p2PUpdateEnable()
211+
{
212+
return qvariant_cast<bool>(m_managerInter->property("P2PUpdateEnable"));
213+
}
214+
215+
bool UpdateDBusProxy::p2PUpdateSupport()
216+
{
217+
return qvariant_cast<bool>(m_managerInter->property("P2PUpdateSupport"));
218+
}
219+
210220
bool UpdateDBusProxy::immutableAutoRecovery()
211221
{
212222
return qvariant_cast<bool>(m_managerInter->property("ImmutableAutoRecovery"));
@@ -387,6 +397,36 @@ QDBusPendingReply<QString> UpdateDBusProxy::GetUpdateLogs(int updateType)
387397
return m_managerInter->asyncCallWithArgumentList(QStringLiteral("GetUpdateLogs"), argumentList);
388398
}
389399

400+
QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryEnable(bool enable)
401+
{
402+
qCDebug(logCommon) << "Setting upgrade delivery enable :" << enable;
403+
QList<QVariant> argumentList;
404+
argumentList << QVariant::fromValue(enable);
405+
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetP2PUpdateEnable"), argumentList);
406+
}
407+
408+
QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit)
409+
{
410+
qCDebug(logCommon) << "Setting upgrade delivery download speed limit : " << downloadLimit;
411+
QList<QVariant> argumentList;
412+
argumentList << QVariant::fromValue(downloadLimit);
413+
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryDownloadSpeedLimit"), argumentList);
414+
}
415+
416+
QDBusPendingReply<void> UpdateDBusProxy::SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit)
417+
{
418+
qCDebug(logCommon) << "Setting upgrade delivery upload speed limit : " << uploadLimit;
419+
QList<QVariant> argumentList;
420+
argumentList << QVariant::fromValue(uploadLimit);
421+
return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryUploadSpeedLimit"), argumentList);
422+
}
423+
424+
QDBusPendingReply<void> UpdateDBusProxy::ClearUpgradeDeliveryCache()
425+
{
426+
qCDebug(logCommon) << "Clearing upgrade delivery cache";
427+
return m_updateInter->asyncCall(QStringLiteral("CleanTransmissionFiles"));
428+
}
429+
390430
QDBusPendingReply<void> UpdateDBusProxy::SetIdleDownloadConfig(const QString& config)
391431
{
392432
qCDebug(logCommon) << "Setting idle download config:" << config;

src/common/dbus/updatedbusproxy.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class UpdateDBusProxy : public QObject
7070
Q_PROPERTY(bool ImmutableAutoRecovery READ immutableAutoRecovery NOTIFY ImmutableAutoRecoveryChanged)
7171
bool immutableAutoRecovery();
7272

73+
Q_PROPERTY(bool P2PUpdateEnable READ p2PUpdateEnable NOTIFY P2PUpdateEnableChanged)
74+
bool p2PUpdateEnable();
75+
76+
Q_PROPERTY(bool P2PUpdateSupport READ p2PUpdateSupport NOTIFY P2PUpdateSupportChanged)
77+
bool p2PUpdateSupport();
78+
7379
QString hardwareId();
7480

7581
quint64 checkUpdateMode();
@@ -103,6 +109,10 @@ class UpdateDBusProxy : public QObject
103109
QDBusPendingReply<void> SetDownloadSpeedLimit(const QString &config);
104110
QDBusPendingReply<qlonglong> QueryAllSizeWithSource(int updateType);
105111
QDBusPendingReply<QString> GetUpdateLogs(int updateType);
112+
QDBusPendingReply<void> SetUpgradeDeliveryEnable(bool enable);
113+
QDBusPendingReply<void> SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit);
114+
QDBusPendingReply<void> SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit);
115+
QDBusPendingReply<void> ClearUpgradeDeliveryCache();
106116
QDBusPendingReply<void> SetIdleDownloadConfig(const QString &config);
107117
QDBusPendingReply<QDBusObjectPath> PrepareDistUpgradePartly(int updateMode);
108118
QDBusPendingReply<QDBusObjectPath> fixError(const QString &errorType);
@@ -137,6 +147,7 @@ class UpdateDBusProxy : public QObject
137147
void AutoInstallUpdatesChanged(bool value) const;
138148
void AutoInstallUpdateTypeChanged(qulonglong value) const;
139149
void MirrorSourceChanged(const QString &value) const;
150+
void UpgradeDeliveryEnabledChanged(bool value) const;
140151
void AutoCheckUpdatesChanged(bool value) const;
141152
void ClassifiedUpdatablePackagesChanged(LastoreUpdatePackagesInfo value) const;
142153

@@ -146,6 +157,8 @@ class UpdateDBusProxy : public QObject
146157
void UpdateModeChanged(qulonglong value) const;
147158
void UpdateStatusChanged(QString value) const;
148159
void ImmutableAutoRecoveryChanged(bool value) const;
160+
void P2PUpdateEnableChanged(bool value) const;
161+
void P2PUpdateSupportChanged(bool value) const;
149162
void managerInterServiceValidChanged(bool value) const;
150163

151164
// Power

0 commit comments

Comments
 (0)