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 "screen_session_manager_client.h"
17
18 #include <hitrace_meter.h>
19 #include <iservice_registry.h>
20 #include <system_ability_definition.h>
21 #include <transaction/rs_transaction.h>
22 #include <transaction/rs_interfaces.h>
23 #include "dm_common.h"
24 #include "pipeline/rs_node_map.h"
25 #include "window_manager_hilog.h"
26
27 namespace OHOS::Rosen {
28 namespace {
29 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenSessionManagerClient" };
30 std::mutex g_instanceMutex;
31 } // namespace
32
GetInstance()33 ScreenSessionManagerClient& ScreenSessionManagerClient::GetInstance()
34 {
35 std::lock_guard<std::mutex> lock(g_instanceMutex);
36 static sptr<ScreenSessionManagerClient> instance = nullptr;
37 if (instance == nullptr) {
38 instance = new ScreenSessionManagerClient();
39 }
40 return *instance;
41 }
42
ConnectToServer()43 void ScreenSessionManagerClient::ConnectToServer()
44 {
45 if (screenSessionManager_) {
46 WLOGFI("Success to get screen session manager proxy");
47 return;
48 }
49 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
50 if (!systemAbilityMgr) {
51 WLOGFE("Failed to get system ability mgr");
52 return;
53 }
54
55 auto remoteObject = systemAbilityMgr->GetSystemAbility(DISPLAY_MANAGER_SERVICE_SA_ID);
56 if (!remoteObject) {
57 WLOGFE("Failed to get display manager service");
58 return;
59 }
60
61 screenSessionManager_ = iface_cast<IScreenSessionManager>(remoteObject);
62 if (!screenSessionManager_) {
63 WLOGFE("Failed to get screen session manager proxy");
64 return;
65 }
66 screenSessionManager_->SetClient(this);
67 }
68
RegisterScreenConnectionListener(IScreenConnectionListener * listener)69 void ScreenSessionManagerClient::RegisterScreenConnectionListener(IScreenConnectionListener* listener)
70 {
71 if (listener == nullptr) {
72 WLOGFE("Failed to register screen connection listener, listener is null");
73 return;
74 }
75
76 screenConnectionListener_ = listener;
77 ConnectToServer();
78 WLOGFI("Success to register screen connection listener");
79 }
80
81
CheckIfNeedCennectScreen(ScreenId screenId,ScreenId rsId,const std::string & name)82 bool ScreenSessionManagerClient::CheckIfNeedCennectScreen(ScreenId screenId, ScreenId rsId, const std::string& name)
83 {
84 if (rsId == SCREEN_ID_INVALID) {
85 WLOGFE("rsId is invalid");
86 return false;
87 }
88 if (!screenSessionManager_) {
89 WLOGFE("screenSessionManager_ is nullptr");
90 return false;
91 }
92 if (screenSessionManager_->GetScreenProperty(screenId).GetScreenType() == ScreenType::VIRTUAL) {
93 if (name == "HiCar" || name == "SuperLauncher" || name == "CastEngine") {
94 WLOGFI("HiCar or SuperLauncher or CastEngine, need to connect the screen");
95 return true;
96 } else {
97 WLOGFE("ScreenType is virtual, no need to connect the screen");
98 return false;
99 }
100 }
101 return true;
102 }
103
OnScreenConnectionChanged(ScreenId screenId,ScreenEvent screenEvent,ScreenId rsId,const std::string & name)104 void ScreenSessionManagerClient::OnScreenConnectionChanged(ScreenId screenId, ScreenEvent screenEvent,
105 ScreenId rsId, const std::string& name)
106 {
107 WLOGFI("screenId: %{public}" PRIu64 " screenEvent: %{public}d rsId: %{public}" PRIu64 " name: %{public}s",
108 screenId, static_cast<int>(screenEvent), rsId, name.c_str());
109 if (screenEvent == ScreenEvent::CONNECTED) {
110 if (!CheckIfNeedCennectScreen(screenId, rsId, name)) {
111 WLOGFE("There is no need to connect the screen");
112 return;
113 }
114 ScreenSessionConfig config = {
115 .screenId = screenId,
116 .rsId = rsId,
117 .name = name,
118 };
119 config.property = screenSessionManager_->GetScreenProperty(screenId);
120 config.displayNode = screenSessionManager_->GetDisplayNode(screenId);
121 sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT);
122 {
123 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
124 screenSessionMap_.emplace(screenId, screenSession);
125 }
126 if (screenConnectionListener_) {
127 screenConnectionListener_->OnScreenConnected(screenSession);
128 WLOGFI("screenId: %{public}" PRIu64 " density: %{public}f ", screenId, config.property.GetDensity());
129 screenSession->SetScreenSceneDpi(config.property.GetDensity());
130 }
131 screenSession->Connect();
132 return;
133 }
134 if (screenEvent == ScreenEvent::DISCONNECTED) {
135 auto screenSession = GetScreenSession(screenId);
136 if (!screenSession) {
137 WLOGFE("screenSession is null");
138 return;
139 }
140 screenSession->DestroyScreenScene();
141 if (screenConnectionListener_) {
142 screenConnectionListener_->OnScreenDisconnected(screenSession);
143 }
144 {
145 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
146 screenSessionMap_.erase(screenId);
147 }
148 screenSession->Disconnect();
149 }
150 }
151
GetScreenSession(ScreenId screenId) const152 sptr<ScreenSession> ScreenSessionManagerClient::GetScreenSession(ScreenId screenId) const
153 {
154 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
155 auto iter = screenSessionMap_.find(screenId);
156 if (iter == screenSessionMap_.end()) {
157 WLOGFE("Error found screen session with id: %{public}" PRIu64, screenId);
158 return nullptr;
159 }
160 return iter->second;
161 }
162
OnPropertyChanged(ScreenId screenId,const ScreenProperty & property,ScreenPropertyChangeReason reason)163 void ScreenSessionManagerClient::OnPropertyChanged(ScreenId screenId,
164 const ScreenProperty& property, ScreenPropertyChangeReason reason)
165 {
166 auto screenSession = GetScreenSession(screenId);
167 if (!screenSession) {
168 WLOGFE("screenSession is null");
169 return;
170 }
171 screenSession->PropertyChange(property, reason);
172 }
173
OnPowerStatusChanged(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)174 void ScreenSessionManagerClient::OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
175 PowerStateChangeReason reason)
176 {
177 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
178 if (screenSessionMap_.empty()) {
179 WLOGFE("[UL_POWER]screenSessionMap_ is nullptr");
180 return;
181 }
182 auto screenSession = screenSessionMap_.begin()->second;
183 if (!screenSession) {
184 WLOGFE("[UL_POWER]screenSession is null");
185 return;
186 }
187 screenSession->PowerStatusChange(event, status, reason);
188 }
189
OnSensorRotationChanged(ScreenId screenId,float sensorRotation)190 void ScreenSessionManagerClient::OnSensorRotationChanged(ScreenId screenId, float sensorRotation)
191 {
192 auto screenSession = GetScreenSession(screenId);
193 if (!screenSession) {
194 WLOGFE("screenSession is null");
195 return;
196 }
197 screenSession->SensorRotationChange(sensorRotation);
198 }
199
OnHoverStatusChanged(ScreenId screenId,int32_t hoverStatus)200 void ScreenSessionManagerClient::OnHoverStatusChanged(ScreenId screenId, int32_t hoverStatus)
201 {
202 auto screenSession = GetScreenSession(screenId);
203 if (!screenSession) {
204 WLOGFE("screenSession is null");
205 return;
206 }
207 screenSession->HandleHoverStatusChange(hoverStatus);
208 }
209
OnScreenOrientationChanged(ScreenId screenId,float screenOrientation)210 void ScreenSessionManagerClient::OnScreenOrientationChanged(ScreenId screenId, float screenOrientation)
211 {
212 auto screenSession = GetScreenSession(screenId);
213 if (!screenSession) {
214 WLOGFE("screenSession is null");
215 return;
216 }
217 screenSession->ScreenOrientationChange(screenOrientation);
218 }
219
OnScreenRotationLockedChanged(ScreenId screenId,bool isLocked)220 void ScreenSessionManagerClient::OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked)
221 {
222 auto screenSession = GetScreenSession(screenId);
223 if (!screenSession) {
224 WLOGFE("screenSession is null");
225 return;
226 }
227 screenSession->SetScreenRotationLocked(isLocked);
228 }
229
RegisterDisplayChangeListener(const sptr<IDisplayChangeListener> & listener)230 void ScreenSessionManagerClient::RegisterDisplayChangeListener(const sptr<IDisplayChangeListener>& listener)
231 {
232 displayChangeListener_ = listener;
233 }
234
RegisterSwitchingToAnotherUserFunction(std::function<void ()> && func)235 void ScreenSessionManagerClient::RegisterSwitchingToAnotherUserFunction(std::function<void()>&& func)
236 {
237 switchingToAnotherUserFunc_ = func;
238 }
239
OnDisplayStateChanged(DisplayId defaultDisplayId,sptr<DisplayInfo> displayInfo,const std::map<DisplayId,sptr<DisplayInfo>> & displayInfoMap,DisplayStateChangeType type)240 void ScreenSessionManagerClient::OnDisplayStateChanged(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
241 const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type)
242 {
243 if (displayChangeListener_) {
244 displayChangeListener_->OnDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
245 }
246 }
247
OnUpdateFoldDisplayMode(FoldDisplayMode displayMode)248 void ScreenSessionManagerClient::OnUpdateFoldDisplayMode(FoldDisplayMode displayMode)
249 {
250 displayMode_ = displayMode;
251 }
252
OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t> & missionIds,std::vector<uint64_t> & surfaceNodeIds,bool isBlackList)253 void ScreenSessionManagerClient::OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
254 std::vector<uint64_t>& surfaceNodeIds, bool isBlackList)
255 {
256 if (displayChangeListener_) {
257 displayChangeListener_->OnGetSurfaceNodeIdsFromMissionIds(missionIds, surfaceNodeIds, isBlackList);
258 }
259 }
260
OnScreenshot(DisplayId displayId)261 void ScreenSessionManagerClient::OnScreenshot(DisplayId displayId)
262 {
263 if (displayChangeListener_) {
264 displayChangeListener_->OnScreenshot(displayId);
265 }
266 }
267
OnImmersiveStateChanged(bool & immersive)268 void ScreenSessionManagerClient::OnImmersiveStateChanged(bool& immersive)
269 {
270 if (displayChangeListener_ != nullptr) {
271 displayChangeListener_->OnImmersiveStateChange(immersive);
272 }
273 }
274
GetAllScreensProperties() const275 std::map<ScreenId, ScreenProperty> ScreenSessionManagerClient::GetAllScreensProperties() const
276 {
277 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
278 std::map<ScreenId, ScreenProperty> screensProperties;
279 for (const auto& iter: screenSessionMap_) {
280 if (iter.second == nullptr) {
281 continue;
282 }
283 screensProperties[iter.first] = iter.second->GetScreenProperty();
284 }
285 return screensProperties;
286 }
287
GetFoldDisplayMode() const288 FoldDisplayMode ScreenSessionManagerClient::GetFoldDisplayMode() const
289 {
290 return displayMode_;
291 }
292
UpdateScreenRotationProperty(ScreenId screenId,const RRect & bounds,ScreenDirectionInfo directionInfo,ScreenPropertyChangeType screenPropertyChangeType)293 void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds,
294 ScreenDirectionInfo directionInfo, ScreenPropertyChangeType screenPropertyChangeType)
295 {
296 if (!screenSessionManager_) {
297 WLOGFE("screenSessionManager_ is null");
298 return;
299 }
300 screenSessionManager_->UpdateScreenDirectionInfo(screenId, directionInfo.screenRotation_, directionInfo.rotation_,
301 directionInfo.phyRotation_, screenPropertyChangeType);
302 screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, directionInfo.notifyRotation_,
303 screenPropertyChangeType);
304
305 // not need update property to input manager
306 if (screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_END ||
307 screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_UPDATE_PROPERTY_ONLY) {
308 return;
309 }
310 auto screenSession = GetScreenSession(screenId);
311 if (!screenSession) {
312 WLOGFE("screenSession is null");
313 return;
314 }
315 auto foldDisplayMode = screenSessionManager_->GetFoldDisplayMode();
316 screenSession->SetPhysicalRotation(directionInfo.phyRotation_);
317 screenSession->SetScreenComponentRotation(directionInfo.screenRotation_);
318 screenSession->UpdateToInputManager(bounds, directionInfo.notifyRotation_, directionInfo.rotation_,
319 foldDisplayMode);
320 }
321
SetDisplayNodeScreenId(ScreenId screenId,ScreenId displayNodeScreenId)322 void ScreenSessionManagerClient::SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId)
323 {
324 auto screenSession = GetScreenSession(screenId);
325 if (!screenSession) {
326 WLOGFE("screenSession is null");
327 return;
328 }
329 screenSession->SetDisplayNodeScreenId(displayNodeScreenId);
330 }
331
GetCurvedCompressionArea()332 uint32_t ScreenSessionManagerClient::GetCurvedCompressionArea()
333 {
334 if (!screenSessionManager_) {
335 WLOGFE("screenSessionManager_ is null");
336 return 0;
337 }
338 return screenSessionManager_->GetCurvedCompressionArea();
339 }
340
GetPhyScreenProperty(ScreenId screenId)341 ScreenProperty ScreenSessionManagerClient::GetPhyScreenProperty(ScreenId screenId)
342 {
343 if (!screenSessionManager_) {
344 WLOGFE("screenSessionManager_ is null");
345 return {};
346 }
347 return screenSessionManager_->GetPhyScreenProperty(screenId);
348 }
349
NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo> & info)350 __attribute__((no_sanitize("cfi"))) void ScreenSessionManagerClient::NotifyDisplayChangeInfoChanged(
351 const sptr<DisplayChangeInfo>& info)
352 {
353 if (!screenSessionManager_) {
354 WLOGFE("screenSessionManager_ is null");
355 return;
356 }
357 screenSessionManager_->NotifyDisplayChangeInfoChanged(info);
358 }
359
SetScreenPrivacyState(bool hasPrivate)360 void ScreenSessionManagerClient::SetScreenPrivacyState(bool hasPrivate)
361 {
362 if (!screenSessionManager_) {
363 WLOGFE("screenSessionManager_ is null");
364 return;
365 }
366 WLOGFD("Begin calling the SetScreenPrivacyState() of screenSessionManager_, hasPrivate: %{public}d", hasPrivate);
367 screenSessionManager_->SetScreenPrivacyState(hasPrivate);
368 WLOGFD("End calling the SetScreenPrivacyState() of screenSessionManager_");
369 }
370
SetPrivacyStateByDisplayId(DisplayId id,bool hasPrivate)371 void ScreenSessionManagerClient::SetPrivacyStateByDisplayId(DisplayId id, bool hasPrivate)
372 {
373 if (!screenSessionManager_) {
374 WLOGFE("screenSessionManager_ is null");
375 return;
376 }
377 WLOGFD("Begin calling the SetPrivacyStateByDisplayId, hasPrivate: %{public}d", hasPrivate);
378 screenSessionManager_->SetPrivacyStateByDisplayId(id, hasPrivate);
379 WLOGFD("End calling the SetPrivacyStateByDisplayId");
380 }
381
SetScreenPrivacyWindowList(DisplayId id,std::vector<std::string> privacyWindowList)382 void ScreenSessionManagerClient::SetScreenPrivacyWindowList(DisplayId id, std::vector<std::string> privacyWindowList)
383 {
384 if (!screenSessionManager_) {
385 WLOGFE("screenSessionManager_ is null");
386 return;
387 }
388 WLOGFD("Begin calling the SetScreenPrivacyWindowList(), id: %{public}" PRIu64, id);
389 screenSessionManager_->SetScreenPrivacyWindowList(id, privacyWindowList);
390 WLOGFD("End calling the SetScreenPrivacyWindowList()");
391 }
392
UpdateAvailableArea(ScreenId screenId,DMRect area)393 void ScreenSessionManagerClient::UpdateAvailableArea(ScreenId screenId, DMRect area)
394 {
395 if (!screenSessionManager_) {
396 WLOGFE("screenSessionManager_ is null");
397 return;
398 }
399 screenSessionManager_->UpdateAvailableArea(screenId, area);
400 }
401
SetScreenOffDelayTime(int32_t delay)402 int32_t ScreenSessionManagerClient::SetScreenOffDelayTime(int32_t delay)
403 {
404 if (!screenSessionManager_) {
405 WLOGFE("screenSessionManager_ is null");
406 return 0;
407 }
408 return screenSessionManager_->SetScreenOffDelayTime(delay);
409 }
410
SetCameraStatus(int32_t cameraStatus,int32_t cameraPosition)411 void ScreenSessionManagerClient::SetCameraStatus(int32_t cameraStatus, int32_t cameraPosition)
412 {
413 if (!screenSessionManager_) {
414 WLOGFE("screenSessionManager_ is null");
415 return;
416 }
417 return screenSessionManager_->SetCameraStatus(cameraStatus, cameraPosition);
418 }
419
NotifyFoldToExpandCompletion(bool foldToExpand)420 void ScreenSessionManagerClient::NotifyFoldToExpandCompletion(bool foldToExpand)
421 {
422 if (!screenSessionManager_) {
423 WLOGFE("screenSessionManager_ is null");
424 return;
425 }
426 screenSessionManager_->NotifyFoldToExpandCompletion(foldToExpand);
427 }
428
SwitchUserCallback(std::vector<int32_t> oldScbPids,int32_t currentScbPid)429 void ScreenSessionManagerClient::SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid)
430 {
431 if (!screenSessionManager_) {
432 WLOGFE("screenSessionManager_ is null");
433 return;
434 }
435 if (oldScbPids.size() == 0) {
436 WLOGFE("oldScbPids size 0");
437 return;
438 }
439 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
440 for (const auto& iter : screenSessionMap_) {
441 auto displayNode = screenSessionManager_->GetDisplayNode(iter.first);
442 if (displayNode == nullptr) {
443 WLOGFE("display node is null");
444 continue;
445 }
446 auto transactionProxy = RSTransactionProxy::GetInstance();
447 if (transactionProxy != nullptr) {
448 displayNode->SetScbNodePid(oldScbPids, currentScbPid);
449 transactionProxy->FlushImplicitTransaction();
450 } else {
451 displayNode->SetScbNodePid(oldScbPids, currentScbPid);
452 WLOGFW("transactionProxy is null");
453 }
454 ScreenId screenId = iter.first;
455 sptr<ScreenSession> screenSession = iter.second;
456 if (screenSession == nullptr) {
457 WLOGFE("screenSession is null");
458 return;
459 }
460 ScreenProperty screenProperty = screenSession->GetScreenProperty();
461 RRect bounds = screenProperty.GetBounds();
462 float rotation = screenSession->ConvertRotationToFloat(screenSession->GetRotation());
463 screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation,
464 ScreenPropertyChangeType::ROTATION_UPDATE_PROPERTY_ONLY);
465 }
466 WLOGFI("switch user callback end");
467 }
468
SwitchingCurrentUser()469 void ScreenSessionManagerClient::SwitchingCurrentUser()
470 {
471 if (screenSessionManager_ == nullptr) {
472 WLOGFE("screenSessionManager_ is null");
473 return;
474 }
475 screenSessionManager_->SwitchUser();
476 WLOGFI("switch to current user end");
477 }
478
GetFoldStatus()479 FoldStatus ScreenSessionManagerClient::GetFoldStatus()
480 {
481 if (!screenSessionManager_) {
482 WLOGFE("screenSessionManager_ is null");
483 return FoldStatus::UNKNOWN;
484 }
485 return screenSessionManager_->GetFoldStatus();
486 }
487
GetScreenSnapshot(ScreenId screenId,float scaleX,float scaleY)488 std::shared_ptr<Media::PixelMap> ScreenSessionManagerClient::GetScreenSnapshot(ScreenId screenId,
489 float scaleX, float scaleY)
490 {
491 auto screenSession = GetScreenSession(screenId);
492 if (!screenSession) {
493 WLOGFE("get screen session is null");
494 return nullptr;
495 }
496 return screenSession->GetScreenSnapshot(scaleX, scaleY);
497 }
498
GetDeviceScreenConfig()499 DeviceScreenConfig ScreenSessionManagerClient::GetDeviceScreenConfig()
500 {
501 if (!screenSessionManager_) {
502 TLOGE(WmsLogTag::DMS, "screenSessionManager_ is null");
503 return {};
504 }
505 return screenSessionManager_->GetDeviceScreenConfig();
506 }
507
GetScreenSessionById(const ScreenId id)508 sptr<ScreenSession> ScreenSessionManagerClient::GetScreenSessionById(const ScreenId id)
509 {
510 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
511 auto iter = screenSessionMap_.find(id);
512 if (iter == screenSessionMap_.end()) {
513 return nullptr;
514 }
515 return iter->second;
516 }
517
GetDefaultScreenId()518 ScreenId ScreenSessionManagerClient::GetDefaultScreenId()
519 {
520 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
521 auto iter = screenSessionMap_.begin();
522 if (iter != screenSessionMap_.end()) {
523 return iter->first;
524 }
525 return SCREEN_ID_INVALID;
526 }
527
IsFoldable()528 bool ScreenSessionManagerClient::IsFoldable()
529 {
530 if (hasCheckFoldableStatus_) {
531 return isFoldable_;
532 }
533 if (!screenSessionManager_) {
534 WLOGFE("screenSessionManager_ is null");
535 return false;
536 }
537 isFoldable_ = screenSessionManager_->IsFoldable();
538 hasCheckFoldableStatus_ = true;
539 return isFoldable_;
540 }
541
SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)542 void ScreenSessionManagerClient::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
543 {
544 sptr<ScreenSession> screenSession = GetScreenSession(screenId);
545 if (!screenSession) {
546 WLOGFE("screen session is null");
547 return;
548 }
549 if (screenSession->isScreenGroup_) {
550 WLOGFE("cannot set virtual pixel ratio to the combination. screen: %{public}" PRIu64, screenId);
551 return;
552 }
553 screenSession->SetScreenSceneDpi(virtualPixelRatio);
554 }
555
UpdateDisplayHookInfo(int32_t uid,bool enable,const DMHookInfo & hookInfo)556 void ScreenSessionManagerClient::UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo)
557 {
558 if (!screenSessionManager_) {
559 WLOGFE("screenSessionManager_ is null");
560 return;
561 }
562 screenSessionManager_->UpdateDisplayHookInfo(uid, enable, hookInfo);
563 }
564
OnFoldStatusChangedReportUE(const std::vector<std::string> & screenFoldInfo)565 void ScreenSessionManagerClient::OnFoldStatusChangedReportUE(const std::vector<std::string>& screenFoldInfo)
566 {
567 if (displayChangeListener_) {
568 displayChangeListener_->OnScreenFoldStatusChanged(screenFoldInfo);
569 }
570 }
571
UpdateDisplayScale(ScreenId id,float scaleX,float scaleY,float pivotX,float pivotY,float translateX,float translateY)572 void ScreenSessionManagerClient::UpdateDisplayScale(ScreenId id, float scaleX, float scaleY, float pivotX, float pivotY,
573 float translateX, float translateY)
574 {
575 auto session = GetScreenSession(id);
576 if (session == nullptr) {
577 TLOGE(WmsLogTag::DMS, "session is null");
578 return;
579 }
580 auto displayNode = session->GetDisplayNode();
581 if (displayNode == nullptr) {
582 TLOGE(WmsLogTag::DMS, "displayNode is null");
583 return;
584 }
585 TLOGD(WmsLogTag::DMS, "scale [%{public}f, %{public}f] translate [%{public}f, %{public}f]", scaleX, scaleY,
586 translateX, translateY);
587 HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
588 "ssmc:UpdateDisplayScale(ScreenId = %" PRIu64
589 " scaleX=%f, scaleY=%f, pivotX=%f, pivotY=%f, translateX=%f, translateY=%f",
590 id, scaleX, scaleY, pivotX, pivotY, translateX, translateY);
591 displayNode->SetScale(scaleX, scaleY);
592 displayNode->SetTranslateX(translateX);
593 displayNode->SetTranslateY(translateY);
594 auto transactionProxy = RSTransactionProxy::GetInstance();
595 if (transactionProxy != nullptr) {
596 transactionProxy->FlushImplicitTransaction();
597 } else {
598 TLOGE(WmsLogTag::DMS, "transactionProxy is nullptr");
599 }
600 session->SetScreenScale(scaleX, scaleY, pivotX, pivotY, translateX, translateY);
601 }
602
ScreenCaptureNotify(ScreenId mainScreenId,int32_t uid,const std::string & clientName)603 void ScreenSessionManagerClient::ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName)
604 {
605 sptr<ScreenSession> screenSession = GetScreenSession(mainScreenId);
606 if (!screenSession) {
607 WLOGFE("screen session is null");
608 return;
609 }
610 WLOGFI("capture screenId: %{public}" PRIu64", uid=%{public}d", mainScreenId, uid);
611 screenSession->ScreenCaptureNotify(mainScreenId, uid, clientName);
612 }
613 } // namespace OHOS::Rosen