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 #ifndef OHOS_ROSEN_WINDOW_SCENE_SESSION_H 17 #define OHOS_ROSEN_WINDOW_SCENE_SESSION_H 18 19 #include <list> 20 #include <mutex> 21 #include <shared_mutex> 22 #include <vector> 23 24 #include <event_handler.h> 25 26 #include "dm_common.h" 27 #include "interfaces/include/ws_common.h" 28 #include "occupied_area_change_info.h" 29 #include "pattern_detach_callback_interface.h" 30 #include "session/container/include/zidl/session_stage_interface.h" 31 #include "session/host/include/zidl/session_stub.h" 32 #include "session/host/include/scene_persistence.h" 33 #include "thread_safety_annotations.h" 34 #include "vsync_station.h" 35 #include "window_visibility_info.h" 36 #include "wm_common.h" 37 38 namespace OHOS::MMI { 39 class PointerEvent; 40 class KeyEvent; 41 class AxisEvent; 42 enum class WindowArea; 43 } // namespace OHOS::MMI 44 45 namespace OHOS::Media { 46 class PixelMap; 47 } // namespace OHOS::Media 48 49 namespace OHOS::Rosen { 50 class RSSurfaceNode; 51 class RSTransaction; 52 class RSSyncTransactionController; 53 class Session; 54 using NotifySessionRectChangeFunc = std::function<void(const WSRect& rect, 55 SizeChangeReason reason, DisplayId displayId, const RectAnimationConfig& rectAnimationConfig)>; 56 using NotifySessionDisplayIdChangeFunc = std::function<void(uint64_t displayId)>; 57 using NotifyPendingSessionActivationFunc = std::function<void(SessionInfo& info)>; 58 using NotifyChangeSessionVisibilityWithStatusBarFunc = std::function<void(const SessionInfo& info, bool visible)>; 59 using NotifySessionStateChangeFunc = std::function<void(const SessionState& state)>; 60 using NotifyBufferAvailableChangeFunc = std::function<void(const bool isAvailable)>; 61 using NotifySessionStateChangeNotifyManagerFunc = std::function<void(int32_t persistentId, const SessionState& state)>; 62 using NotifyRequestFocusStatusNotifyManagerFunc = 63 std::function<void(int32_t persistentId, const bool isFocused, const bool byForeground, FocusChangeReason reason)>; 64 using NotifyBackPressedFunc = std::function<void(const bool needMoveToBackground)>; 65 using NotifySessionFocusableChangeFunc = std::function<void(const bool isFocusable)>; 66 using NotifySessionTouchableChangeFunc = std::function<void(const bool touchable)>; 67 using NotifyClickFunc = std::function<void(bool requestFocus, bool isClick)>; 68 using NotifyTerminateSessionFunc = std::function<void(const SessionInfo& info)>; 69 using NotifyTerminateSessionFuncNew = 70 std::function<void(const SessionInfo& info, bool needStartCaller, bool isFromBroker)>; 71 using NotifyTerminateSessionFuncTotal = std::function<void(const SessionInfo& info, TerminateType terminateType)>; 72 using NofitySessionLabelUpdatedFunc = std::function<void(const std::string& label)>; 73 using NofitySessionIconUpdatedFunc = std::function<void(const std::string& iconPath)>; 74 using NotifySessionExceptionFunc = 75 std::function<void(const SessionInfo& info, const ExceptionInfo& exceptionInfo, bool startFail)>; 76 using NotifySessionSnapshotFunc = std::function<void(const int32_t& persistentId)>; 77 using NotifyPendingSessionToForegroundFunc = std::function<void(const SessionInfo& info)>; 78 using NotifyPendingSessionToBackgroundForDelegatorFunc = std::function<void(const SessionInfo& info, 79 bool shouldBackToCaller)>; 80 using NotifyClickModalWindowOutsideFunc = std::function<void()>; 81 using NotifyRaiseToTopForPointDownFunc = std::function<void()>; 82 using NotifyUIRequestFocusFunc = std::function<void()>; 83 using NotifyUILostFocusFunc = std::function<void()>; 84 using NotifySessionInfoLockedStateChangeFunc = std::function<void(const bool lockedState)>; 85 using GetStateFromManagerFunc = std::function<bool(const ManagerState key)>; 86 using NotifySystemSessionPointerEventFunc = std::function<void(std::shared_ptr<MMI::PointerEvent> pointerEvent)>; 87 using NotifySessionInfoChangeNotifyManagerFunc = std::function<void(int32_t persistentid)>; 88 using NotifySystemSessionKeyEventFunc = std::function<bool(std::shared_ptr<MMI::KeyEvent> keyEvent, 89 bool isPreImeEvent)>; 90 using NotifyContextTransparentFunc = std::function<void()>; 91 using NotifyFrameLayoutFinishFunc = std::function<void()>; 92 using VisibilityChangedDetectFunc = std::function<void(int32_t pid, bool isVisible, bool newIsVisible)>; 93 using AcquireRotateAnimationConfigFunc = std::function<void(RotateAnimationConfig& config)>; 94 using RequestVsyncFunc = std::function<void(const std::shared_ptr<VsyncCallback>& callback)>; 95 using NotifyWindowMovingFunc = std::function<void(DisplayId displayId, int32_t pointerX, int32_t pointerY)>; 96 using NofitySessionLabelAndIconUpdatedFunc = 97 std::function<void(const std::string& label, const std::shared_ptr<Media::PixelMap>& icon)>; 98 using NotifyKeyboardStateChangeFunc = std::function<void(SessionState state, KeyboardViewMode mode)>; 99 using NotifyHighlightChangeFunc = std::function<void(bool isHighlight)>; 100 using NotifySurfaceBoundsChangeFunc = std::function<void(const WSRect& rect, bool isGlobal, bool needFlush)>; 101 102 class ILifecycleListener { 103 public: OnActivation()104 virtual void OnActivation() {} OnConnect()105 virtual void OnConnect() {} OnForeground()106 virtual void OnForeground() {} OnBackground()107 virtual void OnBackground() {} OnDisconnect()108 virtual void OnDisconnect() {} OnLayoutFinished()109 virtual void OnLayoutFinished() {} OnRemoveBlank()110 virtual void OnRemoveBlank() {} OnAddSnapshot()111 virtual void OnAddSnapshot() {} OnRemoveSnapshot()112 virtual void OnRemoveSnapshot() {} OnDrawingCompleted()113 virtual void OnDrawingCompleted() {} OnExtensionDied()114 virtual void OnExtensionDied() {} OnExtensionDetachToDisplay()115 virtual void OnExtensionDetachToDisplay() {} OnExtensionTimeout(int32_t errorCode)116 virtual void OnExtensionTimeout(int32_t errorCode) {} OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)117 virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 118 int64_t uiExtensionIdLevel) {} OnAppRemoveStartingWindow()119 virtual void OnAppRemoveStartingWindow() {} 120 }; 121 122 enum class LifeCycleTaskType : uint32_t { 123 START, 124 STOP 125 }; 126 127 enum class DetectTaskState : uint32_t { 128 NO_TASK, 129 ATTACH_TASK, 130 DETACH_TASK 131 }; 132 133 struct DetectTaskInfo { 134 WindowMode taskWindowMode = WindowMode::WINDOW_MODE_UNDEFINED; 135 DetectTaskState taskState = DetectTaskState::NO_TASK; 136 }; 137 138 class Session : public SessionStub { 139 public: 140 friend class HidumpController; 141 using Task = std::function<void()>; 142 explicit Session(const SessionInfo& info); 143 virtual ~Session(); 144 bool isKeyboardPanelEnabled_ = false; 145 virtual void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler>& handler, 146 const std::shared_ptr<AppExecFwk::EventHandler>& exportHandler = nullptr); 147 148 /* 149 * Window LifeCycle 150 */ 151 virtual WSError ConnectInner(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel, 152 const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig, 153 sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr, 154 int32_t pid = -1, int32_t uid = -1, const std::string& identityToken = "") REQUIRES(SCENE_GUARD); 155 WSError Foreground(sptr<WindowSessionProperty> property, bool isFromClient = false, 156 const std::string& identityToken = "") override; 157 WSError Background(bool isFromClient = false, const std::string& identityToken = "") override; 158 WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override REQUIRES(SCENE_GUARD); 159 WSError Show(sptr<WindowSessionProperty> property) override; 160 WSError Hide() override; 161 WSError DrawingCompleted() override; 162 void ResetSessionConnectState() REQUIRES(SCENE_GUARD); 163 void ResetIsActive(); 164 WSError PendingSessionToForeground(); 165 WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); 166 bool RegisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener); 167 bool UnregisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener); 168 void SetPendingSessionActivationEventListener(NotifyPendingSessionActivationFunc&& func); 169 void SetTerminateSessionListener(NotifyTerminateSessionFunc&& func); 170 void SetTerminateSessionListenerNew(NotifyTerminateSessionFuncNew&& func); 171 void SetSessionExceptionListener(NotifySessionExceptionFunc&& func, bool fromJsScene); 172 void SetTerminateSessionListenerTotal(NotifyTerminateSessionFuncTotal&& func); 173 void SetBackPressedListenser(NotifyBackPressedFunc&& func); 174 void SetPendingSessionToForegroundListener(NotifyPendingSessionToForegroundFunc&& func); 175 void SetPendingSessionToBackgroundForDelegatorListener(NotifyPendingSessionToBackgroundForDelegatorFunc&& func); 176 void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func); 177 WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker); 178 WSError TerminateSessionTotal(const sptr<AAFwk::SessionInfo> info, TerminateType terminateType); 179 180 /* 181 * App Use Control 182 */ GetIsUseControlSession()183 virtual bool GetIsUseControlSession() const { return false; } SetIsUseControlSession(bool isUseControlSession)184 virtual void SetIsUseControlSession(bool isUseControlSession) {} 185 186 /* 187 * Window Recover 188 */ 189 WSError Reconnect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel, 190 const std::shared_ptr<RSSurfaceNode>& surfaceNode, sptr<WindowSessionProperty> property = nullptr, 191 sptr<IRemoteObject> token = nullptr, int32_t pid = -1, int32_t uid = -1) REQUIRES(SCENE_GUARD); 192 193 /* 194 * Callbacks for ILifecycleListener 195 */ 196 void NotifyActivation(); 197 void NotifyConnect(); 198 void NotifyForeground(); 199 void NotifyBackground(); 200 void NotifyDisconnect(); 201 void NotifyLayoutFinished(); 202 void NotifyRemoveBlank(); 203 void NotifyAddSnapshot(); 204 void NotifyRemoveSnapshot(); 205 void NotifyExtensionDied() override; 206 void NotifyExtensionTimeout(int32_t errorCode) override; 207 void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 208 int64_t uiExtensionIdLevel) override; 209 void NotifyExtensionDetachToDisplay() override; 210 211 /* 212 * Cross Display Move Drag 213 */ 214 std::shared_ptr<RSSurfaceNode> GetSurfaceNodeForMoveDrag() const; 215 216 virtual WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, 217 bool needNotifyClient = true, bool isExecuteDelayRaise = false); 218 virtual WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent); 219 NotifyClientToUpdateRect(const std::string & updateReason,std::shared_ptr<RSTransaction> rsTransaction)220 virtual WSError NotifyClientToUpdateRect(const std::string& updateReason, 221 std::shared_ptr<RSTransaction> rsTransaction) { return WSError::WS_OK; } 222 WSError TransferBackPressedEventForConsumed(bool& isConsumed); 223 WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed, 224 bool isPreImeEvent = false); 225 WSError TransferFocusActiveEvent(bool isFocusActive); 226 WSError TransferFocusStateEvent(bool focusState); UpdateAvoidArea(const sptr<AvoidArea> & avoidArea,AvoidAreaType type)227 virtual WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) { return WSError::WS_OK; } 228 229 int32_t GetPersistentId() const; 230 void SetSurfaceNode(const std::shared_ptr<RSSurfaceNode>& surfaceNode); 231 std::shared_ptr<RSSurfaceNode> GetSurfaceNode() const; 232 std::optional<NodeId> GetSurfaceNodeId() const; 233 void SetLeashWinSurfaceNode(std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode); 234 std::shared_ptr<RSSurfaceNode> GetLeashWinSurfaceNode() const; 235 236 /* 237 * Window Scene Snapshot 238 */ 239 std::shared_ptr<Media::PixelMap> GetSnapshot() const; 240 std::shared_ptr<Media::PixelMap> Snapshot( 241 bool runInFfrt = false, float scaleParam = 0.0f, bool useCurWindow = false) const; 242 void ResetSnapshot(); 243 void SaveSnapshot(bool useFfrt, bool needPersist = true); SetSaveSnapshotCallback(Task && task)244 void SetSaveSnapshotCallback(Task&& task) 245 { 246 if (task) { 247 saveSnapshotCallback_ = std::move(task); 248 } 249 } SetRemoveSnapshotCallback(Task && task)250 void SetRemoveSnapshotCallback(Task&& task) 251 { 252 if (task) { 253 removeSnapshotCallback_ = std::move(task); 254 } 255 } 256 257 SessionState GetSessionState() const; 258 virtual void SetSessionState(SessionState state); 259 void SetSessionInfoAncoSceneState(int32_t ancoSceneState); 260 void SetSessionInfoTime(const std::string& time); 261 void SetSessionInfoAbilityInfo(const std::shared_ptr<AppExecFwk::AbilityInfo>& abilityInfo); 262 void SetSessionInfoWant(const std::shared_ptr<AAFwk::Want>& want); 263 void ResetSessionInfoResultCode(); 264 void SetSessionInfoPersistentId(int32_t persistentId); 265 void SetSessionInfoCallerPersistentId(int32_t callerPersistentId); 266 void SetSessionInfoContinueState(ContinueState state); 267 void SetSessionInfoLockedState(bool lockedState); 268 void SetSessionInfoIsClearSession(bool isClearSession); 269 void SetSessionInfoAffinity(std::string affinity); 270 void GetCloseAbilityWantAndClean(AAFwk::Want& outWant); 271 void SetSessionInfo(const SessionInfo& info); 272 const SessionInfo& GetSessionInfo() const; 273 SessionInfo& EditSessionInfo(); 274 DisplayId GetScreenId() const; 275 virtual void SetScreenId(uint64_t screenId); 276 WindowType GetWindowType() const; 277 float GetAspectRatio() const; 278 WSError SetAspectRatio(float ratio) override; 279 WSError SetSessionProperty(const sptr<WindowSessionProperty>& property); 280 WSError SetSessionPropertyForReconnect(const sptr<WindowSessionProperty>& property); GetSessionProperty()281 const sptr<WindowSessionProperty>& GetSessionProperty() const { return property_; } 282 void SetSessionRect(const WSRect& rect); 283 WSRect GetSessionRect() const; 284 WSRect GetSessionGlobalRect() const; 285 WMError GetGlobalScaledRect(Rect& globalScaledRect) override; 286 void SetSessionGlobalRect(const WSRect& rect); 287 void SetSessionRequestRect(const WSRect& rect); 288 WSRect GetSessionRequestRect() const; 289 void SetRequestRectAnimationConfig(const RectAnimationConfig& rectAnimationConfig); 290 RectAnimationConfig GetRequestRectAnimationConfig() const; 291 std::string GetWindowName() const; 292 WSRect GetLastLayoutRect() const; 293 WSRect GetLayoutRect() const; 294 295 virtual WSError SetActive(bool active); 296 virtual WSError UpdateSizeChangeReason(SizeChangeReason reason); GetSizeChangeReason()297 SizeChangeReason GetSizeChangeReason() const { return reason_; } 298 virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, 299 const std::string& updateReason, const std::shared_ptr<RSTransaction>& rsTransaction = nullptr); 300 virtual WSError UpdateRectWithLayoutInfo(const WSRect& rect, SizeChangeReason reason, 301 const std::string& updateReason, const std::shared_ptr<RSTransaction>& rsTransaction = nullptr, 302 const std::map<AvoidAreaType, AvoidArea>& avoidAreas = {}); 303 WSError UpdateDensity(); 304 WSError UpdateOrientation(); 305 306 void SetShowRecent(bool showRecent); 307 void SetSystemActive(bool systemActive); 308 bool GetShowRecent() const; 309 void SetOffset(float x, float y); 310 float GetOffsetX() const; 311 float GetOffsetY() const; 312 void SetBounds(const WSRectF& bounds); 313 WSRectF GetBounds(); 314 void SetRotation(Rotation rotation); 315 Rotation GetRotation() const; 316 void SetBufferAvailable(bool bufferAvailable); 317 bool GetBufferAvailable() const; 318 void SetNeedSnapshot(bool needSnapshot); 319 virtual void SetExitSplitOnBackground(bool isExitSplitOnBackground); 320 virtual bool IsExitSplitOnBackground() const; NeedStartingWindowExitAnimation()321 virtual bool NeedStartingWindowExitAnimation() const { return true; } 322 323 void SetChangeSessionVisibilityWithStatusBarEventListener( 324 NotifyChangeSessionVisibilityWithStatusBarFunc&& func); 325 WSError Clear(bool needStartCaller = false); 326 WSError SetSessionLabel(const std::string& label); 327 void SetUpdateSessionLabelListener(const NofitySessionLabelUpdatedFunc& func); 328 WSError SetSessionIcon(const std::shared_ptr<Media::PixelMap>& icon); 329 void SetUpdateSessionIconListener(const NofitySessionIconUpdatedFunc& func); 330 void SetSessionStateChangeListenser(const NotifySessionStateChangeFunc& func); 331 void SetBufferAvailableChangeListener(const NotifyBufferAvailableChangeFunc& func); 332 virtual void UnregisterSessionChangeListeners(); 333 void SetSessionStateChangeNotifyManagerListener(const NotifySessionStateChangeNotifyManagerFunc& func); 334 void SetSessionInfoChangeNotifyManagerListener(const NotifySessionInfoChangeNotifyManagerFunc& func); 335 void SetRequestFocusStatusNotifyManagerListener(const NotifyRequestFocusStatusNotifyManagerFunc& func); 336 void SetNotifyUIRequestFocusFunc(const NotifyUIRequestFocusFunc& func); 337 void SetNotifyUILostFocusFunc(const NotifyUILostFocusFunc& func); 338 void SetGetStateFromManagerListener(const GetStateFromManagerFunc& func); 339 340 void SetSystemConfig(const SystemSessionConfig& systemConfig); 341 void SetSnapshotScale(const float snapshotScale); 342 virtual WSError ProcessBackEvent(); // send back event to session_stage 343 344 sptr<ScenePersistence> GetScenePersistence() const; 345 void SetParentSession(const sptr<Session>& session); 346 sptr<Session> GetParentSession() const; 347 void BindDialogToParentSession(const sptr<Session>& session); 348 void RemoveDialogToParentSession(const sptr<Session>& session); 349 std::vector<sptr<Session>> GetDialogVector() const; 350 void ClearDialogVector(); 351 WSError NotifyDestroy(); 352 WSError NotifyCloseExistPipWindow(); 353 354 void SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func); 355 void SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func); 356 void SetClickListener(const NotifyClickFunc& func); 357 void NotifySessionFocusableChange(bool isFocusable); 358 void NotifySessionTouchableChange(bool touchable); 359 void NotifyClick(bool requestFocus = true, bool isClick = true); 360 bool GetStateFromManager(const ManagerState key); 361 virtual void PresentFoucusIfNeed(int32_t pointerAcrion); 362 virtual WSError UpdateWindowMode(WindowMode mode); 363 WSError SetCompatibleModeInPc(bool enable, bool isSupportDragInPcCompatibleMode); 364 WSError SetAppSupportPhoneInPc(bool isSupportPhone); 365 WSError SetCompatibleWindowSizeInPc(int32_t portraitWidth, int32_t portraitHeight, 366 int32_t landscapeWidth, int32_t landscapeHeight); 367 WSError SetCompatibleModeEnableInPad(bool enable); 368 WSError CompatibleFullScreenRecover(); 369 WSError CompatibleFullScreenMinimize(); 370 WSError CompatibleFullScreenClose(); 371 WSError PcAppInPadNormalClose(); 372 WSError SetIsPcAppInPad(bool enable); 373 bool NeedNotify() const; 374 void SetNeedNotify(bool needNotify); 375 WSError SetTouchable(bool touchable); 376 bool GetTouchable() const; 377 void SetForceTouchable(bool touchable); 378 virtual void SetSystemTouchable(bool touchable); 379 bool GetSystemTouchable() const; 380 virtual WSError SetRSVisible(bool isVisible); 381 bool GetRSVisible() const; 382 WSError SetVisibilityState(WindowVisibilityState state); 383 WindowVisibilityState GetVisibilityState() const; 384 WSError SetDrawingContentState(bool isRSDrawing); 385 bool GetDrawingContentState() const; 386 WSError SetBrightness(float brightness); 387 float GetBrightness() const; 388 void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info, 389 const std::shared_ptr<RSTransaction>& rsTransaction = nullptr); 390 void SetSessionInfoLockedStateChangeListener(const NotifySessionInfoLockedStateChangeFunc& func); 391 void NotifySessionInfoLockedStateChange(bool lockedState); 392 void SetContextTransparentFunc(const NotifyContextTransparentFunc& func); 393 void NotifyContextTransparent(); 394 bool NeedCheckContextTransparent() const; 395 396 /* 397 * Window Rotate Animation 398 */ 399 void SetAcquireRotateAnimationConfigFunc(const AcquireRotateAnimationConfigFunc& func); 400 401 /* 402 * Window Focus 403 */ 404 virtual WSError SetSystemSceneBlockingFocus(bool blocking); 405 bool GetBlockingFocus() const; 406 WSError SetFocusable(bool isFocusable); 407 bool GetFocusable() const; 408 void SetFocusedOnShow(bool focusedOnShow); // Used when creating ability 409 bool IsFocusedOnShow() const; 410 WSError SetFocusableOnShow(bool isFocusableOnShow); // Used when showing window 411 bool IsFocusableOnShow() const; 412 virtual void SetSystemFocusable(bool systemFocusable); // Used by SCB 413 bool GetSystemFocusable() const; 414 bool CheckFocusable() const; 415 void SetStartingBeforeVisible(bool isStartingBeforeVisible); 416 bool GetStartingBeforeVisible() const; 417 bool IsFocused() const; 418 bool GetFocused() const; 419 virtual WSError UpdateFocus(bool isFocused); 420 virtual void PresentFocusIfPointDown(); 421 WSError RequestFocus(bool isFocused) override; 422 void NotifyRequestFocusStatusNotifyManager(bool isFocused, bool byForeground = true, 423 FocusChangeReason reason = FocusChangeReason::DEFAULT); 424 void NotifyUIRequestFocus(); 425 virtual void NotifyUILostFocus(); 426 WSError NotifyFocusStatus(bool isFocused); 427 void SetExclusivelyHighlighted(bool isExclusivelyHighlighted); 428 virtual WSError UpdateHighlightStatus(bool isHighlight, bool needBlockHighlightNotify); 429 WSError NotifyHighlightChange(bool isHighlight); 430 WSError GetIsHighlighted(bool& isHighlighted) override; 431 432 /* 433 * Multi Window 434 */ 435 void SetIsMidScene(bool isMidScene); 436 bool GetIsMidScene() const; 437 WSError GetIsMidScene(bool& isMidScene) override; 438 439 /* 440 * Keyboard Window 441 */ 442 bool CheckEmptyKeyboardAvoidAreaIfNeeded() const; 443 void SetKeyboardStateChangeListener(const NotifyKeyboardStateChangeFunc& func); 444 445 bool IsSessionValid() const; 446 bool IsActive() const; 447 bool IsSystemActive() const; 448 bool IsSystemSession() const; 449 bool IsTerminated() const; 450 bool IsSessionForeground() const; IsAnco()451 virtual bool IsAnco() const { return false; } SetBlank(bool isAddBlank)452 virtual void SetBlank(bool isAddBlank) {}; GetBlank()453 virtual bool GetBlank() const { return false; } GetBufferAvailableCallbackEnable()454 virtual bool GetBufferAvailableCallbackEnable() const { return false; } 455 456 sptr<IRemoteObject> dialogTargetToken_ = nullptr; 457 int32_t GetWindowId() const; 458 void SetAppIndex(const int32_t appIndex); 459 int32_t GetAppIndex() const; 460 void SetCallingPid(int32_t id) REQUIRES(SCENE_GUARD); 461 void SetCallingUid(int32_t id); 462 int32_t GetCallingPid() const; 463 int32_t GetCallingUid() const; 464 void SetAbilityToken(sptr<IRemoteObject> token); 465 sptr<IRemoteObject> GetAbilityToken() const; 466 WindowMode GetWindowMode() const; 467 468 /* 469 * Window ZOrder 470 */ 471 virtual void SetZOrder(uint32_t zOrder); 472 uint32_t GetZOrder() const; 473 uint32_t GetLastZOrder() const; 474 475 void SetUINodeId(uint32_t uiNodeId); 476 uint32_t GetUINodeId() const; 477 virtual void SetFloatingScale(float floatingScale); 478 float GetFloatingScale() const; 479 virtual void SetScale(float scaleX, float scaleY, float pivotX, float pivotY); 480 float GetScaleX() const; 481 float GetScaleY() const; 482 float GetPivotX() const; 483 float GetPivotY() const; 484 void SetSCBKeepKeyboard(bool scbKeepKeyboardFlag); 485 bool GetSCBKeepKeyboardFlag() const; 486 487 void SetRaiseToAppTopForPointDownFunc(const NotifyRaiseToTopForPointDownFunc& func); 488 void SetFrameLayoutFinishListener(const NotifyFrameLayoutFinishFunc& func); 489 void NotifyScreenshot(); 490 void RemoveLifeCycleTask(const LifeCycleTaskType& taskType); 491 void PostLifeCycleTask(Task &&task, const std::string& name, const LifeCycleTaskType& taskType); 492 WSError UpdateMaximizeMode(bool isMaximize); 493 void NotifySessionForeground(uint32_t reason, bool withAnimation); 494 void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits); 495 void HandlePointDownDialog(); 496 bool CheckDialogOnForeground(); 497 std::shared_ptr<Media::PixelMap> GetSnapshotPixelMap(const float oriScale = 1.0f, const float newScale = 1.0f); GetTouchHotAreas()498 virtual std::vector<Rect> GetTouchHotAreas() const 499 { 500 return std::vector<Rect>(); 501 } 502 503 virtual void SetTouchHotAreas(const std::vector<Rect>& touchHotAreas); 504 SetVpr(float vpr)505 void SetVpr(float vpr) 506 { 507 vpr_ = vpr; 508 } 509 510 bool operator==(const Session* session) const 511 { 512 if (session == nullptr) { 513 return false; 514 } 515 return (persistentId_ == session->persistentId_ && callingPid_ == session->callingPid_); 516 } 517 518 bool operator!=(const Session* session) const 519 { 520 return !this->operator==(session); 521 } 522 523 const char* DumpPointerWindowArea(MMI::WindowArea area) const; 524 WSRectF UpdateHotRect(const WSRect& rect); 525 WSError RaiseToAppTopForPointDown(); 526 527 virtual void NotifyForegroundInteractiveStatus(bool interactive); 528 WSError UpdateTitleInTargetPos(bool isShow, int32_t height); 529 void SetNotifySystemSessionPointerEventFunc(const NotifySystemSessionPointerEventFunc& func); 530 void SetNotifySystemSessionKeyEventFunc(const NotifySystemSessionKeyEventFunc& func); 531 bool IsSystemInput(); 532 // ForegroundInteractiveStatus interface only for event use 533 bool GetForegroundInteractiveStatus() const; 534 virtual void SetForegroundInteractiveStatus(bool interactive); 535 536 /* 537 * Window Lifecycle 538 */ 539 bool GetIsPendingToBackgroundState() const; 540 void SetIsPendingToBackgroundState(bool isPendingToBackgroundState); 541 bool IsActivatedAfterScreenLocked() const; 542 void SetIsActivatedAfterScreenLocked(bool isActivatedAfterScreenLocked); 543 void SetAttachState(bool isAttach, WindowMode windowMode = WindowMode::WINDOW_MODE_UNDEFINED); 544 bool GetAttachState() const; 545 void RegisterDetachCallback(const sptr<IPatternDetachCallback>& callback); 546 void SetNeedNotifyAttachState(bool needNotify); 547 548 SystemSessionConfig GetSystemConfig() const; 549 void RectCheckProcess(); RectCheck(uint32_t curWidth,uint32_t curHeight)550 virtual void RectCheck(uint32_t curWidth, uint32_t curHeight) {}; 551 void RectSizeCheckProcess(uint32_t curWidth, uint32_t curHeight, uint32_t minWidth, 552 uint32_t minHeight, uint32_t maxFloatingWindowSize); 553 DetectTaskInfo GetDetectTaskInfo() const; 554 void SetDetectTaskInfo(const DetectTaskInfo& detectTaskInfo); 555 WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj); 556 void CreateWindowStateDetectTask(bool isAttach, WindowMode windowMode); 557 void RegisterIsScreenLockedCallback(const std::function<bool()>& callback); 558 std::string GetWindowDetectTaskName() const; 559 void RemoveWindowDetectTask(); 560 WSError SwitchFreeMultiWindow(bool enable); 561 CheckGetAvoidAreaAvailable(AvoidAreaType type)562 virtual bool CheckGetAvoidAreaAvailable(AvoidAreaType type) { return true; } 563 564 virtual bool IsVisibleForeground() const; 565 void SetIsStarting(bool isStarting); 566 void SetUIStateDirty(bool dirty); 567 void SetMainSessionUIStateDirty(bool dirty); 568 bool GetUIStateDirty() const; 569 static bool IsScbCoreEnabled(); 570 static void SetScbCoreEnabled(bool enabled); 571 bool IsVisible() const; IsNeedSyncScenePanelGlobalPosition()572 virtual bool IsNeedSyncScenePanelGlobalPosition() { return true; } 573 void SetAppInstanceKey(const std::string& appInstanceKey); 574 std::string GetAppInstanceKey() const; 575 576 /* 577 * Starting Window 578 */ 579 WSError RemoveStartingWindow() override; 580 void SetEnableRemoveStartingWindow(bool enableRemoveStartingWindow); 581 bool GetEnableRemoveStartingWindow() const; 582 void SetAppBufferReady(bool appBufferReady); 583 bool GetAppBufferReady() const; 584 void SetUseStartingWindowAboveLocked(bool useStartingWindowAboveLocked); 585 bool UseStartingWindowAboveLocked() const; 586 587 /* 588 * Window Hierarchy 589 */ 590 void ProcessClickModalWindowOutside(int32_t posX, int32_t posY); 591 void SetClickModalWindowOutsideListener(NotifyClickModalWindowOutsideFunc&& func); 592 593 /* 594 * Window Layout 595 */ 596 static bool IsBackgroundUpdateRectNotifyEnabled(); 597 static void SetBackgroundUpdateRectNotifyEnabled(const bool enabled); 598 void SetClientRect(const WSRect& rect); 599 WSRect GetClientRect() const; 600 void ResetDirtyFlags(); 601 void SetDragActivated(bool dragActivated); 602 void SetClientDragEnable(bool dragEnable); 603 std::optional<bool> GetClientDragEnable() const; 604 std::shared_ptr<AppExecFwk::EventHandler> GetEventHandler() const; 605 WSError UpdateClientDisplayId(DisplayId displayId); 606 DisplayId TransformGlobalRectToRelativeRect(WSRect& rect) const; 607 void UpdateClientRectPosYAndDisplayId(WSRect& rect); 608 bool IsDragAccessible() const; 609 void SetSingleHandTransform(const SingleHandTransform& transform); 610 SingleHandTransform GetSingleHandTransform() const; 611 void SetSingleHandModeFlag(bool flag); 612 bool SessionIsSingleHandMode(); 613 void SetClientDisplayId(DisplayId displayId); 614 DisplayId GetClientDisplayId() const; RegisterNotifySurfaceBoundsChangeFunc(int32_t sessionId,NotifySurfaceBoundsChangeFunc && func)615 virtual void RegisterNotifySurfaceBoundsChangeFunc(int32_t sessionId, NotifySurfaceBoundsChangeFunc&& func) {}; UnregisterNotifySurfaceBoundsChangeFunc(int32_t sessionId)616 virtual void UnregisterNotifySurfaceBoundsChangeFunc(int32_t sessionId) {}; 617 618 /* 619 * Screen Lock 620 */ 621 bool IsScreenLockWindow() const; 622 623 /* 624 * Free Multi Window 625 */ 626 std::shared_ptr<Media::PixelMap> SetFreezeImmediately(float scale, bool isFreeze, float blur) const; 627 628 /* 629 * PC Window 630 */ 631 sptr<Session> GetMainSession() const; 632 sptr<Session> GetMainOrFloatSession() const; 633 bool IsPcWindow() const; 634 bool IsAncestorsSession(int ancestorsId) const; 635 636 /** 637 * Window Property 638 */ 639 WindowUIInfo GetWindowUIInfoForWindowInfo() const; 640 WindowDisplayInfo GetWindowDisplayInfoForWindowInfo() const; 641 WindowLayoutInfo GetWindowLayoutInfoForWindowInfo() const; 642 WindowMetaInfo GetWindowMetaInfoForWindowInfo() const; 643 644 protected: 645 class SessionLifeCycleTask : public virtual RefBase { 646 public: SessionLifeCycleTask(const Task & task,const std::string & name,const LifeCycleTaskType & type)647 SessionLifeCycleTask(const Task& task, const std::string& name, const LifeCycleTaskType& type) 648 : task(task), name(name), type(type) {} 649 Task task; 650 const std::string name; 651 LifeCycleTaskType type; 652 std::chrono::steady_clock::time_point startTime = std::chrono::steady_clock::now(); 653 bool running = false; 654 }; 655 void StartLifeCycleTask(sptr<SessionLifeCycleTask> lifeCycleTask); 656 void GeneratePersistentId(bool isExtension, int32_t persistentId); 657 virtual void UpdateSessionState(SessionState state); 658 void NotifySessionStateChange(const SessionState& state); 659 void UpdateSessionTouchable(bool touchable); UpdateActiveStatus(bool isActive)660 virtual WSError UpdateActiveStatus(bool isActive) { return WSError::WS_OK; } 661 662 /* 663 * Gesture Back 664 */ UpdateGestureBackEnabled()665 virtual void UpdateGestureBackEnabled() {} 666 667 WSRectF UpdateTopBottomArea(const WSRectF& rect, MMI::WindowArea area); 668 WSRectF UpdateLeftRightArea(const WSRectF& rect, MMI::WindowArea area); 669 WSRectF UpdateInnerAngleArea(const WSRectF& rect, MMI::WindowArea area); 670 virtual void UpdatePointerArea(const WSRect& rect); 671 virtual bool CheckPointerEventDispatch(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const; 672 bool IsTopDialog() const; 673 void HandlePointDownDialog(int32_t pointAction); 674 void NotifySessionInfoChange(); 675 676 void PostTask(Task&& task, const std::string& name = "sessionTask", int64_t delayTime = 0); 677 void PostExportTask(Task&& task, const std::string& name = "sessionExportTask", int64_t delayTime = 0); 678 template<typename SyncTask, typename Return = std::invoke_result_t<SyncTask>> 679 Return PostSyncTask(SyncTask&& task, const std::string& name = "sessionTask") 680 { 681 Return ret; 682 if (!handler_ || handler_->GetEventRunner()->IsCurrentRunnerThread()) { 683 StartTraceForSyncTask(name); 684 ret = task(); 685 FinishTraceForSyncTask(); 686 return ret; 687 } 688 auto syncTask = [&ret, &task, &name] { 689 StartTraceForSyncTask(name); 690 ret = task(); 691 FinishTraceForSyncTask(); 692 }; 693 handler_->PostSyncTask(std::move(syncTask), name, AppExecFwk::EventQueue::Priority::IMMEDIATE); 694 return ret; 695 } 696 697 /* 698 * Window Layout 699 */ 700 void SetClientScale(float scaleX, float scaleY, float pivotX, float pivotY); 701 702 static std::shared_ptr<AppExecFwk::EventHandler> mainHandler_; 703 int32_t persistentId_ = INVALID_SESSION_ID; 704 std::atomic<SessionState> state_ = SessionState::STATE_DISCONNECT; 705 SessionInfo sessionInfo_; 706 std::recursive_mutex sessionInfoMutex_; 707 mutable std::mutex surfaceNodeMutex_; 708 std::shared_ptr<RSSurfaceNode> surfaceNode_; 709 mutable std::mutex snapshotMutex_; 710 std::shared_ptr<Media::PixelMap> snapshot_; 711 sptr<ISessionStage> sessionStage_; 712 std::mutex lifeCycleTaskQueueMutex_; 713 std::list<sptr<SessionLifeCycleTask>> lifeCycleTaskQueue_; 714 bool isActive_ = false; 715 bool isSystemActive_ = false; 716 mutable std::mutex globalRectMutex_; 717 WSRectF bounds_; 718 Rotation rotation_; 719 float offsetX_ = 0.0f; 720 float offsetY_ = 0.0f; 721 std::atomic_bool isExitSplitOnBackground_ = false; 722 bool isVisible_ = false; 723 724 NotifyChangeSessionVisibilityWithStatusBarFunc changeSessionVisibilityWithStatusBarFunc_; 725 NotifySessionStateChangeFunc sessionStateChangeFunc_; 726 NotifyBufferAvailableChangeFunc bufferAvailableChangeFunc_; 727 NotifySessionInfoChangeNotifyManagerFunc sessionInfoChangeNotifyManagerFunc_; 728 NotifySessionStateChangeNotifyManagerFunc sessionStateChangeNotifyManagerFunc_; 729 NotifyRequestFocusStatusNotifyManagerFunc requestFocusStatusNotifyManagerFunc_; 730 NotifyUIRequestFocusFunc requestFocusFunc_; 731 NotifyUILostFocusFunc lostFocusFunc_; 732 GetStateFromManagerFunc getStateFromManagerFunc_; 733 NotifySessionFocusableChangeFunc sessionFocusableChangeFunc_; 734 NotifySessionTouchableChangeFunc sessionTouchableChangeFunc_; 735 NotifyClickFunc clickFunc_; 736 NofitySessionLabelUpdatedFunc updateSessionLabelFunc_; 737 NofitySessionIconUpdatedFunc updateSessionIconFunc_; 738 NotifySessionSnapshotFunc notifySessionSnapshotFunc_; 739 NotifyRaiseToTopForPointDownFunc raiseToTopForPointDownFunc_; 740 NotifySessionInfoLockedStateChangeFunc sessionInfoLockedStateChangeFunc_; 741 NotifySystemSessionPointerEventFunc systemSessionPointerEventFunc_; 742 NotifySystemSessionKeyEventFunc systemSessionKeyEventFunc_; 743 NotifyContextTransparentFunc contextTransparentFunc_; 744 NotifyFrameLayoutFinishFunc frameLayoutFinishFunc_; 745 std::mutex highlightChangeFuncMutex_; 746 NotifyHighlightChangeFunc highlightChangeFunc_; 747 748 /* 749 * Window LifeCycle 750 */ 751 NotifyPendingSessionActivationFunc pendingSessionActivationFunc_; 752 NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; 753 NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; 754 NotifyBackPressedFunc backPressedFunc_; 755 NotifyTerminateSessionFunc terminateSessionFunc_; 756 NotifyTerminateSessionFuncNew terminateSessionFuncNew_; 757 NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; 758 NotifySessionExceptionFunc sessionExceptionFunc_; 759 NotifySessionExceptionFunc jsSceneSessionExceptionFunc_; 760 VisibilityChangedDetectFunc visibilityChangedDetectFunc_ GUARDED_BY(SCENE_GUARD); 761 NofitySessionLabelAndIconUpdatedFunc updateSessionLabelAndIconFunc_; 762 763 /* 764 * Window Rotate Animation 765 */ 766 AcquireRotateAnimationConfigFunc acquireRotateAnimationConfigFunc_; 767 768 SystemSessionConfig systemConfig_; 769 bool needSnapshot_ = false; 770 float snapshotScale_ = 0.5; 771 sptr<ScenePersistence> scenePersistence_ = nullptr; 772 773 /* 774 * Window Layout 775 */ 776 static bool isBackgroundUpdateRectNotifyEnabled_; 777 RequestVsyncFunc requestNextVsyncFunc_; 778 WSRect winRect_; 779 WSRect clientRect_; // rect saved when prelayout or notify client to update rect 780 WSRect lastLayoutRect_; // rect saved when go background 781 WSRect layoutRect_; // rect of root view 782 WSRect globalRect_; // globalRect include translate 783 SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; 784 NotifySessionRectChangeFunc sessionRectChangeFunc_; 785 NotifySessionDisplayIdChangeFunc sessionDisplayIdChangeFunc_; 786 float clientScaleX_ = 1.0f; 787 float clientScaleY_ = 1.0f; 788 float clientPivotX_ = 0.0f; 789 float clientPivotY_ = 0.0f; 790 DisplayId clientDisplayId_ = 0; // Window displayId on the client 791 DisplayId configDisplayId_ = DISPLAY_ID_INVALID; 792 SuperFoldStatus lastScreenFoldStatus_ = SuperFoldStatus::UNKNOWN; 793 794 /* 795 * Window ZOrder 796 */ 797 uint32_t zOrder_ = 0; 798 uint32_t lastZOrder_ = 0; 799 800 /* 801 * Window Focus 802 */ 803 bool isFocused_ = false; 804 bool blockingFocus_ { false }; 805 bool isHighlighted_ { false }; 806 807 uint32_t uiNodeId_ = 0; 808 float aspectRatio_ = 0.0f; 809 std::map<MMI::WindowArea, WSRectF> windowAreas_; 810 bool isTerminating_ = false; 811 float floatingScale_ = 1.0f; 812 float scaleX_ = 1.0f; 813 float scaleY_ = 1.0f; 814 float pivotX_ = 0.0f; 815 float pivotY_ = 0.0f; 816 bool scbKeepKeyboardFlag_ = false; 817 mutable std::shared_mutex dialogVecMutex_; 818 std::vector<sptr<Session>> dialogVec_; 819 mutable std::shared_mutex parentSessionMutex_; 820 sptr<Session> parentSession_; 821 sptr<IWindowEventChannel> windowEventChannel_; 822 823 mutable std::mutex pointerEventMutex_; 824 mutable std::shared_mutex keyEventMutex_; 825 bool rectChangeListenerRegistered_ = false; 826 827 /* 828 * Window Hierarchy 829 */ 830 NotifyClickModalWindowOutsideFunc clickModalWindowOutsideFunc_; 831 832 /* 833 * Window Pipeline 834 */ 835 uint32_t dirtyFlags_ = 0; // only accessed on SSM thread 836 bool isNeedSyncSessionRect_ { true }; // where need sync to session rect, currently use in split drag 837 bool isStarting_ = false; // when start app, session is starting state until foreground 838 std::atomic_bool mainUIStateDirty_ = false; 839 static bool isScbCoreEnabled_; 840 841 /* 842 * Keyboard Window 843 */ 844 NotifyKeyboardStateChangeFunc keyboardStateChangeFunc_; 845 846 private: 847 void HandleDialogForeground(); 848 void HandleDialogBackground(); 849 WSError HandleSubWindowClick(int32_t action, bool isExecuteDelayRaise = false); 850 851 template<typename T> 852 bool RegisterListenerLocked(std::vector<std::shared_ptr<T>>& holder, const std::shared_ptr<T>& listener); 853 template<typename T> 854 bool UnregisterListenerLocked(std::vector<std::shared_ptr<T>>& holder, const std::shared_ptr<T>& listener); 855 bool IsStateMatch(bool isAttach) const; 856 bool IsSupportDetectWindow(bool isAttach); 857 bool ShouldCreateDetectTask(bool isAttach, WindowMode windowMode) const; 858 bool ShouldCreateDetectTaskInRecent(bool newShowRecent, bool oldShowRecent, bool isAttach) const; 859 void CreateDetectStateTask(bool isAttach, WindowMode windowMode); 860 861 /* 862 * Window Rotate Animation 863 */ 864 int32_t GetRotateAnimationDuration(); 865 866 /* 867 * Window Property 868 */ 869 void InitSessionPropertyWhenConnect(const sptr<WindowSessionProperty>& property); 870 void InitSystemSessionDragEnable(const sptr<WindowSessionProperty>& property); 871 872 void UpdateGravityWhenUpdateWindowMode(WindowMode mode); 873 874 template<typename T1, typename T2, typename Ret> 875 using EnableIfSame = typename std::enable_if<std::is_same_v<T1, T2>, Ret>::type; 876 template<typename T> GetListeners()877 inline EnableIfSame<T, ILifecycleListener, std::vector<std::weak_ptr<ILifecycleListener>>> GetListeners() 878 { 879 std::vector<std::weak_ptr<ILifecycleListener>> lifecycleListeners; 880 { 881 std::lock_guard<std::recursive_mutex> lock(lifecycleListenersMutex_); 882 for (auto& listener : lifecycleListeners_) { 883 lifecycleListeners.push_back(listener); 884 } 885 } 886 return lifecycleListeners; 887 } 888 889 std::recursive_mutex lifecycleListenersMutex_; 890 std::vector<std::shared_ptr<ILifecycleListener>> lifecycleListeners_; 891 std::shared_ptr<AppExecFwk::EventHandler> handler_; 892 std::shared_ptr<AppExecFwk::EventHandler> exportHandler_; 893 std::function<bool()> isScreenLockedCallback_; 894 895 sptr<WindowSessionProperty> property_; 896 897 /* 898 * Window Focus 899 */ 900 mutable std::shared_mutex uiRequestFocusMutex_; 901 mutable std::shared_mutex uiLostFocusMutex_; 902 bool focusedOnShow_ = true; 903 std::atomic_bool systemFocusable_ = true; 904 bool focusableOnShow_ = true; // if false, ignore request focus when session onAttach 905 bool isStartingBeforeVisible_ = false; 906 907 bool showRecent_ = false; 908 bool bufferAvailable_ = false; 909 910 /* 911 * Multi Window 912 */ 913 bool isMidScene_ = false; 914 915 WSRect preRect_; 916 int32_t callingPid_ = -1; 917 int32_t callingUid_ = -1; 918 int32_t appIndex_ = { 0 }; 919 std::string callingBundleName_ { "unknown" }; 920 bool isRSVisible_ {false}; 921 WindowVisibilityState visibilityState_ { WINDOW_LAYER_STATE_MAX}; 922 bool needNotify_ {true}; 923 bool isRSDrawing_ {false}; 924 sptr<IRemoteObject> abilityToken_ = nullptr; 925 float vpr_ { 1.5f }; 926 bool forceTouchable_ { true }; 927 bool systemTouchable_ { true }; 928 std::atomic_bool foregroundInteractiveStatus_ { true }; 929 930 /* 931 * Window Lifecycle 932 */ 933 void RecordWindowStateAttachExceptionEvent(bool isAttached); 934 935 std::atomic<bool> isAttach_ { false }; 936 std::atomic<bool> isPendingToBackgroundState_ { false }; 937 std::atomic<bool> isActivatedAfterScreenLocked_ { true }; 938 sptr<IPatternDetachCallback> detachCallback_ = nullptr; 939 940 std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode_; 941 mutable std::mutex leashWinSurfaceNodeMutex_; 942 DetectTaskInfo detectTaskInfo_; 943 mutable std::shared_mutex detectTaskInfoMutex_; 944 945 /* 946 * Starting Window 947 */ 948 bool enableRemoveStartingWindow_ { false }; 949 bool appBufferReady_ { false }; 950 bool useStartingWindowAboveLocked_ { false }; 951 952 /* 953 * Window Layout 954 */ 955 std::optional<bool> clientDragEnable_; 956 bool dragActivated_ = true; 957 SingleHandTransform singleHandTransform_; 958 bool singleHandModeFlag_ = false; 959 SingleHandScreenInfo singleHandScreenInfo_; 960 961 /* 962 * Screen Lock 963 */ 964 bool isScreenLockWindow_ { false }; 965 966 /* 967 * Window Scene Snapshot 968 */ 969 Task saveSnapshotCallback_ = []() {}; 970 Task removeSnapshotCallback_ = []() {}; 971 std::mutex saveSnapshotCallbackMutex_; 972 std::mutex removeSnapshotCallbackMutex_; 973 std::atomic<bool> needNotifyAttachState_ = { false }; 974 }; 975 } // namespace OHOS::Rosen 976 977 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_H