Skip to content

Commit d35c822

Browse files
committed
feat: add post-upgrade check for Wayland in treeland environment
1. Add `isWayland` and `postUpdateCheckCompleted` properties to UpdateModel with QML bindings 2. Implement `doCheckSystemOnWayland` in UpdateWorker to perform staged system check (CSS_BeforeLogin → CSS_AfterLogin) after upgrade completion 3. Update desktop autostart entry to skip dde-update process under Wayland, preventing restart issues 4. Modify QML UI to show busy state during post-update check and bypass backup dialog for Wayland 5. This solves the issue where dde-update fails to start after system restart in treeland environment, ensuring system integrity via staged verification Log: Added post-upgrade system check feature for Wayland to ensure proper system functionality after updates Influence: 1. Test upgrade on X11 environment to verify no regression (postUpdateCheckCompleted remains true) 2. Test upgrade on treeland/Wayland environment to verify staged check runs correctly 3. Verify busy indicator shows during check and hides after completion 4. Test upgrade failure scenario to ensure check completes even on error 5. Verify dde-update autostart is disabled under Wayland 6. Test multiple consecutive upgrades to ensure check state resets properly feat: 为 Wayland 环境(treeland)添加更新后系统检查功能 1. 为 UpdateModel 添加 isWayland 和 postUpdateCheckCompleted 属性及 QML 绑定 2. 在 UpdateWorker 中实现 doCheckSystemOnWayland 方法,在更新完成后分阶 段执行系统检查(CSS_BeforeLogin → CSS_AfterLogin) 3. 更新桌面自动启动条目,在 Wayland 环境下跳过 dde-update 进程,避免重启 问题 4. 修改 QML UI 在更新后检查期间显示繁忙状态,并在 Wayland 下跳过备份对 话框 5. 解决 treeland 环境下系统重启后 dde-update 无法启动的问题,通过分阶段 验证确保系统完整性 Log: 新增 Wayland 环境下的更新后系统检查功能,确保系统正常运行 Influence: 1. 测试 X11 环境下的升级功能,确认无回归(postUpdateCheckCompleted 保持 为 true) 2. 测试 treeland/Wayland 环境下的升级功能,确认分阶段检查正确执行 3. 验证检查期间显示繁忙指示器,完成后隐藏 4. 测试升级失败场景,确保即使出错检查也能完成 5. 验证 Wayland 下 dde-update 自动启动被禁用 6. 测试多次连续升级,确保检查状态正确重置 PMS: BUG-347525 BUG-347529 Change-Id: I832f7c7c55dd13158d13f0c3d25478030a39999c
1 parent 09dd4a3 commit d35c822

6 files changed

Lines changed: 113 additions & 3 deletions

File tree

src/dcc-update-plugin/operation/updatemodel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ UpdateModel::UpdateModel(QObject* parent)
4646
, m_updateDisabledIcon("")
4747
, m_updateDisabledTips("")
4848
, m_batterIsOK(false)
49+
, m_postUpdateCheckCompleted(true) // 非 Wayland 默认为 true,Wayland 下检查完成后再置为 true
4950
, m_lastStatus(Default)
5051
, m_showCheckUpdate(false)
5152
, m_checkUpdateIcon("")
@@ -222,6 +223,16 @@ void UpdateModel::setBatterIsOK(bool ok)
222223
Q_EMIT batterIsOKChanged(ok);
223224
}
224225

