• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SCENE_SESSION_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H
18 
19 #include <animation/rs_animation_timing_curve.h>
20 #include <animation/rs_animation_timing_protocol.h>
21 #include <animation/rs_symbol_animation.h>
22 #include <pipeline/rs_node_map.h>
23 #include <modifier/rs_property.h>
24 #include <modifier/rs_property_modifier.h>
25 
26 #include "display_manager.h"
27 #include "session/host/include/session.h"
28 #include "session/host/include/move_drag_controller.h"
29 #include "session/host/include/pc_fold_screen_controller.h"
30 #include "vsync_station.h"
31 #include "wm_common.h"
32 
33 namespace OHOS::PowerMgr {
34 class RunningLock;
35 }
36 
37 namespace OHOS::Rosen {
38 namespace PARAM_KEY {
39 const std::string PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity";
40 const std::string PARAM_DMS_CONTINUE_SESSION_ID_KEY = "ohos.dms.continueSessionId";
41 const std::string PARAM_DMS_PERSISTENT_ID_KEY = "ohos.dms.persistentId";
42 }
43 
44 class SceneSession;
45 
46 using NotifySessionLockStateChangeCallback = std::function<void(bool isLockedState)>;
47 using SpecificSessionCreateCallback =
48   std::function<sptr<SceneSession>(const SessionInfo& info, sptr<WindowSessionProperty> property)>;
49 using SpecificSessionDestroyCallback = std::function<WSError(const int32_t& persistentId)>;
50 using CameraFloatSessionChangeCallback = std::function<void(uint32_t accessTokenId, bool isShowing)>;
51 using GetSceneSessionVectorByTypeAndDisplayIdCallback = std::function<std::vector<sptr<SceneSession>>(
52     WindowType type, DisplayId displayId)>;
53 using GetSceneSessionVectorByTypeCallback = std::function<std::vector<sptr<SceneSession>>(WindowType type)>;
54 using UpdateAvoidAreaCallback = std::function<void(int32_t persistentId)>;
55 using UpdateOccupiedAreaIfNeedCallback = std::function<void(int32_t persistentId)>;
56 using NotifyWindowInfoUpdateCallback = std::function<void(int32_t persistentId, WindowUpdateType type)>;
57 using NotifyWindowPidChangeCallback = std::function<void(int32_t windowId, bool startMoving)>;
58 using NotifySessionTouchOutsideCallback = std::function<void(int32_t persistentId)>;
59 using GetAINavigationBarArea = std::function<WSRect(uint64_t displayId)>;
60 using RecoveryCallback = std::function<void(int32_t persistentId, Rect rect)>;
61 using NotifyBindDialogSessionFunc = std::function<void(const sptr<SceneSession>& session)>;
62 using NotifySessionPiPControlStatusChangeFunc = std::function<void(WsPiPControlType controlType,
63     WsPiPControlStatus status)>;
64 using NotifyAutoStartPiPStatusChangeFunc = std::function<void(bool isAutoStart, uint32_t priority,
65     uint32_t width, uint32_t height)>;
66 using NotifySessionEventFunc = std::function<void(int32_t eventId, SessionEventParam param)>;
67 using NotifySessionTopmostChangeFunc = std::function<void(const bool topmost)>;
68 using NotifySubSessionZLevelChangeFunc = std::function<void(const int32_t zLevel)>;
69 using NotifySubModalTypeChangeFunc = std::function<void(SubWindowModalType subWindowModalType)>;
70 using NotifyMainModalTypeChangeFunc = std::function<void(bool isModal)>;
71 using NotifyRaiseToTopFunc = std::function<void()>;
72 using SetWindowPatternOpacityFunc = std::function<void(float opacity)>;
73 using NotifyIsCustomAnimationPlayingCallback = std::function<void(bool isFinish)>;
74 using NotifyWindowAnimationFlagChangeFunc = std::function<void(const bool flag)>;
75 using NotifySystemBarPropertyChangeFunc = std::function<void(
76     const std::unordered_map<WindowType, SystemBarProperty>& propertyMap)>;
77 using NotifyNeedAvoidFunc = std::function<void(bool status)>;
78 using NotifyShowWhenLockedFunc = std::function<void(bool showWhenLocked)>;
79 using NotifyReqOrientationChangeFunc = std::function<void(uint32_t orientation)>;
80 using NotifyRaiseAboveTargetFunc = std::function<void(int32_t subWindowId)>;
81 using NotifyForceHideChangeFunc = std::function<void(bool hide)>;
82 using NotifyTouchOutsideFunc = std::function<void()>;
83 using ClearCallbackMapFunc = std::function<void(bool needRemove)>;
84 using NotifyPrepareClosePiPSessionFunc = std::function<void()>;
85 using OnOutsideDownEvent = std::function<void(int32_t x, int32_t y)>;
86 using HandleSecureSessionShouldHideCallback = std::function<WSError(const sptr<SceneSession>& sceneSession)>;
87 using ClearDisplayStatusBarTemporarilyFlags = std::function<void()>;
88 using CameraSessionChangeCallback = std::function<void(uint32_t accessTokenId, bool isShowing)>;
89 using NotifyLandscapeMultiWindowSessionFunc = std::function<void(bool isLandscapeMultiWindow)>;
90 using NotifyKeyboardLayoutAdjustFunc = std::function<void(const KeyboardLayoutParams& params)>;
91 using NotifyKeyboarViewModeChangeFunc = std::function<void(const KeyboardViewMode& mode)>;
92 using SessionChangeByActionNotifyManagerFunc = std::function<void(const sptr<SceneSession>& sceneSession,
93     const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action)>;
94 using NotifyLayoutFullScreenChangeFunc = std::function<void(bool isLayoutFullScreen)>;
95 using NotifyDefaultDensityEnabledFunc = std::function<void(bool isDefaultDensityEnabled)>;
96 using NotifyTitleAndDockHoverShowChangeFunc = std::function<void(bool isTitleHoverShown,
97     bool isDockHoverShown)>;
98 using NotifyRestoreMainWindowFunc = std::function<void()>;
99 using SetSkipSelfWhenShowOnVirtualScreenCallback = std::function<void(uint64_t surfaceNodeId, bool isSkip)>;
100 using NotifyForceSplitFunc = std::function<AppForceLandscapeConfig(const std::string& bundleName)>;
101 using UpdatePrivateStateAndNotifyFunc = std::function<void(int32_t persistentId)>;
102 using PiPStateChangeCallback = std::function<void(const std::string& bundleName, bool isForeground)>;
103 using NotifyMainWindowTopmostChangeFunc = std::function<void(bool isTopmost)>;
104 using GetConstrainedModalExtWindowInfoFunc =
105     std::function<std::optional<ExtensionWindowEventInfo>(const sptr<SceneSession>& sceneSession)>;
106 using NotifyPrivacyModeChangeFunc = std::function<void(bool isPrivacyMode)>;
107 using UpdateGestureBackEnabledCallback = std::function<void(int32_t persistentId)>;
108 using NotifyVisibleChangeFunc = std::function<void(int32_t persistentId)>;
109 using IsLastFrameLayoutFinishedFunc = std::function<WSError(bool& isLayoutFinished)>;
110 using IsAINavigationBarAvoidAreaValidFunc = std::function<bool(const AvoidArea& avoidArea, int32_t sessionBottom)>;
111 using GetStatusBarDefaultVisibilityByDisplayIdFunc = std::function<bool(DisplayId displayId)>;
112 using NotifySetWindowRectAutoSaveFunc = std::function<void(bool enabled, bool isSaveBySpecifiedFlag)>;
113 using UpdateAppUseControlFunc = std::function<void(ControlAppType type, bool isNeedControl, bool isControlRecentOnly)>;
114 using NotifyAvoidAreaChangeCallback = std::function<void(const sptr<AvoidArea>& avoidArea, AvoidAreaType type)>;
115 using NotifySetSupportedWindowModesFunc = std::function<void(
116     std::vector<AppExecFwk::SupportWindowMode>&& supportedWindowModes)>;
117 using GetStatusBarAvoidHeightFunc = std::function<void(WSRect& barArea)>;
118 using GetStatusBarConstantlyShowFunc = std::function<void(DisplayId displayId, bool& isVisible)>;
119 using NotifySetWindowCornerRadiusFunc = std::function<void(float cornerRadius)>;
120 using NotifyFollowParentRectFunc = std::function<void(bool isFollow)>;
121 using GetSceneSessionByIdCallback = std::function<sptr<SceneSession>(int32_t sessionId)>;
122 using NotifySetParentSessionFunc = std::function<void(int32_t oldParentWindowId, int32_t newParentWindowId)>;
123 using NotifyUpdateFlagFunc = std::function<void(const std::string& flag)>;
124 
125 struct UIExtensionTokenInfo {
126     bool canShowOnLockScreen { false };
127     uint32_t callingTokenId { 0 };
128     sptr<IRemoteObject> abilityToken;
129 };
130 
131 class SceneSession : public Session {
132 public:
133     friend class HidumpController;
134     friend class PcFoldScreenController;
135     // callback for notify SceneSessionManager
136     struct SpecificSessionCallback : public RefBase {
137         SpecificSessionCreateCallback onCreate_;
138         SpecificSessionDestroyCallback onDestroy_;
139         ClearDisplayStatusBarTemporarilyFlags onClearDisplayStatusBarTemporarilyFlags_;
140         CameraFloatSessionChangeCallback onCameraFloatSessionChange_;
141         GetSceneSessionVectorByTypeAndDisplayIdCallback onGetSceneSessionVectorByTypeAndDisplayId_;
142         GetSceneSessionVectorByTypeCallback onGetSceneSessionVectorByType_;
143         UpdateAvoidAreaCallback onUpdateAvoidArea_;
144         GetStatusBarDefaultVisibilityByDisplayIdFunc onGetStatusBarDefaultVisibilityByDisplayId_;
145         UpdateOccupiedAreaIfNeedCallback onUpdateOccupiedAreaIfNeed_;
146         NotifyWindowInfoUpdateCallback onWindowInfoUpdate_;
147         NotifyWindowPidChangeCallback onWindowInputPidChangeCallback_;
148         NotifySessionTouchOutsideCallback onSessionTouchOutside_;
149         GetAINavigationBarArea onGetAINavigationBarArea_;
150         OnOutsideDownEvent onOutsideDownEvent_;
151         HandleSecureSessionShouldHideCallback onHandleSecureSessionShouldHide_;
152         CameraSessionChangeCallback onCameraSessionChange_;
153         SetSkipSelfWhenShowOnVirtualScreenCallback onSetSkipSelfWhenShowOnVirtualScreen_;
154         PiPStateChangeCallback onPiPStateChange_;
155         UpdateGestureBackEnabledCallback onUpdateGestureBackEnabled_;
156         NotifyAvoidAreaChangeCallback onNotifyAvoidAreaChange_;
157         GetSceneSessionByIdCallback onGetSceneSessionByIdCallback_;
158     };
159 
160     // func for change window scene pattern property
161     struct SetWindowScenePatternFunc : public RefBase {
162         SetWindowPatternOpacityFunc setOpacityFunc_;
163     };
164 
165     struct ControlInfo {
166         bool isNeedControl;
167         bool isControlRecentOnly;
168     };
169 
170     SceneSession(const SessionInfo& info, const sptr<SpecificSessionCallback>& specificCallback);
171     virtual ~SceneSession();
172 
173     WSError Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
174         const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
175         sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr,
176         const std::string& identityToken = "") override;
177     WSError ConnectInner(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
178         const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
179         sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr,
180         int32_t pid = -1, int32_t uid = -1, const std::string& identityToken = "") override;
181     WSError Foreground(sptr<WindowSessionProperty> property, bool isFromClient = false,
182         const std::string& identityToken = "") override;
183     WSError Background(bool isFromClient = false, const std::string& identityToken = "") override;
184     WSError BackgroundTask(const bool isSaveSnapshot = true);
185     WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override;
186     WSError DisconnectTask(bool isFromClient = false, bool isSaveSnapshot = true);
187     void SetClientIdentityToken(const std::string& clientIdentityToken);
BindKeyboardPanelSession(sptr<SceneSession> panelSession)188     virtual void BindKeyboardPanelSession(sptr<SceneSession> panelSession) {};
GetKeyboardPanelSession()189     virtual sptr<SceneSession> GetKeyboardPanelSession() const { return nullptr; };
BindKeyboardSession(sptr<SceneSession> session)190     virtual void BindKeyboardSession(sptr<SceneSession> session) {};
GetKeyboardSession()191     virtual sptr<SceneSession> GetKeyboardSession() const { return nullptr; };
GetKeyboardGravity()192     virtual SessionGravity GetKeyboardGravity() const { return SessionGravity::SESSION_GRAVITY_DEFAULT; };
OnKeyboardPanelUpdated()193     virtual void OnKeyboardPanelUpdated() {};
OnCallingSessionUpdated()194     virtual void OnCallingSessionUpdated() {};
GetCallingSessionId()195     virtual uint32_t GetCallingSessionId() { return INVALID_SESSION_ID; };
196     bool GetScreenWidthAndHeightFromServer(const sptr<WindowSessionProperty>& sessionProperty,
197         uint32_t& screenWidth, uint32_t& screenHeight);
198     bool GetScreenWidthAndHeightFromClient(const sptr<WindowSessionProperty>& sessionProperty,
199         uint32_t& screenWidth, uint32_t& screenHeight);
200     sptr<SceneSession> GetSceneSessionById(int32_t sessionId) const;
201 
202     WSError UpdateActiveStatus(bool isActive) override;
203     WSError OnSessionEvent(SessionEvent event) override;
204     WSError SyncSessionEvent(SessionEvent event) override;
205     WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) override;
206     WSError RaiseToAppTop() override;
207 
208     /*
209      * Window Recover
210      */
211     virtual WSError Reconnect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
212         const std::shared_ptr<RSSurfaceNode>& surfaceNode, sptr<WindowSessionProperty> property = nullptr,
213         sptr<IRemoteObject> token = nullptr, int32_t pid = -1, int32_t uid = -1);
214     WSError ReconnectInner(sptr<WindowSessionProperty> property) REQUIRES(SCENE_GUARD);
IsRecovered()215     bool IsRecovered() const { return isRecovered_; }
SetRecovered(bool isRecovered)216     void SetRecovered(bool isRecovered) { isRecovered_ = isRecovered; }
217 
218     /*
219      * Window Layout
220      */
221     WSError UpdateSizeChangeReason(SizeChangeReason reason) override;
222     WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
223         const std::string& updateReason, const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
224     WSError UpdateSessionRect(const WSRect& rect, SizeChangeReason reason, bool isGlobal = false,
225         bool isFromMoveToGlobal = false, const MoveConfiguration& moveConfiguration = {},
226         const RectAnimationConfig& rectAnimationConfig = {}) override;
227     WSError UpdateClientRect(const WSRect& rect) override;
228     void NotifySingleHandTransformChange(const SingleHandTransform& singleHandTransform);
229     WSRect GetSessionGlobalRectWithSingleHandScale();
230     void UpdateSessionState(SessionState state) override;
231     WSError NotifyClientToUpdateRect(const std::string& updateReason,
232         std::shared_ptr<RSTransaction> rsTransaction) override;
233     void SetWinRectWhenUpdateRect(const WSRect& rect);
234     void RegisterNotifySurfaceBoundsChangeFunc(int32_t sessionId, NotifySurfaceBoundsChangeFunc&& func) override;
235     void UnregisterNotifySurfaceBoundsChangeFunc(int32_t sessionId) override;
236 
OpenKeyboardSyncTransaction()237     virtual void OpenKeyboardSyncTransaction() {}
CloseKeyboardSyncTransaction(const WSRect & keyboardPanelRect,bool isKeyboardShow,bool isRotating)238     virtual void CloseKeyboardSyncTransaction(const WSRect& keyboardPanelRect,
239         bool isKeyboardShow, bool isRotating) {}
240     WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> info, bool visible) override;
241     WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> info) override;
242     bool DisallowActivationFromPendingBackground(bool isPcOrPadEnableActivation, bool isFoundationCall,
243         bool canStartAbilityFromBackground, bool isFromAncoAndToAnco);
244     WSError TerminateSession(const sptr<AAFwk::SessionInfo> info) override;
245     WSError NotifySessionException(
246         const sptr<AAFwk::SessionInfo> info, const ExceptionInfo& exceptionInfo) override;
247     WSError NotifySessionExceptionInner(
248         const sptr<AAFwk::SessionInfo> info, const ExceptionInfo& exceptionInfo,
249         bool isFromClient = false, bool startFail = false);
250 
251     WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
252         bool needNotifyClient = true, bool isExecuteDelayRaise = false) override;
253     WSError TransferPointerEventInner(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
254         bool needNotifyClient = true, bool isExecuteDelayRaise = false);
255     WSError RequestSessionBack(bool needMoveToBackground) override;
256     WSError SetAspectRatio(float ratio) override;
257     WSError SetGlobalMaximizeMode(MaximizeMode mode) override;
258     WSError GetGlobalMaximizeMode(MaximizeMode& mode) override;
259     WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override;
260     WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override;
261     void SetZOrder(uint32_t zOrder) override;
262     std::vector<Rect> GetTouchHotAreas() const override;
263     void NotifyUILostFocus() override;
264     void SetScale(float scaleX, float scaleY, float pivotX, float pivotY) override;
265     void SetFloatingScale(float floatingScale) override;
266     WSError RaiseAboveTarget(int32_t subWindowId) override;
267 
268     /*
269      * PiP Window
270      */
271     PiPTemplateInfo GetPiPTemplateInfo() const;
272     void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo);
273     WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override;
274     WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status) override;
275     WSError SetAutoStartPiP(bool isAutoStart, uint32_t priority, uint32_t width, uint32_t height) override;
276     void NotifyPiPWindowPrepareClose() override;
277     void SetSessionPiPControlStatusChangeCallback(const NotifySessionPiPControlStatusChangeFunc& func);
278     void SetAutoStartPiPStatusChangeCallback(const NotifyAutoStartPiPStatusChangeFunc& func);
279     WSError SetPipActionEvent(const std::string& action, int32_t status);
280     WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status);
281     WSError NotifyPipWindowSizeChange(double width, double height, double scale);
282     void RegisterProcessPrepareClosePiPCallback(NotifyPrepareClosePiPSessionFunc&& callback);
283 
284     void RequestHideKeyboard(bool isAppColdStart = false);
285     WSError ProcessPointDownSession(int32_t posX, int32_t posY) override;
286     WSError SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
287         bool isExecuteDelayRaise = false) override;
288     void NotifyOutsideDownEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
289     WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect) override;
290     void SetForegroundInteractiveStatus(bool interactive) override;
291     WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override;
292 
293     /*
294      * Window Layout
295      */
296     WMError ActivateDragBySystem(bool activateDrag);
297     WMError SetSystemWindowEnableDrag(bool enableDrag) override;
298     WMError SetWindowEnableDragBySystem(bool enableDrag);
299     WSError OnDefaultDensityEnabled(bool isDefaultDensityEnabled) override;
300     void RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback);
301     void SetSessionDisplayIdChangeCallback(NotifySessionDisplayIdChangeFunc&& func);
302 
303     WSError SetKeepScreenOn(bool keepScreenOn);
304     WSError SetViewKeepScreenOn(bool keepScreenOn);
305     void SetParentPersistentId(int32_t parentId);
306     WSError SetTurnScreenOn(bool turnScreenOn);
307     void SetPrivacyMode(bool isPrivacy);
308     WMError SetSnapshotSkip(bool isSkip);
309     void SetSystemSceneOcclusionAlpha(double alpha);
310     void ResetOcclusionAlpha();
311     void SetSystemSceneForceUIFirst(bool forceUIFirst);
312     void SetUIFirstSwitch(RSUIFirstSwitch uiFirstSwitch);
313     void MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled);
314     void SetRequestedOrientation(Orientation orientation);
315     WSError SetDefaultRequestedOrientation(Orientation orientation);
316     void SetWindowAnimationFlag(bool needDefaultAnimationFlag);
317     void SetCollaboratorType(int32_t collaboratorType);
318     void SetLastSafeRect(WSRect rect);
319     void SetMovable(bool isMovable);
320     void SetOriPosYBeforeRaisedByKeyboard(int32_t posY);
321     void SetColorSpace(ColorSpace colorSpace);
322 
323     /*
324      * Window Hierarchy
325      */
SetTopmost(bool topmost)326     virtual WSError SetTopmost(bool topmost) { return WSError::WS_ERROR_INVALID_CALLING; }
IsTopmost()327     virtual bool IsTopmost() const { return false; }
SetMainWindowTopmost(bool isTopmost)328     virtual WSError SetMainWindowTopmost(bool isTopmost) { return WSError::WS_ERROR_INVALID_CALLING; }
IsMainWindowTopmost()329     virtual bool IsMainWindowTopmost() const { return false; }
SetSubWindowZLevel(int32_t zLevel)330     virtual WSError SetSubWindowZLevel(int32_t zLevel) { return WSError::WS_ERROR_INVALID_CALLING; }
GetSubWindowZLevel()331     virtual int32_t GetSubWindowZLevel() const { return 0; }
332     void SetMainWindowTopmostChangeCallback(NotifyMainWindowTopmostChangeFunc&& func);
333 
334     /*
335      * PC Window
336      */
337     void SetTitleAndDockHoverShowChangeCallback(NotifyTitleAndDockHoverShowChangeFunc&& func);
338     void SetRestoreMainWindowCallback(NotifyRestoreMainWindowFunc&& func);
339     void SetWindowRectAutoSaveCallback(NotifySetWindowRectAutoSaveFunc&& func);
IsModal()340     virtual bool IsModal() const { return false; }
IsApplicationModal()341     virtual bool IsApplicationModal() const { return false; }
342     bool IsDialogWindow() const;
343     WSError NotifySubModalTypeChange(SubWindowModalType subWindowModalType) override;
344     void RegisterSubModalTypeChangeCallback(NotifySubModalTypeChangeFunc&& func);
345     void RegisterMainModalTypeChangeCallback(NotifyMainModalTypeChangeFunc&& func);
346     void RegisterSupportWindowModesCallback(NotifySetSupportedWindowModesFunc&& func);
347     void CloneWindow(NodeId surfaceNodeId);
348     void AddSidebarBlur();
349     void AddRSNodeModifier(bool isDark, const std::shared_ptr<RSBaseNode>& rsNode);
350     void SetSidebarBlur(bool isDefaultSidebarBlur);
351     void ModifyRSAnimatableProperty(bool isDefaultSidebarBlur, bool isDark);
352     WSError UpdateDensity();
353     void UpdateNewSizeForPCWindow();
354     bool CalcNewWindowRectIfNeed(DMRect& availableArea, float newVpr);
355     bool IsPrimaryDisplay() const;
356     void SaveLastDensity();
IsFollowParentMultiScreenPolicy()357     virtual bool IsFollowParentMultiScreenPolicy() const { return false; }
358     void NotifyUpdateFlagCallback(NotifyUpdateFlagFunc&& func);
359 
360     /*
361      * PC Window Layout
362      */
363     void SetIsLayoutFullScreen(bool isLayoutFullScreen);
364     bool IsLayoutFullScreen() const;
365     WSError StartMovingWithCoordinate(int32_t offsetX, int32_t offsetY,
366         int32_t pointerPosX, int32_t pointerPosY) override;
367 
368     /*
369      * Sub Window
370      */
SetParentSessionCallback(NotifySetParentSessionFunc && func)371     virtual void SetParentSessionCallback(NotifySetParentSessionFunc&& func) {}
NotifySetParentSession(int32_t oldParentWindowId,int32_t newParentWindowId)372     virtual WMError NotifySetParentSession(int32_t oldParentWindowId,
373         int32_t newParentWindowId) { return WMError::WM_ERROR_INVALID_WINDOW; }
374     void UpdateSubWindowLevel(uint32_t subWindowLevel);
375     int GetMaxSubWindowLevel() const;
376 
377     /*
378      * Window Immersive
379      */
380     WSError OnNeedAvoid(bool status) override;
381     AvoidArea GetAvoidAreaByType(AvoidAreaType type, const WSRect& rect = WSRect::EMPTY_RECT,
382         int32_t apiVersion = API_VERSION_INVALID) override;
383     WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) override;
384     WSError SetSystemBarProperty(WindowType type, SystemBarProperty systemBarProperty);
385     void SetIsStatusBarVisible(bool isVisible);
386     WSError SetIsStatusBarVisibleInner(bool isVisible);
387     WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
388     void UpdateRotationAvoidArea();
389     bool CheckGetAvoidAreaAvailable(AvoidAreaType type) override;
390     bool GetIsDisplayStatusBarTemporarily() const;
391     void SetIsDisplayStatusBarTemporarily(bool isTemporary);
392     void SetIsLastFrameLayoutFinishedFunc(IsLastFrameLayoutFinishedFunc&& func);
393     void SetIsAINavigationBarAvoidAreaValidFunc(IsAINavigationBarAvoidAreaValidFunc&& func);
394     void RetrieveStatusBarDefaultVisibility();
395     void RegisterNeedAvoidCallback(NotifyNeedAvoidFunc&& callback);
396     void RegisterSystemBarPropertyChangeCallback(NotifySystemBarPropertyChangeFunc&& callback);
397     void MarkAvoidAreaAsDirty();
RecalculatePanelRectForAvoidArea(WSRect & panelRect)398     virtual void RecalculatePanelRectForAvoidArea(WSRect& panelRect) {}
399     void RegisterGetStatusBarAvoidHeightFunc(GetStatusBarAvoidHeightFunc&& func);
400     void RegisterGetStatusBarConstantlyShowFunc(GetStatusBarConstantlyShowFunc&& func);
401     void HookAvoidAreaInCompatibleMode(WSRect& rect, AvoidArea& avoidArea, AvoidAreaType avoidAreaType) const;
402 
403     void SetAbilitySessionInfo(std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo);
404     void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func);
405     void SetSessionEventParam(SessionEventParam param);
406     void SetSessionRectChangeCallback(const NotifySessionRectChangeFunc& func);
407     void SetAdjustKeyboardLayoutCallback(const NotifyKeyboardLayoutAdjustFunc& func);
408     void SetSkipDraw(bool skip);
409     virtual void SetSkipSelfWhenShowOnVirtualScreen(bool isSkip);
410     WMError SetUniqueDensityDpi(bool useUnique, float dpi);
411 
412     bool IsAnco() const override;
413     void SetBlank(bool isAddBlank) override;
414     bool GetBlank() const override;
415     void SetBufferAvailableCallbackEnable(bool enable);
416     bool GetBufferAvailableCallbackEnable() const override;
417     int32_t GetCollaboratorType() const;
418     WSRect GetLastSafeRect() const;
419     WSRect GetSessionTargetRectByDisplayId(DisplayId displayId) const;
420     std::string GetUpdatedIconPath() const;
421     int32_t GetParentPersistentId() const;
422     int32_t GetMainSessionId();
GetMissionId()423     virtual int32_t GetMissionId() const { return persistentId_; };
424     Orientation GetRequestedOrientation() const;
425     std::vector<sptr<SceneSession>> GetSubSession() const;
426     std::vector<sptr<SceneSession>> GetToastSession() const;
427     std::shared_ptr<AppExecFwk::AbilityInfo> GetAbilityInfo() const;
428     std::string GetWindowNameAllType() const;
429     SubWindowModalType GetSubWindowModalType() const;
430     int32_t GetOriPosYBeforeRaisedByKeyboard() const;
431     std::string GetClientIdentityToken() const;
432 
433     /*
434      * Window Watermark
435      */
436     void SetWatermarkEnabled(const std::string& watermarkName, bool isEnabled);
437 
438     bool IsDecorEnable() const;
439     bool IsAppSession() const;
440     bool IsAppOrLowerSystemSession() const;
441     bool IsSystemSessionAboveApp() const;
442     bool IsTurnScreenOn() const;
443     bool IsKeepScreenOn() const;
444     bool IsViewKeepScreenOn() const;
445     bool IsShowWhenLocked() const;
446     bool GetShowWhenLockedFlagValue() const;
447     bool IsFloatingWindowAppType() const;
448     bool IsNeedDefaultAnimation() const;
449     void SetSystemTouchable(bool touchable) override;
450     bool IsVisibleForAccessibility() const;
451     void SetStartingWindowExitAnimationFlag(bool enable);
452     bool NeedStartingWindowExitAnimation() const override;
453 
454     void NotifyWindowVisibility();
455     WSError OnShowWhenLocked(bool showWhenLocked);
456     void SaveUpdatedIcon(const std::shared_ptr<Media::PixelMap>& icon);
457     void NotifyTouchOutside();
458     bool CheckTouchOutsideCallbackRegistered();
459     void UpdateNativeVisibility(bool visible);
460     void DumpSessionElementInfo(const std::vector<std::string>& params);
461     void NotifyForceHideChange(bool hide);
462     WSError BindDialogSessionTarget(const sptr<SceneSession>& sceneSession);
463     void DumpSessionInfo(std::vector<std::string>& info) const;
464     bool AddSubSession(const sptr<SceneSession>& subSession);
465     bool RemoveSubSession(int32_t persistentId);
466     bool AddToastSession(const sptr<SceneSession>& toastSession);
467     bool RemoveToastSession(int32_t persistentId);
468     void NotifySessionForeground(uint32_t reason, bool withAnimation);
469     void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits);
470     void RegisterForceSplitListener(const NotifyForceSplitFunc& func);
471 
472     /*
473      * Dialog Window
474      */
475     void RegisterBindDialogSessionCallback(const NotifyBindDialogSessionFunc& callback);
476 
477     void SetUpdatePrivateStateAndNotifyFunc(const UpdatePrivateStateAndNotifyFunc& func);
478 
479     /*
480      * Window Input Event
481      */
482     void RegisterTouchOutsideCallback(NotifyTouchOutsideFunc&& callback);
483     void SetMousePointerDownEventStatus(bool mousePointerDownEventStatus);
484     bool GetMousePointerDownEventStatus() const;
485     void SetFingerPointerDownStatus(int32_t fingerId);
486     void RemoveFingerPointerDownStatus(int32_t fingerId);
487     std::unordered_set<int32_t> GetFingerPointerDownStatusList() const;
488 
489     /*
490      * Window Rotation
491      */
492     void RegisterRequestedOrientationChangeCallback(NotifyReqOrientationChangeFunc&& callback);
493 
494     /*
495      * Window Animation
496      */
497     void RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback);
498     void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback);
499 
500     /*
501      * Window Visibility
502      */
503     void SetNotifyVisibleChangeFunc(const NotifyVisibleChangeFunc& func);
504 
505     /*
506      * Window Hierarchy
507      */
508     void RegisterRaiseToTopCallback(NotifyRaiseToTopFunc&& callback);
509     void RegisterRaiseAboveTargetCallback(NotifyRaiseAboveTargetFunc&& callback);
510     void RegisterSessionTopmostChangeCallback(NotifySessionTopmostChangeFunc&& callback);
511     void RegisterSubSessionZLevelChangeCallback(NotifySubSessionZLevelChangeFunc&& callback);
512 
513     /*
514      * Window Lifecycle
515      */
516     void ClearJsSceneSessionCbMap(bool needRemove); // ONLY Accessed on OS_sceneSession thread
517     void ClearSpecificSessionCbMap();
518     void RegisterShowWhenLockedCallback(NotifyShowWhenLockedFunc&& callback);
519     void RegisterForceHideChangeCallback(NotifyForceHideChangeFunc&& callback);
520     void RegisterClearCallbackMapCallback(ClearCallbackMapFunc&& callback);
HideSync()521     virtual WSError HideSync() { return WSError::WS_DO_NOTHING; }
522     void RegisterUpdateAppUseControlCallback(UpdateAppUseControlFunc&& func);
523     void NotifyUpdateAppUseControl(ControlAppType type, const ControlInfo& controlInfo);
524     void SetVisibilityChangedDetectFunc(VisibilityChangedDetectFunc&& func);
RegisterSessionLockStateChangeCallback(NotifySessionLockStateChangeCallback && callback)525     virtual void RegisterSessionLockStateChangeCallback(NotifySessionLockStateChangeCallback&& callback) {}
NotifySessionLockStateChange(bool isLockedState)526     virtual void NotifySessionLockStateChange(bool isLockedState) {}
SetUpdateSessionLabelAndIconListener(NofitySessionLabelAndIconUpdatedFunc && func)527     virtual void SetUpdateSessionLabelAndIconListener(NofitySessionLabelAndIconUpdatedFunc&& func) {}
528     bool UpdateInteractiveInner(bool interactive);
529 
530     void SendPointerEventToUI(std::shared_ptr<MMI::PointerEvent> pointerEvent);
531     bool SendKeyEventToUI(std::shared_ptr<MMI::KeyEvent> keyEvent, bool isPreImeEvent = false);
532     bool IsStartMoving() override;
533     void SetIsStartMoving(bool startMoving);
534     bool IsSystemSpecificSession() const;
535     void SetIsSystemSpecificSession(bool isSystemSpecificSession);
536     void SetShouldHideNonSecureWindows(bool shouldHide);
537     void UpdateExtWindowFlags(int32_t extPersistentId, const ExtensionWindowFlags& extWindowFlags,
538         const ExtensionWindowFlags& extWindowActions);
539     ExtensionWindowFlags GetCombinedExtWindowFlags();
540     void RemoveExtWindowFlags(int32_t extPersistentId);
541     void ClearExtWindowFlags();
542     void NotifyDisplayMove(DisplayId from, DisplayId to);
543     void NotifySessionFullScreen(bool fullScreen);
544     void SetDefaultDisplayIdIfNeed();
545 
546     void SetSessionState(SessionState state) override;
547     void SetForceHideState(ForceHideState forceHideState);
548     ForceHideState GetForceHideState() const;
549     bool IsTemporarilyShowWhenLocked() const;
550     void SetTemporarilyShowWhenLocked(bool isTemporarilyShowWhenLocked);
551 
552     std::shared_ptr<PowerMgr::RunningLock> keepScreenLock_;
553     std::shared_ptr<PowerMgr::RunningLock> viewKeepScreenLock_;
554 
555     static MaximizeMode maximizeMode_;
556     static uint32_t GetWindowDragHotAreaType(DisplayId displayId, uint32_t type, int32_t pointerX, int32_t pointerY);
557     static void AddOrUpdateWindowDragHotArea(DisplayId displayId, uint32_t type, const WSRect& area);
558     WSError UpdateRectChangeListenerRegistered(bool isRegister) override;
559 
560     /*
561      * Window Decor
562      */
563     int32_t GetCustomDecorHeight() const;
564     void SetCustomDecorHeight(int32_t height) override;
565 
566     WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
567         WSPropertyChangeAction action) override;
568     void SetSessionChangeByActionNotifyManagerListener(const SessionChangeByActionNotifyManagerFunc& func);
569 
570     /*
571      * UIExtension
572      */
573     bool IsShowOnLockScreen(uint32_t lockScreenZOrder);
574     void AddExtensionTokenInfo(const UIExtensionTokenInfo& tokenInfo);
575     void RemoveExtensionTokenInfo(const sptr<IRemoteObject>& abilityToken);
576     void CheckExtensionOnLockScreenToClose();
577     void CloseExtensionSync(const UIExtensionTokenInfo& tokenInfo);
578     void OnNotifyAboveLockScreen();
579     void AddNormalModalUIExtension(const ExtensionWindowEventInfo& extensionInfo);
580     void RemoveNormalModalUIExtension(int32_t persistentId);
581     void UpdateNormalModalUIExtension(const ExtensionWindowEventInfo& extensionInfo);
582     std::optional<ExtensionWindowEventInfo> GetLastModalUIExtensionEventInfo();
583     Vector2f GetSessionGlobalPosition(bool useUIExtension);
584     void AddUIExtSurfaceNodeId(uint64_t surfaceNodeId, int32_t persistentId);
585     void RemoveUIExtSurfaceNodeId(int32_t persistentId);
586     int32_t GetUIExtPersistentIdBySurfaceNodeId(uint64_t surfaceNodeId) const;
587     int32_t GetStatusBarHeight() override;
588     int32_t GetDockHeight();
IsFreeMultiWindowMode()589     bool IsFreeMultiWindowMode() const
590     {
591         return systemConfig_.IsFreeMultiWindowMode();
592     }
593     WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) override;
594 
595     // WMSPipeline-related: only accessed on SSM thread
SyncScenePanelGlobalPosition(bool needSync)596     virtual void SyncScenePanelGlobalPosition(bool needSync) {}
597     void SetNeedSyncSessionRect(bool needSync);
598     // update visible session, return dirty flags
599     uint32_t UpdateUIParam(const SessionUIParam& uiParam) REQUIRES(SCENE_GUARD);
600     // update invisible session, return dirty flags
601     uint32_t UpdateUIParam() REQUIRES(SCENE_GUARD);
602     void SetPostProcessFocusState(PostProcessFocusState state);
603     PostProcessFocusState GetPostProcessFocusState() const;
604     void ResetPostProcessFocusState();
605     void SetPostProcessProperty(bool state);
606     bool GetPostProcessProperty() const;
607     void PostProcessNotifyAvoidArea();
608     bool IsImmersiveType() const;
609     bool IsPcOrPadEnableActivation() const;
610     static void RegisterGetConstrainedModalExtWindowInfo(GetConstrainedModalExtWindowInfoFunc&& callback);
611 
612     /*
613      * Multi User
614      */
615     void SetMinimizedFlagByUserSwitch(bool isMinimized);
616     bool IsMinimizedByUserSwitch() const;
617     void UnregisterSessionChangeListeners() override;
618 
619     /*
620      * Window ZOrder: PC
621      */
SetPcScenePanel(bool isPcScenePanel)622     void SetPcScenePanel(bool isPcScenePanel) { isPcScenePanel_ = isPcScenePanel; }
623     void UpdatePCZOrderAndMarkDirty(const uint32_t zOrder);
624 
625     /*
626      * Multi Window
627      */
628     WSError SetSplitButtonVisible(bool isVisible);
629     WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue);
630     WSError OnContainerModalEvent(const std::string& eventName, const std::string& eventValue) override;
631     void RegisterSetLandscapeMultiWindowFunc(NotifyLandscapeMultiWindowSessionFunc&& func);
632 
633     /*
634      * Move Drag
635      */
SetAppDragResizeType(DragResizeType dragResizeType)636     void SetAppDragResizeType(DragResizeType dragResizeType) { appDragResizeType_ = dragResizeType; }
GetAppDragResizeType()637     DragResizeType GetAppDragResizeType() const { return appDragResizeType_; }
638     void RegisterSessionEventCallback(NotifySessionEventFunc&& callback);
639     void SetWindowMovingCallback(NotifyWindowMovingFunc&& func);
640     DMRect CalcRectForStatusBar();
641     WSError SetMoveAvailableArea(DisplayId displayId);
642 
643     /*
644      * Window Layout
645      */
646     bool IsDirtyWindow();
647     bool IsDirtyDragWindow();
648     void ResetDirtyDragFlags();
649     void ResetSizeChangeReasonIfDirty();
650     void SetRequestNextVsyncFunc(RequestVsyncFunc&& func);
651     void OnNextVsyncReceivedWhenDrag();
652     void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback);
653     bool SetFrameGravity(Gravity gravity);
654     void SetBehindWindowFilterEnabled(bool enabled); // Only accessed on main thread
655     WSError GetCrossAxisState(CrossAxisState& state) override;
656     virtual void UpdateCrossAxis();
GetIsFollowParentLayout()657     bool GetIsFollowParentLayout() const { return isFollowParentLayout_; }
GetMoveDragController()658     sptr<MoveDragController> GetMoveDragController() const { return moveDragController_; }
659     void NotifyUpdateGravity();
660 
661     /*
662      * Gesture Back
663      */
664     bool GetGestureBackEnabled();
665     bool GetEnableGestureBackHadSet();
666 
667     /*
668      * PC Fold Screen
669      */
670     void UpdateFullScreenWaterfallMode(bool isWaterfallMode);
671     void RegisterFullScreenWaterfallModeChangeCallback(std::function<void(bool isWaterfallMode)>&& func);
672     void OnThrowSlipAnimationStateChange(bool isAnimating);
673     void RegisterThrowSlipAnimationStateChangeCallback(std::function<void(bool isAnimating)>&& func);
674     bool IsMissionHighlighted();
675     void MaskSupportEnterWaterfallMode();
676     void SetSupportEnterWaterfallMode(bool isSupportEnter);
677     void ThrowSlipDirectly(const WSRectF& velocity);
678 
679     /*
680      * Keyboard
681      */
682     void SetIsSystemKeyboard(bool isSystemKeyboard);
683     bool IsSystemKeyboard() const;
684     void ActivateKeyboardAvoidArea(bool active, bool recalculateAvoid);
685     bool IsKeyboardAvoidAreaActive() const;
SetKeyboardViewModeChangeListener(const NotifyKeyboarViewModeChangeFunc & func)686     virtual void SetKeyboardViewModeChangeListener(const NotifyKeyboarViewModeChangeFunc& func) {};
687     void NotifyKeyboardAnimationCompleted(bool isShowAnimation, const WSRect& beginRect, const WSRect& endRect);
688     void NotifyKeyboardDidShowRegistered(bool registered) override;
689     void NotifyKeyboardDidHideRegistered(bool registered) override;
690 
691     /*
692      * Window Focus
693      */
694     bool IsSameMainSession(const sptr<SceneSession>& prevSession);
695     void SetHighlightChangeNotifyFunc(const NotifyHighlightChangeFunc& func);
696     void SetFollowParentRectFunc(NotifyFollowParentRectFunc&& func);
697     WSError SetFollowParentWindowLayoutEnabled(bool isFollow) override;
698 
699     /*
700      * Window Property
701     */
702     void SetWindowCornerRadiusCallback(NotifySetWindowCornerRadiusFunc&& func);
703     WSError SetWindowCornerRadius(float cornerRadius) override;
704     void SetPrivacyModeChangeNotifyFunc(NotifyPrivacyModeChangeFunc&& func);
705     void SetIsAncoForFloatingWindow(bool isAncoForFloatingWindow);
706     bool GetIsAncoForFloatingWindow() const;
707 
708     /*
709      * Window Pattern
710     */
711     void NotifyWindowAttachStateListenerRegistered(bool registered) override;
712 
713 protected:
714     void NotifyIsCustomAnimationPlaying(bool isPlaying);
715     void SetMoveDragCallback();
716     std::string GetRatioPreferenceKey();
717     WSError NotifyClientToUpdateRectTask(const std::string& updateReason, std::shared_ptr<RSTransaction> rsTransaction);
718     bool CheckPermissionWithPropertyAnimation(const sptr<WindowSessionProperty>& property) const;
719 
GetRectInfo(const WSRect & rect)720     std::string GetRectInfo(const WSRect& rect)
721     {
722         using std::to_string;
723         return "[" + to_string(rect.width_) + ", " + to_string(rect.height_) + "; "
724         + to_string(rect.posX_) + ", " + to_string(rect.posY_) + "]";
725     }
726 
727     /*
728      * Window Pipeline
729      */
730     bool UpdateVisibilityInner(bool visibility) REQUIRES(SCENE_GUARD);
NotifyClientToUpdateInteractive(bool interactive)731     virtual void NotifyClientToUpdateInteractive(bool interactive) {}
732     bool PipelineNeedNotifyClientToUpdateRect() const;
733     bool UpdateRectInner(const SessionUIParam& uiParam, SizeChangeReason reason);
734     bool NotifyServerToUpdateRect(const SessionUIParam& uiParam, SizeChangeReason reason);
735     bool IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY);
736     bool UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY);
737     bool UpdateZOrderInner(uint32_t zOrder);
738 
739     /*
740      * Window Immersive
741      */
742     void CalculateAvoidAreaRect(const WSRect& rect, const WSRect& avoidRect, AvoidArea& avoidArea) const;
743     virtual void NotifyClientToUpdateAvoidArea();
744     bool PipelineNeedNotifyClientToUpdateAvoidArea(uint32_t dirty) const;
745     NotifyNeedAvoidFunc onNeedAvoid_;
746     NotifySystemBarPropertyChangeFunc onSystemBarPropertyChange_;
747     GetStatusBarAvoidHeightFunc onGetStatusBarAvoidHeightFunc_;
748     GetStatusBarConstantlyShowFunc onGetStatusBarConstantlyShowFunc_;
749 
750     /*
751      * Gesture Back
752      */
753     void UpdateGestureBackEnabled() override;
754 
755     sptr<SpecificSessionCallback> specificCallback_ = nullptr;
756 
757     /*
758      * Dialog window
759      */
760     NotifyBindDialogSessionFunc onBindDialogTarget_;
761 
762     sptr<SceneSession> keyboardPanelSession_ = nullptr;
763     sptr<SceneSession> keyboardSession_ = nullptr;
764     NotifyKeyboardLayoutAdjustFunc adjustKeyboardLayoutFunc_;
765 
766     /*
767      * Window Hierarchy
768      */
769     NotifyMainWindowTopmostChangeFunc mainWindowTopmostChangeFunc_;
770     NotifyRaiseToTopFunc onRaiseToTop_;
771     NotifyRaiseAboveTargetFunc onRaiseAboveTarget_;
772     NotifySessionTopmostChangeFunc onSessionTopmostChange_;
773     NotifySubSessionZLevelChangeFunc onSubSessionZLevelChange_;
774 
775     /*
776      * PC Window
777      */
778     NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_;
779     NotifyRestoreMainWindowFunc onRestoreMainWindowFunc_;
780     NotifySetWindowRectAutoSaveFunc onSetWindowRectAutoSaveFunc_;
781     NotifySubModalTypeChangeFunc onSubModalTypeChange_;
782     NotifyMainModalTypeChangeFunc onMainModalTypeChange_;
783     NotifySetSupportedWindowModesFunc onSetSupportedWindowModesFunc_;
784     NotifyUpdateFlagFunc onUpdateFlagFunc_;
785 
786     /*
787      * PiP Window
788      */
789     NotifyPrepareClosePiPSessionFunc onPrepareClosePiPSession_;
790 
791     /*
792      * Window Layout
793      */
794     NotifyDefaultDensityEnabledFunc onDefaultDensityEnabledFunc_;
795     sptr<MoveDragController> moveDragController_ = nullptr;
796     NotifyFollowParentRectFunc followParentRectFunc_ = nullptr;
797     std::mutex registerNotifySurfaceBoundsChangeMutex_;
798     std::unordered_map<int32_t, NotifySurfaceBoundsChangeFunc> notifySurfaceBoundsChangeFuncMap_;
799     bool isFollowParentLayout_ = false;
800 
801     virtual void NotifySessionRectChange(const WSRect& rect,
802         SizeChangeReason reason = SizeChangeReason::UNDEFINED, DisplayId displayId = DISPLAY_ID_INVALID,
803         const RectAnimationConfig& rectAnimationConfig = {});
804     virtual void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason,
805         const MoveConfiguration& moveConfiguration, const RectAnimationConfig& rectAnimationConfig = {});
806     void NotifySessionDisplayIdChange(uint64_t displayId);
807     virtual void CheckAndMoveDisplayIdRecursively(uint64_t displayId);
SetShouldFollowParentWhenShow(bool shouldFollow)808     void SetShouldFollowParentWhenShow(bool shouldFollow) { shouldFollowParentWhenShow_ = shouldFollow; }
GetShouldFollowParentWhenShow()809     bool GetShouldFollowParentWhenShow() const { return shouldFollowParentWhenShow_; }
810     void CheckSubSessionShouldFollowParent(uint64_t displayId);
811 
812     /*
813      * Window Lifecycle
814      */
815     NotifyShowWhenLockedFunc onShowWhenLockedFunc_;
816     NotifyForceHideChangeFunc onForceHideChangeFunc_;
817     ClearCallbackMapFunc clearCallbackMapFunc_;
818     UpdateAppUseControlFunc onUpdateAppUseControlFunc_;
819     std::unordered_map<ControlAppType, ControlInfo> appUseControlMap_;
820 
821     /*
822      * PC Fold Screen
823      */
824     bool IsFullScreenWaterfallMode();
825     void UpdateWaterfallMode(SessionEvent event);
826     sptr<PcFoldScreenController> pcFoldScreenController_ = nullptr;
827     std::atomic<uint32_t> throwSlipToFullScreenAnimCount_ = 0;
828     std::function<void(bool isAnimating)> onThrowSlipAnimationStateChangeFunc_;
829 
830     /*
831      * UIExtension
832      */
833     static GetConstrainedModalExtWindowInfoFunc onGetConstrainedModalExtWindowInfoFunc_;
834 
835     /*
836      * Multi Window
837      */
838     NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_;
839 
840     /*
841      * Keyboard
842      */
EnableCallingSessionAvoidArea()843     virtual void EnableCallingSessionAvoidArea() {}
844     virtual void RestoreCallingSession(const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) {}
845     bool keyboardAvoidAreaActive_ = true;
846     std::atomic<bool> isKeyboardDidShowRegistered_ = false;
847     std::atomic<bool> isKeyboardDidHideRegistered_ = false;
848 
849 private:
850     void NotifyAccessibilityVisibilityChange();
851     void CalculateCombinedExtWindowFlags();
852 
853     /*
854      * Window Immersive
855      */
856     void GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea);
857     void GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea);
858     void GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea);
859     void GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea) const;
860     AvoidArea GetAvoidAreaByTypeInner(AvoidAreaType type, const WSRect& rect = WSRect::EMPTY_RECT);
861 
862     /*
863      * Window Lifecycle
864      */
865     bool CheckIdentityTokenIfMatched(const std::string& identityToken);
866     bool CheckPidIfMatched();
867 
868     // session lifecycle funcs
869     WSError ForegroundTask(const sptr<WindowSessionProperty>& property);
870 
871     /*
872      * Move Drag
873      */
874     void HandleMoveDragSurfaceNode(SizeChangeReason reason);
875     void OnMoveDragCallback(SizeChangeReason reason);
876     bool IsDragResizeWhenEnd(SizeChangeReason reason);
877     void InitializeCrossMoveDrag();
878     WSError InitializeMoveInputBar();
879     void HandleMoveDragSurfaceBounds(WSRect& rect, WSRect& globalRect, SizeChangeReason reason);
880     void HandleMoveDragEnd(WSRect& rect, SizeChangeReason reason);
881     bool MoveUnderInteriaAndNotifyRectChange(WSRect& rect, SizeChangeReason reason);
882     void NotifyFullScreenAfterThrowSlip(const WSRect& rect);
SetDragResizeTypeDuringDrag(DragResizeType dragResizeType)883     void SetDragResizeTypeDuringDrag(DragResizeType dragResizeType) { dragResizeTypeDuringDrag_ = dragResizeType; }
GetDragResizeTypeDuringDrag()884     DragResizeType GetDragResizeTypeDuringDrag() const { return dragResizeTypeDuringDrag_; }
885     void HandleSessionDragEvent(SessionEvent event);
886     void HandleCompatibleModeMoveDrag(WSRect& rect, SizeChangeReason reason);
887     void HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reason, bool isSupportDragInPcCompatibleMode);
888     NotifySessionEventFunc onSessionEvent_;
889     void ProcessWindowMoving(const std::shared_ptr<MMI::PointerEvent>& pointerEvent);
890 
891     /*
892      * Gesture Back
893      */
894     WMError SetGestureBackEnabled(bool isEnabled) override;
895 
896     /*
897      * UIExtension
898      */
899     void UpdateAllModalUIExtensions(const WSRect& globalRect);
900 
901     /*
902      * Window Property
903      */
904     void NotifyPrivacyModeChange();
905 
906 #ifdef DEVICE_STATUS_ENABLE
907     void RotateDragWindow(std::shared_ptr<RSTransaction> rsTransaction);
908 #endif // DEVICE_STATUS_ENABLE
909     void NotifyPropertyWhenConnect();
910     WSError RaiseAppMainWindowToTop() override;
911     void UpdateWinRectForSystemBar(WSRect& rect);
912     bool IsMovableWindowType();
913     bool IsFullScreenMovable();
914     bool IsMovable();
915     void HandleCastScreenConnection(SessionInfo& info, sptr<SceneSession> session);
916     WMError HandleUpdatePropertyByAction(const sptr<WindowSessionProperty>& property,
917         WSPropertyChangeAction action);
918     WMError HandleActionUpdateTurnScreenOn(const sptr<WindowSessionProperty>& property,
919         WSPropertyChangeAction action);
920     WMError HandleActionUpdateKeepScreenOn(const sptr<WindowSessionProperty>& property,
921         WSPropertyChangeAction action);
922     WMError HandleActionUpdateViewKeepScreenOn(const sptr<WindowSessionProperty>& property,
923         WSPropertyChangeAction action);
924     WMError HandleActionUpdateFocusable(const sptr<WindowSessionProperty>& property,
925         WSPropertyChangeAction action);
926     WMError HandleActionUpdateTouchable(const sptr<WindowSessionProperty>& property,
927         WSPropertyChangeAction action);
928     WMError HandleActionUpdateSetBrightness(const sptr<WindowSessionProperty>& property,
929         WSPropertyChangeAction action);
930     WMError HandleActionUpdateOrientation(const sptr<WindowSessionProperty>& property,
931         WSPropertyChangeAction action);
932     WMError HandleActionUpdatePrivacyMode(const sptr<WindowSessionProperty>& property,
933         WSPropertyChangeAction action);
934     WMError HandleActionUpdateSnapshotSkip(const sptr<WindowSessionProperty>& property,
935         WSPropertyChangeAction action);
936     WMError HandleActionUpdateMaximizeState(const sptr<WindowSessionProperty>& property,
937         WSPropertyChangeAction action);
938     WMError HandleActionUpdateOtherProps(const sptr<WindowSessionProperty>& property,
939         WSPropertyChangeAction action);
940     WMError HandleActionUpdateStatusProps(const sptr<WindowSessionProperty>& property,
941         WSPropertyChangeAction action);
942     WMError HandleActionUpdateNavigationProps(const sptr<WindowSessionProperty>& property,
943         WSPropertyChangeAction action);
944     WMError HandleActionUpdateNavigationIndicatorProps(const sptr<WindowSessionProperty>& property,
945         WSPropertyChangeAction action);
946     WMError HandleActionUpdateFlags(const sptr<WindowSessionProperty>& property,
947         WSPropertyChangeAction action);
948     WMError HandleActionUpdateMode(const sptr<WindowSessionProperty>& property,
949         WSPropertyChangeAction action);
950     WMError HandleActionUpdateAnimationFlag(const sptr<WindowSessionProperty>& property,
951         WSPropertyChangeAction action);
952     WMError HandleActionUpdateTouchHotArea(const sptr<WindowSessionProperty>& property,
953         WSPropertyChangeAction action);
954     WMError HandleActionUpdateKeyboardTouchHotArea(const sptr<WindowSessionProperty>& property,
955         WSPropertyChangeAction action);
956     WMError HandleActionUpdateDecorEnable(const sptr<WindowSessionProperty>& property,
957         WSPropertyChangeAction action);
958     WMError HandleActionUpdateWindowLimits(const sptr<WindowSessionProperty>& property,
959         WSPropertyChangeAction action);
960     WMError HandleActionUpdateDragenabled(const sptr<WindowSessionProperty>& property,
961         WSPropertyChangeAction action);
962     WMError HandleActionUpdateRaiseenabled(const sptr<WindowSessionProperty>& property,
963         WSPropertyChangeAction action);
964     WMError HandleActionUpdateHideNonSystemFloatingWindows(const sptr<WindowSessionProperty>& property,
965         WSPropertyChangeAction action);
966     WMError HandleActionUpdateTextfieldAvoidInfo(const sptr<WindowSessionProperty>& property,
967         WSPropertyChangeAction action);
968     WMError HandleActionUpdateWindowMask(const sptr<WindowSessionProperty>& property,
969         WSPropertyChangeAction action);
970     WMError HandleActionUpdateTopmost(const sptr<WindowSessionProperty>& property,
971         WSPropertyChangeAction action);
972     WMError HandleActionUpdateMainWindowTopmost(const sptr<WindowSessionProperty>& property,
973         WSPropertyChangeAction action);
974     WMError HandleActionUpdateSubWindowZLevel(const sptr<WindowSessionProperty>& property,
975         WSPropertyChangeAction action);
976     WMError HandleActionUpdateWindowModeSupportType(const sptr<WindowSessionProperty>& property,
977         WSPropertyChangeAction action);
978     WMError ProcessUpdatePropertyByAction(const sptr<WindowSessionProperty>& property,
979         WSPropertyChangeAction action);
980     WMError HandleActionUpdateAvoidAreaOption(const sptr<WindowSessionProperty>& property,
981         WSPropertyChangeAction action);
982     WMError HandleBackgroundAlpha(const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action);
983     WMError HandleActionUpdateExclusivelyHighlighted(const sptr<WindowSessionProperty>& property,
984         WSPropertyChangeAction action);
985     void HandleSpecificSystemBarProperty(WindowType type, const sptr<WindowSessionProperty>& property);
986     void SetWindowFlags(const sptr<WindowSessionProperty>& property);
987     void NotifySessionChangeByActionNotifyManager(const sptr<WindowSessionProperty>& property,
988         WSPropertyChangeAction action);
989 
990     /*
991      * PiP Window
992      */
993     NotifySessionPiPControlStatusChangeFunc sessionPiPControlStatusChangeFunc_;
994     NotifyAutoStartPiPStatusChangeFunc autoStartPiPStatusChangeFunc_;
995     PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}};
996 
997     NotifyForceSplitFunc forceSplitFunc_;
998     UpdatePrivateStateAndNotifyFunc updatePrivateStateAndNotifyFunc_;
999     int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE;
1000     WSRect lastSafeRect = { 0, 0, 0, 0 };
1001     std::vector<sptr<SceneSession>> subSession_;
1002     std::vector<sptr<SceneSession>> toastSession_;
1003     std::atomic_bool needStartingWindowExitAnimation_ { true };
1004     bool needDefaultAnimationFlag_ = true;
1005     SessionEventParam sessionEventParam_ = { 0, 0, 0, 0, 0 };
1006     std::atomic_bool isStartMoving_ { false };
1007     std::atomic_bool isVisibleForAccessibility_ { true };
1008     bool isSystemSpecificSession_ { false };
1009 
1010     /*
1011      * UIExtension
1012      */
1013     std::atomic_bool shouldHideNonSecureWindows_ { false };
1014     std::shared_mutex combinedExtWindowFlagsMutex_;
1015     ExtensionWindowFlags combinedExtWindowFlags_ { 0 };
1016     std::map<int32_t, ExtensionWindowFlags> extWindowFlagsMap_;
1017     std::vector<UIExtensionTokenInfo> extensionTokenInfos_;
1018 
1019     /*
1020      * Window Layout
1021      */
1022     void AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect);
1023     bool AdjustRectByAspectRatio(WSRect& rect);
1024     bool SaveAspectRatio(float ratio);
1025     WSError UpdateRectForDrag(const WSRect& rect);
1026     void UpdateSessionRectPosYFromClient(SizeChangeReason reason, DisplayId& configDisplayId, WSRect& rect);
1027 
1028     /*
1029      * Window Decor
1030      */
1031     mutable std::mutex customDecorHeightMutex_;
1032     int32_t customDecorHeight_ = 0;
1033 
1034     ForceHideState forceHideState_ { ForceHideState::NOT_HIDDEN };
1035     int32_t oriPosYBeforeRaisedByKeyboard_ = 0;
1036     std::atomic_bool isTemporarilyShowWhenLocked_ { false };
1037     std::shared_mutex modalUIExtensionInfoListMutex_;
1038     std::vector<ExtensionWindowEventInfo> modalUIExtensionInfoList_;
1039     mutable std::shared_mutex uiExtNodeIdToPersistentIdMapMutex_;
1040     std::map<uint64_t, int32_t> uiExtNodeIdToPersistentIdMap_;
1041     std::string clientIdentityToken_ = { "" };
1042     SessionChangeByActionNotifyManagerFunc sessionChangeByActionNotifyManagerFunc_;
1043 
1044     bool isAddBlank_ = false;
1045     bool bufferAvailableCallbackEnable_ = false;
1046 
1047     // WMSPipeline-related: only accessed on SSM thread
1048     PostProcessFocusState postProcessFocusState_;
1049     bool postProcessProperty_ { false };
1050 
1051     /*
1052      * Window Recover
1053      */
1054     bool isRecovered_ = false;
1055 
1056     /*
1057      * Multi User
1058      */
1059     bool isMinimizedByUserSwitch_ { false };
1060 
1061     /*
1062      * Window ZOrder: PC
1063      */
1064     bool isPcScenePanel_ { false };
1065 
1066     /*
1067      * Move Drag
1068      */
1069     static std::shared_mutex windowDragHotAreaMutex_;
1070     static std::map<uint64_t, std::map<uint32_t, WSRect>> windowDragHotAreaMap_;
1071     DragResizeType appDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED;
1072     DragResizeType dragResizeTypeDuringDrag_ = DragResizeType::RESIZE_TYPE_UNDEFINED;
1073     NotifyWindowMovingFunc notifyWindowMovingFunc_;
1074 
1075     /*
1076      * Gesture Back
1077      */
1078     bool isEnableGestureBack_ { true };
1079     bool isEnableGestureBackHadSet_ { false };
1080 
1081     /*
1082      * Window Visibility
1083      */
1084     NotifyVisibleChangeFunc notifyVisibleChangeFunc_;
1085 
1086     /*
1087      * Window Input Event
1088      */
1089     NotifyTouchOutsideFunc onTouchOutside_;
1090     bool isMousePointerDownEventStatus_ { false };
1091     std::unordered_set<int32_t> fingerPointerDownStatusList_;
1092 
1093     /*
1094      * Window Rotation
1095      */
1096     NotifyReqOrientationChangeFunc onRequestedOrientationChange_;
1097 
1098     /*
1099      * Window Animation
1100      */
1101     NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_;
1102     NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_;
1103 
1104     /*
1105      * Window Layout
1106      */
1107     void SetSurfaceBoundsWithAnimation(
1108         const std::pair<RSAnimationTimingProtocol, RSAnimationTimingCurve>& animationParam,
1109         const WSRect& rect, const std::function<void()>& finishCallback = nullptr, bool isGlobal = false);
1110     void SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool needFlush = true);
1111     virtual void UpdateCrossAxisOfLayout(const WSRect& rect);
1112     NotifyLayoutFullScreenChangeFunc onLayoutFullScreenChangeFunc_;
NotifySubAndDialogFollowRectChange(const WSRect & rect,bool isGlobal,bool needFlush)1113     virtual void NotifySubAndDialogFollowRectChange(const WSRect& rect, bool isGlobal, bool needFlush) {};
1114     std::atomic<bool> shouldFollowParentWhenShow_ = true;
1115     std::shared_ptr<RSBehindWindowFilterEnabledModifier>
1116         behindWindowFilterEnabledModifier_; // Only accessed on main thread
1117     bool isDragging_ = false;
1118     std::atomic<bool> isCrossAxisOfLayout_ = false;
1119     std::atomic<uint32_t> crossAxisState_ = 0;
1120 
1121     /*
1122      * Window Immersive
1123      */
1124     std::atomic_bool isDisplayStatusBarTemporarily_ { false };
1125     bool isStatusBarVisible_ = true;
1126     IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc_;
1127     IsAINavigationBarAvoidAreaValidFunc isAINavigationBarAvoidAreaValid_;
1128 
1129     /*
1130      * PC Window Layout
1131      */
1132     bool isLayoutFullScreen_ { false };
1133     bool displayChangedByMoveDrag_ = false;
1134 
1135     /*
1136      * Window Property
1137      */
1138     NotifySetWindowCornerRadiusFunc onSetWindowCornerRadiusFunc_;
1139     NotifyPrivacyModeChangeFunc privacyModeChangeNotifyFunc_;
1140     // Set true if either sessionProperty privacyMode or combinedExtWindowFlags_ privacyModeFlag is true.
1141     bool isPrivacyMode_ { false };
1142     bool isAncoForFloatingWindow_ = false;
1143 
1144     /*
1145      * PC Window Sidebar Blur
1146      */
1147     std::shared_ptr<Rosen::RSAnimatableProperty<float>> blurRadiusValue_;
1148     std::shared_ptr<Rosen::RSAnimatableProperty<float>> blurSaturationValue_;
1149     std::shared_ptr<Rosen::RSAnimatableProperty<float>> blurBrightnessValue_;
1150     std::shared_ptr<Rosen::RSAnimatableProperty<Rosen::RSColor>> blurMaskColorValue_;
1151 };
1152 } // namespace OHOS::Rosen
1153 #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H
1154