@@ -190,27 +190,39 @@ void LockWorker::initConnections()
190190 const bool sleepLock = isSleepLock ();
191191#endif
192192 qCInfo (DDE_SHELL ) << " Lock screen when system wakes up: " << sleepLock << " , is visible:" << m_model->visible ();
193+
194+ FullScreenBackground::setContent (LockContent::instance ());
195+ m_model->setCurrentContentType (SessionBaseModel::LockContent);
196+
193197 if (isSleep) {
194- endAuthentication (m_account, AT_All);
195- destroyAuthentication (m_account);
196198 checkSystemWakeupTimer->start ();
197199 doSuspendTime = QDateTime::currentDateTime ();
198- } else {
199- // 非黑屏mode
200- m_model->setIsBlackMode (isSleep);
201-
202- // 如果待机唤醒后需要密码则创建验证
203- if (m_login1SessionSelf->active () && sleepLock)
204- createAuthentication (m_model->currentUser ()->name ());
205- }
206- if (!m_model->visible () && sleepLock) {
207- m_model->setIsBlackMode (isSleep);
208- m_model->setVisible (true );
209- }
200+ m_model->setIsBlackMode (true );
201+ // 休眠时按需拉起锁屏,注意此时是被动响应休眠
202+ if (sleepLock && m_login1SessionSelf->active ()) {
203+ // 仅sleepLock配置开启时执行
204+ m_model->setCurrentModeState (SessionBaseModel::ModeStatus::PasswordMode);
205+ setLocked (true );
206+ m_model->setVisible (true );
210207
211- if (!isSleep && !sleepLock) {
212- // 待机唤醒后检查是否需要密码,若不需要密码直接隐藏锁定界面
213- m_model->setVisible (false );
208+ qCInfo (DDE_SHELL ) << " locked for sleepLock config" ;
209+ }
210+ } else {
211+ SessionBaseModel::ModeStatus status = m_model->currentModeState ();
212+ if (isLocked () || (m_model->isNoPasswordLogin () && (status == SessionBaseModel::ModeStatus::PowerMode || status == SessionBaseModel::ModeStatus::PasswordMode))) {
213+ // 唤醒时如果处于lock状态,重置认证
214+ if (m_login1SessionSelf->active ()) {
215+ endAuthentication (m_account, AT_All);
216+ destroyAuthentication (m_account);
217+ createAuthentication (m_model->currentUser ()->name ());
218+ }
219+ } else {
220+ // 处理其他流程设置的可见状态
221+ m_model->setVisible (false );
222+ }
223+ // 避免在电源选项处理中设置密码模式,会导致唤醒后闪锁屏
224+ m_model->setCurrentModeState (SessionBaseModel::ModeStatus::PasswordMode);
225+ m_model->setIsBlackMode (false );
214226 }
215227 emit m_model->prepareForSleep (isSleep);
216228 });
@@ -286,40 +298,50 @@ void LockWorker::initConnections()
286298
287299void LockWorker::initData ()
288300{
289- /* com.deepin.daemon.Accounts */
290- m_model->updateUserList (m_accountsInter->userList ());
291- m_model->updateLoginedUserList (m_loginedInter->userList ());
292-
293- m_model->setUserlistVisible (valueByQSettings<bool >(" " , " userlist" , true ));
294- /* com.deepin.udcp.iam */
295- QDBusInterface ifc (DSS_DBUS ::udcpIamService, DSS_DBUS ::udcpIamPath, DSS_DBUS ::udcpIamService, QDBusConnection::systemBus (), this );
296- const bool allowShowCustomUser = (!m_model->userlistVisible ()) || valueByQSettings<bool >(" " , " loginPromptInput" , false ) ||
297- ifc.property (" Enable" ).toBool () || checkIsADDomain ();
298- m_model->setAllowShowCustomUser (allowShowCustomUser);
299-
300- /* init server user or custom user */
301- if (DSysInfo::deepinType () == DSysInfo::DeepinServer || m_model->allowShowCustomUser ()) {
302- std::shared_ptr<User> user (new User ());
303- m_model->setIsServerModel (DSysInfo::deepinType () == DSysInfo::DeepinServer);
304- m_model->addUser (user);
305- }
301+ auto list = m_accountsInter->userList ();
302+ if (!list.isEmpty ()) {
303+ /* com.deepin.daemon.Accounts */
304+ m_model->updateUserList (m_accountsInter->userList ());
305+ m_model->updateLoginedUserList (m_loginedInter->userList ());
306+
307+ m_model->setUserlistVisible (valueByQSettings<bool >(" " , " userlist" , true ));
308+ /* com.deepin.udcp.iam */
309+ QDBusInterface ifc (DSS_DBUS ::udcpIamService, DSS_DBUS ::udcpIamPath, DSS_DBUS ::udcpIamService, QDBusConnection::systemBus (), this );
310+ const bool allowShowCustomUser = (!m_model->userlistVisible ()) || valueByQSettings<bool >(" " , " loginPromptInput" , false ) ||
311+ ifc.property (" Enable" ).toBool () || checkIsADDomain ();
312+ m_model->setAllowShowCustomUser (allowShowCustomUser);
313+
314+ /* init server user or custom user */
315+ if (DSysInfo::deepinType () == DSysInfo::DeepinServer || m_model->allowShowCustomUser ()) {
316+ std::shared_ptr<User> user (new User ());
317+ m_model->setIsServerModel (DSysInfo::deepinType () == DSysInfo::DeepinServer);
318+ m_model->addUser (user);
319+ }
306320
307- /* com.deepin.dde.LockService */
308- std::shared_ptr<User> user_ptr = m_model->findUserByUid (getuid ());
309- if (user_ptr.get ()) {
310- m_model->updateCurrentUser (user_ptr);
311- const QString &userJson = m_lockInter->CurrentUser ();
312- QJsonParseError jsonParseError;
313- const QJsonDocument userDoc = QJsonDocument::fromJson (userJson.toUtf8 (), &jsonParseError);
314- if (jsonParseError.error != QJsonParseError::NoError || userDoc.isEmpty ()) {
315- qCWarning (DDE_SHELL ) << " Failed to obtain current user information from lock service!" ;
321+ /* com.deepin.dde.LockService */
322+ std::shared_ptr<User> user_ptr = m_model->findUserByUid (getuid ());
323+ if (user_ptr.get ()) {
324+ m_model->updateCurrentUser (user_ptr);
325+ const QString &userJson = m_lockInter->CurrentUser ();
326+ QJsonParseError jsonParseError;
327+ const QJsonDocument userDoc = QJsonDocument::fromJson (userJson.toUtf8 (), &jsonParseError);
328+ if (jsonParseError.error != QJsonParseError::NoError || userDoc.isEmpty ()) {
329+ qCWarning (DDE_SHELL ) << " Failed to obtain current user information from lock service!" ;
330+ } else {
331+ const QJsonObject userObj = userDoc.object ();
332+ m_model->currentUser ()->setLastAuthType (AUTH_TYPE_CAST (userObj[" AuthType" ].toInt ()));
333+ m_model->currentUser ()->setLastCustomAuth (userObj[" LastCustomAuth" ].toString ());
334+ }
316335 } else {
317- const QJsonObject userObj = userDoc.object ();
318- m_model->currentUser ()->setLastAuthType (AUTH_TYPE_CAST (userObj[" AuthType" ].toInt ()));
319- m_model->currentUser ()->setLastCustomAuth (userObj[" LastCustomAuth" ].toString ());
336+ m_model->updateCurrentUser (m_lockInter->CurrentUser ());
320337 }
321338 } else {
322- m_model->updateCurrentUser (m_lockInter->CurrentUser ());
339+ qCWarning (DDE_SHELL ) << " dbus com.deepin.daemon.Accounts userList is empty, use ..." ;
340+
341+ std::shared_ptr<User> user (new User ());
342+ m_model->addUser (user);
343+ m_model->updateCurrentUser (user);
344+ m_model->setAllowShowCustomUser (true );
323345 }
324346
325347 /* com.deepin.daemon.Authenticate */
@@ -343,6 +365,8 @@ void LockWorker::initConfiguration()
343365 m_model->setAllowShowUserSwitchButton (getDconfigValue (" switchUser" , Ondemand).toInt () == AuthInterface::Ondemand);
344366#endif
345367
368+ m_model->setGsCheckpwd (isCheckPwdBeforeRebootOrShut ());
369+
346370 checkPowerInfo ();
347371}
348372
@@ -490,7 +514,6 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action)
490514 case SessionBaseModel::PowerAction::RequireSuspend:
491515 {
492516 m_model->setIsBlackMode (true );
493- m_model->setCurrentModeState (SessionBaseModel::ModeStatus::PasswordMode);
494517
495518 int delayTime = 500 ;
496519#ifndef ENABLE_DSS_SNIPE
@@ -520,7 +543,6 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action)
520543 case SessionBaseModel::PowerAction::RequireHibernate:
521544 {
522545 m_model->setIsBlackMode (true );
523- m_model->setCurrentModeState (SessionBaseModel::ModeStatus::PasswordMode);
524546
525547 int delayTime = 500 ;
526548#ifndef ENABLE_DSS_SNIPE
@@ -549,42 +571,44 @@ void LockWorker::doPowerAction(const SessionBaseModel::PowerAction action)
549571 }
550572 }
551573 break ;
552- case SessionBaseModel::PowerAction::RequireRestart:
574+ case SessionBaseModel::PowerAction::RequireRestart: {
553575 m_model->setShutdownMode (true );
576+ auto gsCheckPwd = m_model->gsCheckpwd ();
577+ if (!isLocked () || m_model->currentModeState () == SessionBaseModel::ModeStatus::ShutDownMode || !gsCheckPwd) {
578+ m_sessionManagerInter->RequestReboot ();
579+ } else {
580+ createAuthentication (m_account);
581+ m_model->setCurrentModeState (SessionBaseModel::ModeStatus::ConfirmPasswordMode);
582+ }
554583
555- QTimer::singleShot (350 , this , [=] {
556- if (!isLocked () || m_model->currentModeState () == SessionBaseModel::ModeStatus::ShutDownMode || !isCheckPwdBeforeRebootOrShut ()) {
557- m_sessionManagerInter->RequestReboot ();
558- } else {
559- createAuthentication (m_account);
560- m_model->setCurrentModeState (SessionBaseModel::ModeStatus::ConfirmPasswordMode);
561- }
562-
563- if (m_model->visibleShutdownWhenRebootOrShutdown ()) {
564- return ;
565- }
584+ if (m_model->visibleShutdownWhenRebootOrShutdown ()) {
585+ return ;
586+ }
566587
588+ if (!gsCheckPwd)
567589 m_model->setVisible (false );
568- });
590+
569591 return ;
570- case SessionBaseModel::PowerAction::RequireShutdown:
592+ }
593+ case SessionBaseModel::PowerAction::RequireShutdown: {
571594 m_model->setShutdownMode (true );
595+ auto gsCheckPwd = m_model->gsCheckpwd ();
596+ if (!isLocked () || m_model->currentModeState () == SessionBaseModel::ModeStatus::ShutDownMode || !gsCheckPwd) {
597+ m_sessionManagerInter->RequestShutdown ();
598+ } else {
599+ createAuthentication (m_account);
600+ m_model->setCurrentModeState (SessionBaseModel::ModeStatus::ConfirmPasswordMode);
601+ }
572602
573- QTimer::singleShot (350 , this , [=] {
574- if (!isLocked () || m_model->currentModeState () == SessionBaseModel::ModeStatus::ShutDownMode || !isCheckPwdBeforeRebootOrShut ()) {
575- m_sessionManagerInter->RequestShutdown ();
576- } else {
577- createAuthentication (m_account);
578- m_model->setCurrentModeState (SessionBaseModel::ModeStatus::ConfirmPasswordMode);
579- }
580-
581- if (m_model->visibleShutdownWhenRebootOrShutdown ()) {
582- return ;
583- }
603+ if (m_model->visibleShutdownWhenRebootOrShutdown ()) {
604+ return ;
605+ }
584606
607+ if (!gsCheckPwd)
585608 m_model->setVisible (false );
586- });
609+
587610 return ;
611+ }
588612 case SessionBaseModel::PowerAction::RequireLock:
589613 m_model->setCurrentModeState (SessionBaseModel::ModeStatus::PasswordMode);
590614 createAuthentication (m_model->currentUser ()->name ());
0 commit comments