226+
void UpdateModel::setPostUpdateCheckCompleted(bool completed)
227+
{
228+
if (m_postUpdateCheckCompleted == completed) {
229+
return;
230+
}
231+
232+
m_postUpdateCheckCompleted = completed;
233+
Q_EMIT postUpdateCheckCompletedChanged(completed);
234+
}
235+
225236
void UpdateModel::setForceUpdateText(const QString& updateTime, int lastoreStatus)
226237
{
227238
if (!updateTime.isEmpty()) {

src/dcc-update-plugin/operation/updatemodel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class UpdateModel : public QObject
100100
Q_PROPERTY(bool upgradeDeliveryEnable READ upgradeDeliveryEnable NOTIFY upgradeDeliveryEnableChanged FINAL)
101101
Q_PROPERTY(bool p2pUpdateEnabled READ isP2PUpdateEnabled NOTIFY p2pUpdateEnableStateChanged FINAL)
102102
Q_PROPERTY(bool forceUpdate READ forceUpdate NOTIFY forceUpdateChanged FINAL)
103+
Q_PROPERTY(bool postUpdateCheckCompleted READ postUpdateCheckCompleted NOTIFY postUpdateCheckCompletedChanged FINAL)
103104
Q_PROPERTY(UpdateHistoryModel *historyModel READ historyModel NOTIFY historyModelChanged FINAL)
104105

105106

@@ -261,6 +262,9 @@ class UpdateModel : public QObject
261262
bool isPrivateUpdate() const { return m_isPrivateUpdate; }
262263
void setIsPrivateUpdate(bool isPrivateUpdate);
263264

265+
bool postUpdateCheckCompleted() const { return m_postUpdateCheckCompleted; }
266+
void setPostUpdateCheckCompleted(bool completed);
267+
264268
UpdatesStatus updateStatus(ControlPanelType type) const;
265269
UpdatesStatus updateStatus(UpdateType type) const;
266270
QList<UpdateType> updateTypesList(ControlPanelType type) const;
@@ -419,6 +423,7 @@ public slots:
419423
void updateInfoChanged(UpdateType);
420424
void isUpdatableChanged(const bool isUpdatablePackages);
421425
void isPrivateUpdateChanged(const bool isPrivateUpdate);
426+
void postUpdateCheckCompletedChanged(bool completed);
422427
void updateStatusChanged(ControlPanelType, UpdatesStatus);
423428
void controlTypeChanged();
424429
void lastErrorChanged(UpdatesStatus, UpdateErrorType);
@@ -457,6 +462,7 @@ public slots:
457462
QString m_updateDisabledIcon;
458463
QString m_updateDisabledTips;
459464
bool m_batterIsOK;
465+
bool m_postUpdateCheckCompleted;
460466
int m_lastStatus;
461467
bool m_immutableAutoRecovery;
462468

src/dcc-update-plugin/operation/updatework.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ UpdateWorker::UpdateWorker(UpdateModel* model, QObject* parent)
132132
, m_backupJob(nullptr)
133133
, m_installPackageJob(nullptr)
134134
, m_removePackageJob(nullptr)
135+
, m_checkSystemJob(nullptr)
136+
, m_updateMode(0)
137+
, m_currentCheckStage(0)
135138
{
136139
qCDebug(logDccUpdatePlugin) << "Initializing UpdateWorker";
137140
qRegisterMetaType<UpdatesStatus>("UpdatesStatus");
@@ -151,6 +154,7 @@ UpdateWorker::~UpdateWorker()
151154
deleteJob(m_backupJob);
152155
deleteJob(m_installPackageJob);
153156
deleteJob(m_removePackageJob);
157+
deleteJob(m_checkSystemJob);
154158

155159
if (m_lastoreHeartBeatTimer != nullptr) {
156160
if (m_lastoreHeartBeatTimer->isActive()) {
@@ -774,6 +778,11 @@ void UpdateWorker::doUpgrade(int updateTypes, bool doBackup)
774778
cleanLaStoreJob(m_distUpgradeJob);
775779
cleanLaStoreJob(m_backupJob);
776780

781+
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
782+
m_updateMode = updateTypes;
783+
m_model->setPostUpdateCheckCompleted(false);
784+
}
785+
777786
QDBusPendingCall call = m_updateInter->DistUpgradePartly(updateTypes, doBackup);
778787
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(call, this);
779788
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, updateTypes, watcher, doBackup] {
@@ -1711,6 +1720,13 @@ void UpdateWorker::onDistUpgradeStatusChanged(const QString& status)
17111720
if (updateStatus == UpgradeComplete) {
17121721
cleanLaStoreJob(m_distUpgradeJob);
17131722
updateSystemVersion();
1723+
1724+
// TODO: treeland 环境下重启后无法启动 dde-update 进程, 这里直接在安装更新完成后,进行检查:
1725+
// 串行执行: CheckUpgrade(stage=1, CSS_BeforeLogin) → CheckUpgrade(stage=2, CSS_AfterLogin) → 标记完成
1726+
if (DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform)) {
1727+
doCheckSystemOnWayland(1);
1728+
}
1729+
17141730
} else {
17151731
if (updateStatus == UpgradeFailed && m_distUpgradeJob) {
17161732
const QString& description = m_distUpgradeJob->description();
@@ -1858,3 +1874,68 @@ void UpdateWorker::cleanUpgradeDeliveryCache()
18581874
}
18591875
});
18601876
}
1877+
1878+
void UpdateWorker::doCheckSystemOnWayland(int stage)
1879+
{
1880+
qCInfo(logDccUpdatePlugin) << "treeland: start check system, stage:" << stage;
1881+
m_currentCheckStage = stage;
1882+
1883+
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(m_updateInter->CheckUpgrade(m_updateMode, stage), this);
1884+
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher] {
1885+
QDBusPendingReply<QDBusObjectPath> reply = *watcher;
1886+
if (reply.isError()) {
1887+
qCWarning(logDccUpdatePlugin) << "CheckUpgrade stage" << m_currentCheckStage
1888+
<< "failed:" << reply.error().message();
1889+
// 即使检查失败也标记完成,不阻塞后续流程
1890+
m_model->setPostUpdateCheckCompleted(true);
1891+
} else {
1892+
const QString jobPath = reply.value().path();
1893+
qCInfo(logDccUpdatePlugin) << "Check system job created:" << jobPath << "stage:" << m_currentCheckStage;
1894+
setCheckSystemJob(jobPath);
1895+
}
1896+
watcher->deleteLater();
1897+
});
1898+
}
1899+
1900+
void UpdateWorker::setCheckSystemJob(const QString& jobPath)
1901+
{
1902+
qCInfo(logDccUpdatePlugin) << "Create check system job, path:" << jobPath;
1903+
if (m_checkSystemJob || jobPath.isEmpty()) {
1904+
qCWarning(logDccUpdatePlugin) << "Check system job already exists or path is empty";
1905+
m_model->setPostUpdateCheckCompleted(true);
1906+
return;
1907+
}
1908+
1909+
m_checkSystemJob = new UpdateJobDBusProxy(jobPath, this);
1910+
connect(m_checkSystemJob, &UpdateJobDBusProxy::StatusChanged, this, &UpdateWorker::onCheckSystemJobStatusChanged);
1911+
// 主动触发一次状态同步,避免 job 在连接信号前已完成
1912+
onCheckSystemJobStatusChanged(m_checkSystemJob->status());
1913+
}
1914+
1915+
void UpdateWorker::onCheckSystemJobStatusChanged(const QString& status)
1916+
{
1917+
qCInfo(logDccUpdatePlugin) << "Check system job status changed, stage:" << m_currentCheckStage << "status:" << status;
1918+
1919+
// 仅关注终态:failed / succeed / end
1920+
if (status == "failed" || status == "succeed" || status == "end") {
1921+
cleanLaStoreJob(m_checkSystemJob);
1922+
1923+
if (m_currentCheckStage == 1) {
1924+
if (status == "failed") {
1925+
qCWarning(logDccUpdatePlugin) << "CheckUpgrade stage CSS_BeforeLogin failed, cannot continue to CSS_AfterLogin";
1926+
m_model->setPostUpdateCheckCompleted(true);
1927+
return;
1928+
} else if (status == "end") {
1929+
// CSS_BeforeLogin 阶段完成,继续 CSS_AfterLogin 阶段
1930+
qCInfo(logDccUpdatePlugin) << "treeland: CSS_BeforeLogin completed, starting CSS_AfterLogin";
1931+
QTimer::singleShot(1000, this, [this] {
1932+
doCheckSystemOnWayland(2);
1933+
});
1934+
}
1935+
} else {
1936+
// CSS_AfterLogin 阶段完成,标记检查完成
1937+
qCInfo(logDccUpdatePlugin) << "treeland: CSS_AfterLogin completed, mark check completed";
1938+
m_model->setPostUpdateCheckCompleted(true);
1939+
}
1940+
}
1941+
}

