1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "session_manager_lite.h"
17 #include <ipc_skeleton.h>
18 #include <iremote_stub.h>
19 #include <iservice_registry.h>
20 #include <system_ability_definition.h>
21
22 #include "session_manager_service_recover_interface.h"
23 #include "scene_session_manager_lite_proxy.h"
24 #include "window_manager_hilog.h"
25
26 namespace OHOS::Rosen {
27 namespace {
28 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionManagerLite" };
29 }
30
31 class SessionManagerServiceLiteRecoverListener : public IRemoteStub<ISessionManagerServiceRecoverListener> {
32 public:
33 SessionManagerServiceLiteRecoverListener() = default;
34
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)35 int32_t OnRemoteRequest(
36 uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override
37 {
38 if (data.ReadInterfaceToken() != GetDescriptor()) {
39 TLOGE(WmsLogTag::WMS_RECOVER, "InterfaceToken check failed");
40 return ERR_TRANSACTION_FAILED;
41 }
42 auto msgId = static_cast<SessionManagerServiceRecoverMessage>(code);
43 switch (msgId) {
44 case SessionManagerServiceRecoverMessage::TRANS_ID_ON_SESSION_MANAGER_SERVICE_RECOVER: {
45 auto sessionManagerService = data.ReadRemoteObject();
46 // Even if sessionManagerService is null, the recovery process is still required.
47 OnSessionManagerServiceRecover(sessionManagerService);
48 break;
49 }
50 case SessionManagerServiceRecoverMessage::TRANS_ID_ON_WMS_CONNECTION_CHANGED: {
51 int32_t userId = INVALID_USER_ID;
52 int32_t screenId = DEFAULT_SCREEN_ID;
53 bool isConnected = false;
54 if (!data.ReadInt32(userId) || !data.ReadInt32(screenId) || !data.ReadBool(isConnected)) {
55 TLOGE(WmsLogTag::WMS_MULTI_USER, "Read data failed in lite!");
56 return ERR_TRANSACTION_FAILED;
57 }
58 if (isConnected) {
59 // Even if data.ReadRemoteObject() is null, the WMS connection still needs to be notified.
60 OnWMSConnectionChanged(userId, screenId, isConnected, data.ReadRemoteObject());
61 } else {
62 OnWMSConnectionChanged(userId, screenId, isConnected, nullptr);
63 }
64 break;
65 }
66 default:
67 TLOGW(WmsLogTag::WMS_RECOVER, "unknown transaction code %{public}d", code);
68 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
69 }
70 return ERR_NONE;
71 }
72
OnSessionManagerServiceRecover(const sptr<IRemoteObject> & sessionManagerService)73 void OnSessionManagerServiceRecover(const sptr<IRemoteObject>& sessionManagerService) override
74 {
75 SessionManagerLite::GetInstance().Clear();
76 SessionManagerLite::GetInstance().ClearSessionManagerProxy();
77
78 auto sms = iface_cast<ISessionManagerService>(sessionManagerService);
79 SessionManagerLite::GetInstance().RecoverSessionManagerService(sms);
80 }
81
OnWMSConnectionChanged(int32_t userId,int32_t screenId,bool isConnected,const sptr<IRemoteObject> & sessionManagerService)82 void OnWMSConnectionChanged(
83 int32_t userId, int32_t screenId, bool isConnected, const sptr<IRemoteObject>& sessionManagerService) override
84 {
85 auto sms = iface_cast<ISessionManagerService>(sessionManagerService);
86 SessionManagerLite::GetInstance().OnWMSConnectionChanged(userId, screenId, isConnected, sms);
87 }
88 };
89
90 class SceneSessionManagerLiteProxyMock : public SceneSessionManagerLiteProxy {
91 public:
SceneSessionManagerLiteProxyMock(const sptr<IRemoteObject> & impl)92 explicit SceneSessionManagerLiteProxyMock(const sptr<IRemoteObject>& impl)
93 : SceneSessionManagerLiteProxy(impl) {}
94 virtual ~SceneSessionManagerLiteProxyMock() = default;
95
RegisterSessionListener(const sptr<ISessionListener> & listener,bool isRecover=false)96 WSError RegisterSessionListener(const sptr<ISessionListener>& listener, bool isRecover = false) override
97 {
98 TLOGI(WmsLogTag::DEFAULT, "called");
99 auto ret = SceneSessionManagerLiteProxy::RegisterSessionListener(listener);
100 if (ret != WSError::WS_OK) {
101 return ret;
102 }
103 if (isRecover) {
104 TLOGI(WmsLogTag::DEFAULT, "Recover mode, no need to save listener");
105 return WSError::WS_OK;
106 }
107 SessionManagerLite::GetInstance().SaveSessionListener(listener);
108 return WSError::WS_OK;
109 }
UnRegisterSessionListener(const sptr<ISessionListener> & listener)110 WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) override
111 {
112 TLOGI(WmsLogTag::DEFAULT, "called");
113 auto ret = SceneSessionManagerLiteProxy::UnRegisterSessionListener(listener);
114 SessionManagerLite::GetInstance().DeleteSessionListener(listener);
115 return ret;
116 }
117
118 private:
119 static inline BrokerDelegator<SceneSessionManagerLiteProxyMock> delegator_;
120 };
121
WM_IMPLEMENT_SINGLE_INSTANCE(SessionManagerLite)122 WM_IMPLEMENT_SINGLE_INSTANCE(SessionManagerLite)
123
124 SessionManagerLite::~SessionManagerLite()
125 {
126 sptr<IRemoteObject> remoteObject = nullptr;
127 if (mockSessionManagerServiceProxy_) {
128 remoteObject = mockSessionManagerServiceProxy_->AsObject();
129 }
130 if (remoteObject) {
131 remoteObject->RemoveDeathRecipient(foundationDeath_);
132 }
133 TLOGI(WmsLogTag::WMS_LIFE, "destroyed");
134 }
135
ClearSessionManagerProxy()136 void SessionManagerLite::ClearSessionManagerProxy()
137 {
138 WLOGFI("enter");
139 std::lock_guard<std::recursive_mutex> lock(mutex_);
140 sessionManagerServiceProxy_ = nullptr;
141 sceneSessionManagerLiteProxy_ = nullptr;
142 screenSessionManagerLiteProxy_ = nullptr;
143 }
144
GetSceneSessionManagerLiteProxy()145 sptr<ISceneSessionManagerLite> SessionManagerLite::GetSceneSessionManagerLiteProxy()
146 {
147 std::lock_guard<std::recursive_mutex> lock(mutex_);
148 InitSessionManagerServiceProxy();
149 InitSceneSessionManagerLiteProxy();
150 return sceneSessionManagerLiteProxy_;
151 }
152
GetScreenSessionManagerLiteProxy()153 sptr<IScreenSessionManagerLite> SessionManagerLite::GetScreenSessionManagerLiteProxy()
154 {
155 std::lock_guard<std::recursive_mutex> lock(mutex_);
156 InitSessionManagerServiceProxy();
157 InitScreenSessionManagerLiteProxy();
158 return screenSessionManagerLiteProxy_;
159 }
160
GetSessionManagerServiceProxy()161 sptr<ISessionManagerService> SessionManagerLite::GetSessionManagerServiceProxy()
162 {
163 std::lock_guard<std::recursive_mutex> lock(mutex_);
164 InitSessionManagerServiceProxy();
165 InitSceneSessionManagerLiteProxy();
166 return sessionManagerServiceProxy_;
167 }
168
SaveSessionListener(const sptr<ISessionListener> & listener)169 void SessionManagerLite::SaveSessionListener(const sptr<ISessionListener>& listener)
170 {
171 if (listener == nullptr) {
172 TLOGW(WmsLogTag::DEFAULT, "listener is nullptr");
173 return;
174 }
175 std::lock_guard<std::recursive_mutex> guard(listenerLock_);
176 auto it = std::find_if(sessionListeners_.begin(), sessionListeners_.end(),
177 [&listener](const sptr<ISessionListener>& item) {
178 return (item && item->AsObject() == listener->AsObject());
179 });
180 if (it != sessionListeners_.end()) {
181 TLOGW(WmsLogTag::DEFAULT, "listener was already added");
182 return;
183 }
184 sessionListeners_.emplace_back(listener);
185 }
186
DeleteSessionListener(const sptr<ISessionListener> & listener)187 void SessionManagerLite::DeleteSessionListener(const sptr<ISessionListener>& listener)
188 {
189 TLOGI(WmsLogTag::DEFAULT, "called");
190 std::lock_guard<std::recursive_mutex> guard(listenerLock_);
191 auto it = std::find_if(sessionListeners_.begin(), sessionListeners_.end(),
192 [&listener](const sptr<ISessionListener>& item) {
193 return (item && item->AsObject() == listener->AsObject());
194 });
195 if (it != sessionListeners_.end()) {
196 sessionListeners_.erase(it);
197 }
198 }
199
DeleteAllSessionListeners()200 void SessionManagerLite::DeleteAllSessionListeners()
201 {
202 std::lock_guard<std::recursive_mutex> guard(listenerLock_);
203 sessionListeners_.clear();
204 }
205
RecoverSessionManagerService(const sptr<ISessionManagerService> & sessionManagerService)206 void SessionManagerLite::RecoverSessionManagerService(const sptr<ISessionManagerService>& sessionManagerService)
207 {
208 {
209 std::lock_guard<std::recursive_mutex> lock(mutex_);
210 sessionManagerServiceProxy_ = sessionManagerService;
211 }
212 GetSceneSessionManagerLiteProxy();
213 ReregisterSessionListener();
214 if (userSwitchCallbackFunc_) {
215 TLOGI(WmsLogTag::WMS_RECOVER, "user switch");
216 userSwitchCallbackFunc_();
217 }
218 }
219
ReregisterSessionListener()220 void SessionManagerLite::ReregisterSessionListener()
221 {
222 sptr<ISceneSessionManagerLite> sceneSessionManagerLiteProxy = nullptr;
223 {
224 std::lock_guard<std::recursive_mutex> lock(mutex_);
225 sceneSessionManagerLiteProxy = sceneSessionManagerLiteProxy_;
226 }
227 if (sceneSessionManagerLiteProxy == nullptr) {
228 TLOGE(WmsLogTag::WMS_RECOVER, "sceneSessionManagerLiteProxy is null");
229 return;
230 }
231
232 std::lock_guard<std::recursive_mutex> guard(listenerLock_);
233 TLOGI(WmsLogTag::WMS_RECOVER, "listener count=%{public}" PRIu64,
234 static_cast<int64_t>(sessionListeners_.size()));
235 for (const auto& listener : sessionListeners_) {
236 auto ret = sceneSessionManagerLiteProxy->RegisterSessionListener(listener, true);
237 if (ret != WSError::WS_OK) {
238 TLOGW(WmsLogTag::WMS_RECOVER, "failed, ret=%{public}" PRId32, ret);
239 }
240 }
241 }
242
RegisterUserSwitchListener(const UserSwitchCallbackFunc & callbackFunc)243 void SessionManagerLite::RegisterUserSwitchListener(const UserSwitchCallbackFunc& callbackFunc)
244 {
245 TLOGD(WmsLogTag::WMS_MULTI_USER, "enter");
246 userSwitchCallbackFunc_ = callbackFunc;
247 }
248
OnWMSConnectionChanged(int32_t userId,int32_t screenId,bool isConnected,const sptr<ISessionManagerService> & sessionManagerService)249 void SessionManagerLite::OnWMSConnectionChanged(
250 int32_t userId, int32_t screenId, bool isConnected, const sptr<ISessionManagerService>& sessionManagerService)
251 {
252 bool isCallbackRegistered = false;
253 int32_t lastUserId = INVALID_USER_ID;
254 int32_t lastScreenId = DEFAULT_SCREEN_ID;
255 {
256 // The mutex ensures the timing of the following variable states in multiple threads
257 std::lock_guard<std::mutex> lock(wmsConnectionMutex_);
258 lastUserId = currentWMSUserId_;
259 lastScreenId = currentScreenId_;
260 isCallbackRegistered = wmsConnectionChangedFunc_ != nullptr;
261 if (isConnected) {
262 currentWMSUserId_ = userId;
263 currentScreenId_ = screenId;
264 }
265 // isWMSConnected_ only represents the wms connection status of the active user
266 if (currentWMSUserId_ == userId) {
267 isWMSConnected_ = isConnected;
268 }
269 }
270 TLOGD(WmsLogTag::WMS_MULTI_USER,
271 "Lite: curUserId=%{public}d, oldUserId=%{public}d, screenId=%{public}d, isConnected=%{public}d",
272 userId, lastUserId, screenId, isConnected);
273 if (isConnected && lastUserId > INVALID_USER_ID && lastUserId != userId) {
274 // Notify the user that the old wms has been disconnected.
275 OnWMSConnectionChangedCallback(lastUserId, lastScreenId, false, isCallbackRegistered);
276 OnUserSwitch(sessionManagerService);
277 }
278 // Notify the user that the current wms connection has changed.
279 OnWMSConnectionChangedCallback(userId, screenId, isConnected, isCallbackRegistered);
280 }
281
OnUserSwitch(const sptr<ISessionManagerService> & sessionManagerService)282 void SessionManagerLite::OnUserSwitch(const sptr<ISessionManagerService>& sessionManagerService)
283 {
284 TLOGD(WmsLogTag::WMS_MULTI_USER, "User switched Lite");
285 {
286 Clear();
287 std::lock_guard<std::recursive_mutex> lock(mutex_);
288 sessionManagerServiceProxy_ = sessionManagerService;
289 sceneSessionManagerLiteProxy_ = nullptr;
290 InitSceneSessionManagerLiteProxy();
291 if (!sceneSessionManagerLiteProxy_) {
292 TLOGE(WmsLogTag::WMS_MULTI_USER, "sceneSessionManagerLiteProxy is null");
293 return;
294 }
295 }
296 ReregisterSessionListener();
297 if (userSwitchCallbackFunc_) {
298 TLOGI(WmsLogTag::WMS_MULTI_USER, "User switch Lite callback.");
299 userSwitchCallbackFunc_();
300 }
301 }
302
InitSessionManagerServiceProxy()303 void SessionManagerLite::InitSessionManagerServiceProxy()
304 {
305 if (sessionManagerServiceProxy_) {
306 return;
307 }
308 auto ret = InitMockSMSProxy();
309 if (ret != WMError::WM_OK) {
310 TLOGE(WmsLogTag::DEFAULT, "Init mock session manager service failed in Lite");
311 return;
312 }
313 RegisterSMSRecoverListener();
314 sptr<IRemoteObject> remoteObject = nullptr;
315 int32_t errCode = mockSessionManagerServiceProxy_->GetSessionManagerService(remoteObject);
316 if (errCode != ERR_NONE) {
317 TLOGE(WmsLogTag::DEFAULT, "userId is illegal");
318 }
319 if (!remoteObject) {
320 WLOGFE("Remote object is nullptr");
321 return;
322 }
323 sessionManagerServiceProxy_ = iface_cast<ISessionManagerService>(remoteObject);
324 if (!sessionManagerServiceProxy_) {
325 WLOGFE("sessionManagerServiceProxy is nullptr");
326 }
327 }
328
InitScreenSessionManagerLiteProxy()329 void SessionManagerLite::InitScreenSessionManagerLiteProxy()
330 {
331 if (screenSessionManagerLiteProxy_) {
332 return;
333 }
334 if (!mockSessionManagerServiceProxy_) {
335 WLOGFE("mockSessionManagerServiceProxy is nullptr");
336 return;
337 }
338
339 sptr<IRemoteObject> remoteObject = nullptr;
340 mockSessionManagerServiceProxy_->GetScreenSessionManagerLite(remoteObject);
341 if (!remoteObject) {
342 WLOGFW("Get screen session manager lite proxy failed, null");
343 return;
344 }
345 screenSessionManagerLiteProxy_ = iface_cast<IScreenSessionManagerLite>(remoteObject);
346 if (!screenSessionManagerLiteProxy_) {
347 WLOGFW("Get screen session manager lite proxy failed, iface_cast null");
348 }
349 }
350
InitSceneSessionManagerLiteProxy()351 void SessionManagerLite::InitSceneSessionManagerLiteProxy()
352 {
353 if (sceneSessionManagerLiteProxy_) {
354 return;
355 }
356 if (!sessionManagerServiceProxy_) {
357 WLOGFE("sessionManagerServiceProxy is nullptr");
358 return;
359 }
360
361 sptr<IRemoteObject> remoteObject = sessionManagerServiceProxy_->GetSceneSessionManagerLite();
362 if (!remoteObject) {
363 WLOGFW("Get scene session manager proxy failed, null");
364 return;
365 }
366 sceneSessionManagerLiteProxy_ = iface_cast<ISceneSessionManagerLite>(remoteObject);
367 if (sceneSessionManagerLiteProxy_) {
368 ssmDeath_ = sptr<SSMDeathRecipientLite>::MakeSptr();
369 if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(ssmDeath_)) {
370 WLOGFE("Failed to add death recipient");
371 return;
372 }
373 } else {
374 WLOGFW("Get scene session manager proxy failed, iface_cast null");
375 }
376 }
377
Clear()378 void SessionManagerLite::Clear()
379 {
380 std::lock_guard<std::recursive_mutex> lock(mutex_);
381 if ((sceneSessionManagerLiteProxy_ != nullptr) && (sceneSessionManagerLiteProxy_->AsObject() != nullptr)) {
382 sceneSessionManagerLiteProxy_->AsObject()->RemoveDeathRecipient(ssmDeath_);
383 }
384 }
385
OnRemoteDied(const wptr<IRemoteObject> & wptrDeath)386 void SSMDeathRecipientLite::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
387 {
388 WLOGI("ssm OnRemoteDied");
389 SessionManagerLite::GetInstance().Clear();
390 SessionManagerLite::GetInstance().ClearSessionManagerProxy();
391 }
392
RegisterWMSConnectionChangedListener(const WMSConnectionChangedCallbackFunc & callbackFunc)393 WMError SessionManagerLite::RegisterWMSConnectionChangedListener(const WMSConnectionChangedCallbackFunc& callbackFunc)
394 {
395 TLOGD(WmsLogTag::WMS_MULTI_USER, "Lite in");
396 if (callbackFunc == nullptr) {
397 TLOGE(WmsLogTag::WMS_MULTI_USER, "Lite callbackFunc is null");
398 return WMError::WM_ERROR_NULLPTR;
399 }
400 bool isWMSAlreadyConnected = false;
401 int32_t userId = INVALID_USER_ID;
402 int32_t screenId = DEFAULT_SCREEN_ID;
403 {
404 // The mutex ensures the timing of the following variable states in multiple threads
405 std::lock_guard<std::mutex> lock(wmsConnectionMutex_);
406 wmsConnectionChangedFunc_ = callbackFunc;
407 isWMSAlreadyConnected = isWMSConnected_ && (currentWMSUserId_ > INVALID_USER_ID);
408 userId = currentWMSUserId_;
409 screenId = currentScreenId_;
410 }
411 if (isWMSAlreadyConnected) {
412 TLOGD(WmsLogTag::WMS_MULTI_USER, "Lite WMS already connected, notify immediately");
413 OnWMSConnectionChangedCallback(userId, screenId, true, true);
414 }
415 {
416 std::lock_guard<std::recursive_mutex> lock(mutex_);
417 auto ret = InitMockSMSProxy();
418 if (ret != WMError::WM_OK) {
419 TLOGE(WmsLogTag::WMS_MULTI_USER, "Init mock session manager service failed");
420 return ret;
421 }
422 }
423 RegisterSMSRecoverListener();
424 return WMError::WM_OK;
425 }
426
UnregisterWMSConnectionChangedListener()427 WMError SessionManagerLite::UnregisterWMSConnectionChangedListener()
428 {
429 {
430 std::lock_guard<std::mutex> lock(wmsConnectionMutex_);
431 wmsConnectionChangedFunc_ = nullptr;
432 }
433 UnregisterSMSRecoverListener();
434 return WMError::WM_OK;
435 }
436
InitMockSMSProxy()437 WMError SessionManagerLite::InitMockSMSProxy()
438 {
439 sptr<ISystemAbilityManager> systemAbilityManager =
440 SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
441 if (!systemAbilityManager) {
442 TLOGE(WmsLogTag::WMS_MULTI_USER, "Failed to get system ability mgr.");
443 return WMError::WM_ERROR_NULLPTR;
444 }
445 sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(WINDOW_MANAGER_SERVICE_ID);
446 if (!remoteObject) {
447 TLOGE(WmsLogTag::WMS_MULTI_USER, "Remote object is nullptr");
448 return WMError::WM_ERROR_NULLPTR;
449 }
450 mockSessionManagerServiceProxy_ = iface_cast<IMockSessionManagerInterface>(remoteObject);
451 if (!mockSessionManagerServiceProxy_) {
452 TLOGE(WmsLogTag::WMS_MULTI_USER, "Get mock session manager service proxy failed, nullptr");
453 return WMError::WM_ERROR_NULLPTR;
454 }
455
456 if (GetUserIdByUid(getuid()) != SYSTEM_USERID || isFoundationListenerRegistered_) {
457 return WMError::WM_OK;
458 }
459 if (!foundationDeath_) {
460 foundationDeath_ = sptr<FoundationDeathRecipientLite>::MakeSptr();
461 }
462 if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(foundationDeath_)) {
463 TLOGE(WmsLogTag::WMS_MULTI_USER, "Failed to add death recipient");
464 return WMError::WM_ERROR_IPC_FAILED;
465 }
466 isFoundationListenerRegistered_ = true;
467 return WMError::WM_OK;
468 }
469
RegisterSMSRecoverListener()470 void SessionManagerLite::RegisterSMSRecoverListener()
471 {
472 std::lock_guard<std::recursive_mutex> lock(mutex_);
473 if (!recoverListenerRegistered_) {
474 if (!mockSessionManagerServiceProxy_) {
475 TLOGE(WmsLogTag::WMS_RECOVER, "mockSessionManagerServiceProxy is null");
476 return;
477 }
478 recoverListenerRegistered_ = true;
479 TLOGD(WmsLogTag::WMS_RECOVER, "Register recover listener");
480 smsRecoverListener_ = sptr<SessionManagerServiceLiteRecoverListener>::MakeSptr();
481 std::string identity = IPCSkeleton::ResetCallingIdentity();
482 mockSessionManagerServiceProxy_->RegisterSMSLiteRecoverListener(smsRecoverListener_);
483 IPCSkeleton::SetCallingIdentity(identity);
484 }
485 }
486
UnregisterSMSRecoverListener()487 void SessionManagerLite::UnregisterSMSRecoverListener()
488 {
489 std::lock_guard<std::recursive_mutex> lock(mutex_);
490 recoverListenerRegistered_ = false;
491 if (mockSessionManagerServiceProxy_) {
492 mockSessionManagerServiceProxy_->UnregisterSMSLiteRecoverListener();
493 }
494 }
495
OnWMSConnectionChangedCallback(int32_t userId,int32_t screenId,bool isConnected,bool isCallbackRegistered)496 void SessionManagerLite::OnWMSConnectionChangedCallback(
497 int32_t userId, int32_t screenId, bool isConnected, bool isCallbackRegistered)
498 {
499 if (isCallbackRegistered) {
500 TLOGI(WmsLogTag::WMS_MULTI_USER,
501 "WMS connection changed with userId=%{public}d, screenId=%{public}d, isConnected=%{public}d", userId,
502 screenId, isConnected);
503 wmsConnectionChangedFunc_(userId, screenId, isConnected);
504 } else {
505 TLOGD(WmsLogTag::WMS_MULTI_USER, "Lite WMS CallbackFunc is null.");
506 }
507 }
508
OnRemoteDied(const wptr<IRemoteObject> & wptrDeath)509 void FoundationDeathRecipientLite::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
510 {
511 TLOGI(WmsLogTag::WMS_RECOVER, "Foundation died");
512 SessionManagerLite::GetInstance().OnFoundationDied();
513 }
514
OnFoundationDied()515 void SessionManagerLite::OnFoundationDied()
516 {
517 TLOGI(WmsLogTag::WMS_RECOVER, "enter");
518 {
519 std::lock_guard<std::mutex> lock(wmsConnectionMutex_);
520 isWMSConnected_ = false;
521 }
522 std::lock_guard<std::recursive_mutex> lock(mutex_);
523 isFoundationListenerRegistered_ = false;
524 recoverListenerRegistered_ = false;
525 mockSessionManagerServiceProxy_ = nullptr;
526 sessionManagerServiceProxy_ = nullptr;
527 sceneSessionManagerLiteProxy_ = nullptr;
528 }
529 } // namespace OHOS::Rosen
530