Skip to content

Commit 8dc116e

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 8dc116e

6 files changed

Lines changed: 137 additions & 3 deletions

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ UpdateModel::UpdateModel(QObject* parent)
4646
, m_updateDisabledIcon("")
4747
, m_updateDisabledTips("")
4848
, m_batterIsOK(false)
49+
, m_isWayland(false)
50+
, m_postUpdateCheckCompleted(true) // 非 Wayland 默认为 true,Wayland 下检查完成后再置为 true
4951
, m_lastStatus(Default)
5052
, m_showCheckUpdate(false)
5153
, m_checkUpdateIcon("")
@@ -222,6 +224,26 @@ void UpdateModel::setBatterIsOK(bool ok)
222224
Q_EMIT batterIsOKChanged(ok);
223225
}
224226

227+
void UpdateModel::setIsWayland(bool isWayland)
228+
{
229+
if (m_isWayland == isWayland) {
230+
return;
231+
}
232+
233+
m_isWayland = isWayland;
234+
Q_EMIT isWaylandChanged(isWayland);
235+
}
236+
237+
void UpdateModel::setPostUpdateCheckCompleted(bool completed)
238+
{
239+
if (m_postUpdateCheckCompleted == completed) {
240+
return;
241+
}
242+
243+
m_postUpdateCheckCompleted = completed;
244+
Q_EMIT postUpdateCheckCompletedChanged(completed);
245+
}
246+
225247
void UpdateModel::setForceUpdateText(const QString& updateTime, int lastoreStatus)
226248
{
227249
if (!updateTime.isEmpty()) {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class UpdateModel : public QObject
3131
Q_PROPERTY(int lastStatus READ lastStatus NOTIFY lastStatusChanged FINAL)
3232
Q_PROPERTY(bool isUpdatable READ isUpdatable NOTIFY isUpdatableChanged FINAL)
3333
Q_PROPERTY(bool isPrivateUpdate READ isPrivateUpdate NOTIFY isPrivateUpdateChanged FINAL)
34+
Q_PROPERTY(bool isWayland READ isWayland WRITE setIsWayland NOTIFY isWaylandChanged FINAL)
3435

3536
// ---------------检查更新页面数据---------------
3637
Q_PROPERTY(bool showCheckUpdate READ showCheckUpdate NOTIFY showCheckUpdateChanged FINAL)
@@ -100,6 +101,7 @@ class UpdateModel : public QObject
100101
Q_PROPERTY(bool upgradeDeliveryEnable READ upgradeDeliveryEnable NOTIFY upgradeDeliveryEnableChanged FINAL)
101102
Q_PROPERTY(bool p2pUpdateEnabled READ isP2PUpdateEnabled NOTIFY p2pUpdateEnableStateChanged FINAL)
102103
Q_PROPERTY(bool forceUpdate READ forceUpdate NOTIFY forceUpdateChanged FINAL)
104+
Q_PROPERTY(bool postUpdateCheckCompleted READ postUpdateCheckCompleted NOTIFY postUpdateCheckCompletedChanged FINAL)
103105
Q_PROPERTY(UpdateHistoryModel *historyModel READ historyModel NOTIFY historyModelChanged FINAL)
104106

105107

@@ -261,6 +263,12 @@ class UpdateModel : public QObject
261263
bool isPrivateUpdate() const { return m_isPrivateUpdate; }
262264
void setIsPrivateUpdate(bool isPrivateUpdate);
263265

266+
bool isWayland() const { return m_isWayland; }
267+
void setIsWayland(bool isWayland);
268+
269+
bool postUpdateCheckCompleted() const { return m_postUpdateCheckCompleted; }
270+
void setPostUpdateCheckCompleted(bool completed);
271+
264272
UpdatesStatus updateStatus(ControlPanelType type) const;
265273
UpdatesStatus updateStatus(UpdateType type) const;
266274
QList<UpdateType> updateTypesList(ControlPanelType type) const;
@@ -419,6 +427,8 @@ public slots:
419427
void updateInfoChanged(UpdateType);
420428
void isUpdatableChanged(const bool isUpdatablePackages);
421429
void isPrivateUpdateChanged(const bool isPrivateUpdate);
430+
void isWaylandChanged(bool isWayland);
431+
void postUpdateCheckCompletedChanged(bool completed);
422432
void updateStatusChanged(ControlPanelType, UpdatesStatus);
423433
void controlTypeChanged();
424434
void lastErrorChanged(UpdatesStatus, UpdateErrorType);
@@ -457,6 +467,8 @@ public slots:
457467
QString m_updateDisabledIcon;
458468
QString m_updateDisabledTips;
459469
bool m_batterIsOK;
470+
bool m_isWayland;
471+
bool m_postUpdateCheckCompleted;
460472
int m_lastStatus;
461473
bool m_immutableAutoRecovery;
462474

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

Lines changed: 87 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()) {
@@ -230,6 +234,7 @@ void UpdateWorker::activate()
230234

231235
initConfig();
232236
getLicenseState();
237+
setIsWayland();
233238
onPowerChange();
234239
updateSystemVersion();
235240
refreshLastTimeAndCheckCircle();
@@ -295,6 +300,14 @@ void UpdateWorker::activate()
295300
});
296301
}
297302

303+
void UpdateWorker::setIsWayland()
304+
{
305+
m_model->setIsWayland(DGuiApplicationHelper::testAttribute(DGuiApplicationHelper::IsWaylandPlatform));
306+
if (m_model->isWayland()) {
307+
m_model->setPostUpdateCheckCompleted(false);
308+
}
309+
}
310+
298311
void UpdateWorker::initConfig()
299312
{
300313
qCDebug(logDccUpdatePlugin) << "Initialize lastore daemon configuration";
@@ -774,6 +787,8 @@ void UpdateWorker::doUpgrade(int updateTypes, bool doBackup)
774787
cleanLaStoreJob(m_distUpgradeJob);
775788
cleanLaStoreJob(m_backupJob);
776789

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

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

Lines changed: 8 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();
@@ -154,6 +157,7 @@ public Q_SLOTS:
154157
QMutex m_downloadMutex;
155158

156159
QString calculateRequiredSpaceText(int updateTypes, const QString &originalText);
160+
void setIsWayland();
157161

158162
bool m_doCheckUpdates;
159163
QPointer<UpdateJobDBusProxy> m_checkUpdateJob;
@@ -163,6 +167,10 @@ public Q_SLOTS:
163167
QPointer<UpdateJobDBusProxy> m_backupJob;
164168
QPointer<UpdateJobDBusProxy> m_installPackageJob;
165169
QPointer<UpdateJobDBusProxy> m_removePackageJob;
170+
QPointer<UpdateJobDBusProxy> m_checkSystemJob;
171+
172+
int m_updateMode;
173+
int m_currentCheckStage; // 当前 check system 阶段: 1=CSS_BeforeLogin, 2=CSS_AfterLogin
166174
};
167175

168176
#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 (dccData.model().isWayland) {
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)