src/dcc-update-plugin/operation/updatework.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class UpdateWorker : public QObject
5959
Q_INVOKABLE void setShutdownAndUpgrade(bool isShutdownUpdate = false);
6060
void setBackupJob(const QString& jobPath);
6161
void setDistUpgradeJob(const QString& jobPath);
62+
void doCheckSystemOnWayland(int stage);
63+
void setCheckSystemJob(const QString& jobPath);
6264
void updateSystemVersion();
6365

6466
// 更新设置-更新类型
@@ -133,6 +135,7 @@ public Q_SLOTS:
133135
void onDistUpgradeStatusChanged(const QString& status);
134136
void onInstallPackageStatusChanged(const QString& value);
135137
void onRemovePackageStatusChanged(const QString& value);
138+
void onCheckSystemJobStatusChanged(const QString& status);
136139

137140
Q_SIGNALS:
138141
void requestCloseTestingChannel();
@@ -163,6 +166,10 @@ public Q_SLOTS:
163166
QPointer<UpdateJobDBusProxy> m_backupJob;
164167
QPointer<UpdateJobDBusProxy> m_installPackageJob;
165168
QPointer<UpdateJobDBusProxy> m_removePackageJob;
169+
QPointer<UpdateJobDBusProxy> m_checkSystemJob;
170+
171+
int m_updateMode;
172+
int m_currentCheckStage; // 当前 check system 阶段: 1=CSS_BeforeLogin, 2=CSS_AfterLogin
166173
};
167174

