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
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 }
149 }
150
GetScreenSession(ScreenId screenId) const151 sptr<ScreenSession> ScreenSessionManagerClient::GetScreenSession(ScreenId screenId) const
152 {
153 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
154 auto iter = screenSessionMap_.find(screenId);
155 if (iter == screenSessionMap_.end()) {
156 WLOGFE("Error found screen session with id: %{public}" PRIu64, screenId);
157 return nullptr;
158 }
159 return iter->second;
160 }
161
OnPropertyChanged(ScreenId screenId,const ScreenProperty & property,ScreenPropertyChangeReason reason)162 void ScreenSessionManagerClient::OnPropertyChanged(ScreenId screenId,
163 const ScreenProperty& property, ScreenPropertyChangeReason reason)
164 {
165 auto screenSession = GetScreenSession(screenId);
166 if (!screenSession) {
167 WLOGFE("screenSession is null");
168 return;
169 }
170 screenSession->PropertyChange(property, reason);
171 }
172
OnPowerStatusChanged(DisplayPowerEvent event,EventStatus status,PowerStateChangeReason reason)173 void ScreenSessionManagerClient::OnPowerStatusChanged(DisplayPowerEvent event, EventStatus status,
174 PowerStateChangeReason reason)
175 {
176 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
177 if (screenSessionMap_.empty()) {
178 WLOGFE("[UL_POWER]screenSessionMap_ is nullptr");
179 return;
180 }
181 auto screenSession = screenSessionMap_.begin()->second;
182 if (!screenSession) {
183 WLOGFE("[UL_POWER]screenSession is null");
184 return;
185 }
186 screenSession->PowerStatusChange(event, status, reason);
187 }
188
OnSensorRotationChanged(ScreenId screenId,float sensorRotation)189 void ScreenSessionManagerClient::OnSensorRotationChanged(ScreenId screenId, float sensorRotation)
190 {
191 auto screenSession = GetScreenSession(screenId);
192 if (!screenSession) {
193 WLOGFE("screenSession is null");
194 return;
195 }
196 screenSession->SensorRotationChange(sensorRotation);
197 }
198
OnScreenOrientationChanged(ScreenId screenId,float screenOrientation)199 void ScreenSessionManagerClient::OnScreenOrientationChanged(ScreenId screenId, float screenOrientation)
200 {
201 auto screenSession = GetScreenSession(screenId);
202 if (!screenSession) {
203 WLOGFE("screenSession is null");
204 return;
205 }
206 screenSession->ScreenOrientationChange(screenOrientation);
207 }
208
OnScreenRotationLockedChanged(ScreenId screenId,bool isLocked)209 void ScreenSessionManagerClient::OnScreenRotationLockedChanged(ScreenId screenId, bool isLocked)
210 {
211 auto screenSession = GetScreenSession(screenId);
212 if (!screenSession) {
213 WLOGFE("screenSession is null");
214 return;
215 }
216 screenSession->SetScreenRotationLocked(isLocked);
217 }
218
RegisterDisplayChangeListener(const sptr<IDisplayChangeListener> & listener)219 void ScreenSessionManagerClient::RegisterDisplayChangeListener(const sptr<IDisplayChangeListener>& listener)
220 {
221 displayChangeListener_ = listener;
222 }
223
RegisterSwitchingToAnotherUserFunction(std::function<void ()> && func)224 void ScreenSessionManagerClient::RegisterSwitchingToAnotherUserFunction(std::function<void()>&& func)
225 {
226 switchingToAnotherUserFunc_ = func;
227 }
228
OnDisplayStateChanged(DisplayId defaultDisplayId,sptr<DisplayInfo> displayInfo,const std::map<DisplayId,sptr<DisplayInfo>> & displayInfoMap,DisplayStateChangeType type)229 void ScreenSessionManagerClient::OnDisplayStateChanged(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
230 const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type)
231 {
232 if (displayChangeListener_) {
233 displayChangeListener_->OnDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
234 }
235 }
236
OnUpdateFoldDisplayMode(FoldDisplayMode displayMode)237 void ScreenSessionManagerClient::OnUpdateFoldDisplayMode(FoldDisplayMode displayMode)
238 {
239 displayMode_ = displayMode;
240 }
241
OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t> & missionIds,std::vector<uint64_t> & surfaceNodeIds,bool isBlackList)242 void ScreenSessionManagerClient::OnGetSurfaceNodeIdsFromMissionIdsChanged(std::vector<uint64_t>& missionIds,
243 std::vector<uint64_t>& surfaceNodeIds, bool isBlackList)
244 {
245 if (displayChangeListener_) {
246 displayChangeListener_->OnGetSurfaceNodeIdsFromMissionIds(missionIds, surfaceNodeIds, isBlackList);
247 }
248 }
249
OnScreenshot(DisplayId displayId)250 void ScreenSessionManagerClient::OnScreenshot(DisplayId displayId)
251 {
252 if (displayChangeListener_) {
253 displayChangeListener_->OnScreenshot(displayId);
254 }
255 }
256
OnImmersiveStateChanged(bool & immersive)257 void ScreenSessionManagerClient::OnImmersiveStateChanged(bool& immersive)
258 {
259 if (displayChangeListener_ != nullptr) {
260 displayChangeListener_->OnImmersiveStateChange(immersive);
261 }
262 }
263
GetAllScreensProperties() const264 std::map<ScreenId, ScreenProperty> ScreenSessionManagerClient::GetAllScreensProperties() const
265 {
266 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
267 std::map<ScreenId, ScreenProperty> screensProperties;
268 for (const auto& iter: screenSessionMap_) {
269 if (iter.second == nullptr) {
270 continue;
271 }
272 screensProperties[iter.first] = iter.second->GetScreenProperty();
273 }
274 return screensProperties;
275 }
276
GetFoldDisplayMode() const277 FoldDisplayMode ScreenSessionManagerClient::GetFoldDisplayMode() const
278 {
279 return displayMode_;
280 }
281
UpdateScreenRotationProperty(ScreenId screenId,const RRect & bounds,float rotation,ScreenPropertyChangeType screenPropertyChangeType)282 void ScreenSessionManagerClient::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation,
283 ScreenPropertyChangeType screenPropertyChangeType)
284 {
285 if (!screenSessionManager_) {
286 WLOGFE("screenSessionManager_ is null");
287 return;
288 }
289 screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation, screenPropertyChangeType);
290
291 // not need update property to input manager
292 if (screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_END ||
293 screenPropertyChangeType == ScreenPropertyChangeType::ROTATION_UPDATE_PROPERTY_ONLY) {
294 return;
295 }
296 auto screenSession = GetScreenSession(screenId);
297 if (!screenSession) {
298 WLOGFE("screenSession is null");
299 return;
300 }
301 auto foldDisplayMode = screenSessionManager_->GetFoldDisplayMode();
302 screenSession->UpdateToInputManager(bounds, rotation, foldDisplayMode);
303 }
304
SetDisplayNodeScreenId(ScreenId screenId,ScreenId displayNodeScreenId)305 void ScreenSessionManagerClient::SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId)
306 {
307 auto screenSession = GetScreenSession(screenId);
308 if (!screenSession) {
309 WLOGFE("screenSession is null");
310 return;
311 }
312 screenSession->SetDisplayNodeScreenId(displayNodeScreenId);
313 }
314
GetCurvedCompressionArea()315 uint32_t ScreenSessionManagerClient::GetCurvedCompressionArea()
316 {
317 if (!screenSessionManager_) {
318 WLOGFE("screenSessionManager_ is null");
319 return 0;
320 }
321 return screenSessionManager_->GetCurvedCompressionArea();
322 }
323
GetPhyScreenProperty(ScreenId screenId)324 ScreenProperty ScreenSessionManagerClient::GetPhyScreenProperty(ScreenId screenId)
325 {
326 if (!screenSessionManager_) {
327 WLOGFE("screenSessionManager_ is null");
328 return {};
329 }
330 return screenSessionManager_->GetPhyScreenProperty(screenId);
331 }
332
NotifyDisplayChangeInfoChanged(const sptr<DisplayChangeInfo> & info)333 __attribute__((no_sanitize("cfi"))) void ScreenSessionManagerClient::NotifyDisplayChangeInfoChanged(
334 const sptr<DisplayChangeInfo>& info)
335 {
336 if (!screenSessionManager_) {
337 WLOGFE("screenSessionManager_ is null");
338 return;
339 }
340 screenSessionManager_->NotifyDisplayChangeInfoChanged(info);
341 }
342
SetScreenPrivacyState(bool hasPrivate)343 void ScreenSessionManagerClient::SetScreenPrivacyState(bool hasPrivate)
344 {
345 if (!screenSessionManager_) {
346 WLOGFE("screenSessionManager_ is null");
347 return;
348 }
349 WLOGFD("Begin calling the SetScreenPrivacyState() of screenSessionManager_, hasPrivate: %{public}d", hasPrivate);
350 screenSessionManager_->SetScreenPrivacyState(hasPrivate);
351 WLOGFD("End calling the SetScreenPrivacyState() of screenSessionManager_");
352 }
353
SetPrivacyStateByDisplayId(DisplayId id,bool hasPrivate)354 void ScreenSessionManagerClient::SetPrivacyStateByDisplayId(DisplayId id, bool hasPrivate)
355 {
356 if (!screenSessionManager_) {
357 WLOGFE("screenSessionManager_ is null");
358 return;
359 }
360 WLOGFD("Begin calling the SetPrivacyStateByDisplayId, hasPrivate: %{public}d", hasPrivate);
361 screenSessionManager_->SetPrivacyStateByDisplayId(id, hasPrivate);
362 WLOGFD("End calling the SetPrivacyStateByDisplayId");
363 }
364
SetScreenPrivacyWindowList(DisplayId id,std::vector<std::string> privacyWindowList)365 void ScreenSessionManagerClient::SetScreenPrivacyWindowList(DisplayId id, std::vector<std::string> privacyWindowList)
366 {
367 if (!screenSessionManager_) {
368 WLOGFE("screenSessionManager_ is null");
369 return;
370 }
371 WLOGFD("Begin calling the SetScreenPrivacyWindowList(), id: %{public}" PRIu64, id);
372 screenSessionManager_->SetScreenPrivacyWindowList(id, privacyWindowList);
373 WLOGFD("End calling the SetScreenPrivacyWindowList()");
374 }
375
UpdateAvailableArea(ScreenId screenId,DMRect area)376 void ScreenSessionManagerClient::UpdateAvailableArea(ScreenId screenId, DMRect area)
377 {
378 if (!screenSessionManager_) {
379 WLOGFE("screenSessionManager_ is null");
380 return;
381 }
382 screenSessionManager_->UpdateAvailableArea(screenId, area);
383 }
384
SetScreenOffDelayTime(int32_t delay)385 int32_t ScreenSessionManagerClient::SetScreenOffDelayTime(int32_t delay)
386 {
387 if (!screenSessionManager_) {
388 WLOGFE("screenSessionManager_ is null");
389 return 0;
390 }
391 return screenSessionManager_->SetScreenOffDelayTime(delay);
392 }
393
NotifyFoldToExpandCompletion(bool foldToExpand)394 void ScreenSessionManagerClient::NotifyFoldToExpandCompletion(bool foldToExpand)
395 {
396 if (!screenSessionManager_) {
397 WLOGFE("screenSessionManager_ is null");
398 return;
399 }
400 screenSessionManager_->NotifyFoldToExpandCompletion(foldToExpand);
401 }
402
SwitchUserCallback(std::vector<int32_t> oldScbPids,int32_t currentScbPid)403 void ScreenSessionManagerClient::SwitchUserCallback(std::vector<int32_t> oldScbPids, int32_t currentScbPid)
404 {
405 if (!screenSessionManager_) {
406 WLOGFE("screenSessionManager_ is null");
407 return;
408 }
409 if (oldScbPids.size() == 0) {
410 WLOGFE("oldScbPids size 0");
411 return;
412 }
413 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
414 for (const auto& iter : screenSessionMap_) {
415 auto displayNode = screenSessionManager_->GetDisplayNode(iter.first);
416 if (displayNode == nullptr) {
417 WLOGFE("display node is null");
418 continue;
419 }
420 auto transactionProxy = RSTransactionProxy::GetInstance();
421 if (transactionProxy != nullptr) {
422 displayNode->SetScbNodePid(oldScbPids, currentScbPid);
423 transactionProxy->FlushImplicitTransaction();
424 } else {
425 displayNode->SetScbNodePid(oldScbPids, currentScbPid);
426 WLOGFW("transactionProxy is null");
427 }
428 ScreenId screenId = iter.first;
429 sptr<ScreenSession> screenSession = iter.second;
430 if (screenSession == nullptr) {
431 WLOGFE("screenSession is null");
432 return;
433 }
434 ScreenProperty screenProperty = screenSession->GetScreenProperty();
435 RRect bounds = screenProperty.GetBounds();
436 float rotation = screenSession->ConvertRotationToFloat(screenSession->GetRotation());
437 screenSessionManager_->UpdateScreenRotationProperty(screenId, bounds, rotation,
438 ScreenPropertyChangeType::ROTATION_UPDATE_PROPERTY_ONLY);
439 }
440 WLOGFI("switch user callback end");
441 }
442
SwitchingCurrentUser()443 void ScreenSessionManagerClient::SwitchingCurrentUser()
444 {
445 if (screenSessionManager_ == nullptr) {
446 WLOGFE("screenSessionManager_ is null");
447 return;
448 }
449 screenSessionManager_->SwitchUser();
450 WLOGFI("switch to current user end");
451 }
452
GetFoldStatus()453 FoldStatus ScreenSessionManagerClient::GetFoldStatus()
454 {
455 if (!screenSessionManager_) {
456 WLOGFE("screenSessionManager_ is null");
457 return FoldStatus::UNKNOWN;
458 }
459 return screenSessionManager_->GetFoldStatus();
460 }
461
GetScreenSnapshot(ScreenId screenId,float scaleX,float scaleY)462 std::shared_ptr<Media::PixelMap> ScreenSessionManagerClient::GetScreenSnapshot(ScreenId screenId,
463 float scaleX, float scaleY)
464 {
465 auto screenSession = GetScreenSession(screenId);
466 if (!screenSession) {
467 WLOGFE("get screen session is null");
468 return nullptr;
469 }
470 return screenSession->GetScreenSnapshot(scaleX, scaleY);
471 }
472
GetDeviceScreenConfig()473 DeviceScreenConfig ScreenSessionManagerClient::GetDeviceScreenConfig()
474 {
475 if (!screenSessionManager_) {
476 TLOGE(WmsLogTag::DMS, "screenSessionManager_ is null");
477 return {};
478 }
479 return screenSessionManager_->GetDeviceScreenConfig();
480 }
481
GetScreenSessionById(const ScreenId id)482 sptr<ScreenSession> ScreenSessionManagerClient::GetScreenSessionById(const ScreenId id)
483 {
484 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
485 auto iter = screenSessionMap_.find(id);
486 if (iter == screenSessionMap_.end()) {
487 return nullptr;
488 }
489 return iter->second;
490 }
491
GetDefaultScreenId()492 ScreenId ScreenSessionManagerClient::GetDefaultScreenId()
493 {
494 std::lock_guard<std::mutex> lock(screenSessionMapMutex_);
495 auto iter = screenSessionMap_.begin();
496 if (iter != screenSessionMap_.end()) {
497 return iter->first;
498 }
499 return SCREEN_ID_INVALID;
500 }
501
IsFoldable()502 bool ScreenSessionManagerClient::IsFoldable()
503 {
504 if (hasCheckFoldableStatus_) {
505 return isFoldable_;
506 }
507 if (!screenSessionManager_) {
508 WLOGFE("screenSessionManager_ is null");
509 return false;
510 }
511 isFoldable_ = screenSessionManager_->IsFoldable();
512 hasCheckFoldableStatus_ = true;
513 return isFoldable_;
514 }
515
SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)516 void ScreenSessionManagerClient::SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
517 {
518 sptr<ScreenSession> screenSession = GetScreenSession(screenId);
519 if (!screenSession) {
520 WLOGFE("screen session is null");
521 return;
522 }
523 if (screenSession->isScreenGroup_) {
524 WLOGFE("cannot set virtual pixel ratio to the combination. screen: %{public}" PRIu64, screenId);
525 return;
526 }
527 screenSession->SetScreenSceneDpi(virtualPixelRatio);
528 }
529
UpdateDisplayHookInfo(int32_t uid,bool enable,const DMHookInfo & hookInfo)530 void ScreenSessionManagerClient::UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo)
531 {
532 if (!screenSessionManager_) {
533 WLOGFE("screenSessionManager_ is null");
534 return;
535 }
536 screenSessionManager_->UpdateDisplayHookInfo(uid, enable, hookInfo);
537 }
538
OnFoldStatusChangedReportUE(const std::vector<std::string> & screenFoldInfo)539 void ScreenSessionManagerClient::OnFoldStatusChangedReportUE(const std::vector<std::string>& screenFoldInfo)
540 {
541 if (displayChangeListener_) {
542 displayChangeListener_->OnScreenFoldStatusChanged(screenFoldInfo);
543 }
544 }
545
UpdateDisplayScale(ScreenId id,float scaleX,float scaleY,float pivotX,float pivotY,float translateX,float translateY)546 void ScreenSessionManagerClient::UpdateDisplayScale(ScreenId id, float scaleX, float scaleY, float pivotX, float pivotY,
547 float translateX, float translateY)
548 {
549 auto session = GetScreenSession(id);
550 if (session == nullptr) {
551 TLOGE(WmsLogTag::DMS, "session is null");
552 return;
553 }
554 auto displayNode = session->GetDisplayNode();
555 if (displayNode == nullptr) {
556 TLOGE(WmsLogTag::DMS, "displayNode is null");
557 return;
558 }
559 TLOGD(WmsLogTag::DMS, "scale [%{public}f, %{public}f] translate [%{public}f, %{public}f]", scaleX, scaleY,
560 translateX, translateY);
561 HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
562 "ssmc:UpdateDisplayScale(ScreenId = %" PRIu64
563 " scaleX=%f, scaleY=%f, pivotX=%f, pivotY=%f, translateX=%f, translateY=%f",
564 id, scaleX, scaleY, pivotX, pivotY, translateX, translateY);
565 displayNode->SetScale(scaleX, scaleY);
566 displayNode->SetTranslateX(translateX);
567 displayNode->SetTranslateY(translateY);
568 auto transactionProxy = RSTransactionProxy::GetInstance();
569 if (transactionProxy != nullptr) {
570 transactionProxy->FlushImplicitTransaction();
571 } else {
572 TLOGE(WmsLogTag::DMS, "transactionProxy is nullptr");
573 }
574 session->SetScreenScale(scaleX, scaleY, pivotX, pivotY, translateX, translateY);
575 }
576 } // namespace OHOS::Rosen