168175
#endif // UPDATEWORK_H

src/dcc-update-plugin/qml/UpdateMain.qml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ DccObject {
199199
updateTips: qsTr("To ensure proper functioning of your system and applications, please restart your computer after the update")
200200
btnActions: [ qsTr("Reboot now") ]
201201
updateListcheck: false
202+
busyState: !dccData.model().postUpdateCheckCompleted
202203

203204
onBtnClicked: function(index, updateType) {
204205
dccData.work().reStart()
@@ -318,8 +319,12 @@ DccObject {
318319
if (dccData.model().isPrivateUpdate) {
319320
dccData.work().doUpgrade(updateListModels.getAllUpdateType(), true)
320321
} else {
321-
updateSelectLoader.updateType = updateType
322-
updateSelectLoader.active = true
322+
if (DccApp.isTreeland()) {
323+
dccData.work().doUpgrade(updateType, true)
324+
} else {
325+
updateSelectLoader.updateType = updateType
326+
updateSelectLoader.active = true
327+
}
323328
}
324329
} else if (index === 1) {
325330
dccData.work().reCheckWithUi();

src/dde-update/misc/dde-update-autostart.desktop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
Name=dde-update
33
Type=Application
44
NoDisplay=true
5-
Exec=sh -c 'if [ -f /tmp/deepin_update_option.json ]; then /usr/bin/dde-update ; fi'
5+
Exec=sh -c 'if [ -f /tmp/deepin_update_option.json ] && [ "$XDG_SESSION_TYPE" != "wayland" ]; then /usr/bin/dde-update ; fi'
66
X-Deepin-Vendor=deepin

0 commit comments

Comments
 (0)