/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H #define OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H #include "session/host/include/session.h" #include "session/host/include/move_drag_controller.h" #include "wm_common.h" namespace OHOS::PowerMgr { class RunningLock; } namespace OHOS::Rosen { namespace PARAM_KEY { const std::string PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity"; const std::string PARAM_DMS_CONTINUE_SESSION_ID_KEY = "ohos.dms.continueSessionId"; const std::string PARAM_DMS_PERSISTENT_ID_KEY = "ohos.dms.persistentId"; } namespace { constexpr int32_t MIN_DECOR_HEIGHT = 37; constexpr int32_t MAX_DECOR_HEIGHT = 112; } class SceneSession; using SpecificSessionCreateCallback = std::function(const SessionInfo& info, sptr property)>; using SpecificSessionDestroyCallback = std::function; using CameraFloatSessionChangeCallback = std::function; using GetSceneSessionVectorByTypeCallback = std::function>( WindowType type, uint64_t displayId)>; using UpdateAvoidAreaCallback = std::function; using UpdateAvoidAreaByTypeCallback = std::function; using UpdateOccupiedAreaIfNeedCallback = std::function; using NotifyWindowInfoUpdateCallback = std::function; using NotifyWindowPidChangeCallback = std::function; using NotifySessionTouchOutsideCallback = std::function; using GetAINavigationBarArea = std::function; using RecoveryCallback = std::function; using NotifyBindDialogSessionFunc = std::function& session)>; using NotifySessionPiPControlStatusChangeFunc = std::function; using NotifyAutoStartPiPStatusChangeFunc = std::function; using NotifySessionEventFunc = std::function; using NotifySessionTopmostChangeFunc = std::function; using NotifySubModalTypeChangeFunc = std::function; using NotifyMainModalTypeChangeFunc = std::function; using NotifyRaiseToTopFunc = std::function; using SetWindowPatternOpacityFunc = std::function; using NotifyIsCustomAnimationPlayingCallback = std::function; using NotifyWindowAnimationFlagChangeFunc = std::function; using NotifySystemBarPropertyChangeFunc = std::function& propertyMap)>; using NotifyNeedAvoidFunc = std::function; using NotifyShowWhenLockedFunc = std::function; using NotifyReqOrientationChangeFunc = std::function; using NotifyRaiseAboveTargetFunc = std::function; using NotifyForceHideChangeFunc = std::function; using NotifyTouchOutsideFunc = std::function; using ClearCallbackMapFunc = std::function; using NotifyPrepareClosePiPSessionFunc = std::function; using OnOutsideDownEvent = std::function; using HandleSecureSessionShouldHideCallback = std::function& sceneSession)>; using SystemSessionBufferAvailableCallback = std::function; using ClearDisplayStatusBarTemporarilyFlags = std::function; using CameraSessionChangeCallback = std::function; using NotifyLandscapeMultiWindowSessionFunc = std::function; using NotifyKeyboardGravityChangeFunc = std::function; using SessionChangeByActionNotifyManagerFunc = std::function& sceneSession, const sptr& property, WSPropertyChangeAction action)>; using NotifyKeyboardLayoutAdjustFunc = std::function; using NotifyLayoutFullScreenChangeFunc = std::function; using NotifyDefaultDensityEnabledFunc = std::function; using NotifyTitleAndDockHoverShowChangeFunc = std::function; using NotifyRestoreMainWindowFunc = std::function; using SetSkipSelfWhenShowOnVirtualScreenCallback = std::function; using NotifyForceSplitFunc = std::function; using UpdatePrivateStateAndNotifyFunc = std::function; using NotifyVisibleChangeFunc = std::function; using PiPStateChangeCallback = std::function; using NotifyMainWindowTopmostChangeFunc = std::function; using UpdateGestureBackEnabledCallback = std::function; using IsLastFrameLayoutFinishedFunc = std::function; using GetStatusBarDefaultVisibilityByDisplayIdFunc = std::function; using UpdateAppUseControlFunc = std::function; using NotifySetWindowRectAutoSaveFunc = std::function; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; uint32_t callingTokenId { 0 }; sptr abilityToken; }; class SceneSession : public Session { public: // callback for notify SceneSessionManager struct SpecificSessionCallback : public RefBase { SpecificSessionCreateCallback onCreate_; SpecificSessionDestroyCallback onDestroy_; ClearDisplayStatusBarTemporarilyFlags onClearDisplayStatusBarTemporarilyFlags_; CameraFloatSessionChangeCallback onCameraFloatSessionChange_; GetSceneSessionVectorByTypeCallback onGetSceneSessionVectorByType_; UpdateAvoidAreaCallback onUpdateAvoidArea_; UpdateAvoidAreaByTypeCallback onUpdateAvoidAreaByType_; GetStatusBarDefaultVisibilityByDisplayIdFunc onGetStatusBarDefaultVisibilityByDisplayId_; UpdateOccupiedAreaIfNeedCallback onUpdateOccupiedAreaIfNeed_; NotifyWindowInfoUpdateCallback onWindowInfoUpdate_; NotifyWindowPidChangeCallback onWindowInputPidChangeCallback_; NotifySessionTouchOutsideCallback onSessionTouchOutside_; GetAINavigationBarArea onGetAINavigationBarArea_; OnOutsideDownEvent onOutsideDownEvent_; HandleSecureSessionShouldHideCallback onHandleSecureSessionShouldHide_; CameraSessionChangeCallback onCameraSessionChange_; SetSkipSelfWhenShowOnVirtualScreenCallback onSetSkipSelfWhenShowOnVirtualScreen_; PiPStateChangeCallback onPiPStateChange_; UpdateGestureBackEnabledCallback onUpdateGestureBackEnabled_; }; // callback for notify SceneBoard struct SessionChangeCallback : public RefBase { NotifyBindDialogSessionFunc onBindDialogTarget_; NotifySessionTopmostChangeFunc onSessionTopmostChange_; NotifyRaiseToTopFunc onRaiseToTop_; NotifySessionEventFunc OnSessionEvent_; NotifyRaiseAboveTargetFunc onRaiseAboveTarget_; NotifyLandscapeMultiWindowSessionFunc onSetLandscapeMultiWindowFunc_; NotifyLayoutFullScreenChangeFunc onLayoutFullScreenChangeFunc_; }; // func for change window scene pattern property struct SetWindowScenePatternFunc : public RefBase { SetWindowPatternOpacityFunc setOpacityFunc_; }; SceneSession(const SessionInfo& info, const sptr& specificCallback); virtual ~SceneSession(); WSError Connect(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property = nullptr, sptr token = nullptr, const std::string& identityToken = "") override; WSError ConnectInner(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, SystemSessionConfig& systemConfig, sptr property = nullptr, sptr token = nullptr, int32_t pid = -1, int32_t uid = -1, const std::string& identityToken = "") override; virtual WSError Reconnect(const sptr& sessionStage, const sptr& eventChannel, const std::shared_ptr& surfaceNode, sptr property = nullptr, sptr token = nullptr, int32_t pid = -1, int32_t uid = -1); WSError ReconnectInner(sptr property); WSError Foreground(sptr property, bool isFromClient = false, const std::string& identityToken = "") override; WSError Background(bool isFromClient = false, const std::string& identityToken = "") override; virtual void RegisterBufferAvailableCallback(const SystemSessionBufferAvailableCallback& func) {}; WSError BackgroundTask(const bool isSaveSnapshot = true); WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override; WSError DisconnectTask(bool isFromClient = false, bool isSaveSnapshot = true); void SetClientIdentityToken(const std::string& clientIdentityToken); virtual void BindKeyboardPanelSession(sptr panelSession) {}; virtual sptr GetKeyboardPanelSession() const { return nullptr; }; virtual void BindKeyboardSession(sptr session) {}; virtual sptr GetKeyboardSession() const { return nullptr; }; virtual SessionGravity GetKeyboardGravity() const { return SessionGravity::SESSION_GRAVITY_DEFAULT; }; virtual void OnKeyboardPanelUpdated() {}; virtual void OnCallingSessionUpdated() {}; virtual uint32_t GetCallingSessionId() { return INVALID_SESSION_ID; }; bool GetScreenWidthAndHeightFromServer(const sptr& sessionProperty, uint32_t& screenWidth, uint32_t& screenHeight); bool GetScreenWidthAndHeightFromClient(const sptr& sessionProperty, uint32_t& screenWidth, uint32_t& screenHeight); void NotifyTargetScreenWidthAndHeight(bool isScreenAngleMismatch, uint32_t screenWidth, uint32_t screenHeight); WSError UpdateActiveStatus(bool isActive) override; WSError OnSessionEvent(SessionEvent event) override; WSError SyncSessionEvent(SessionEvent event) override; WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) override; WSError RaiseToAppTop() override; /* * Window Layout */ WSError UpdateSizeChangeReason(SizeChangeReason reason) override; virtual void SyncScenePanelGlobalPosition(bool needSync) {} void SetNeedSyncSessionRect(bool needSync); WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, const std::string& updateReason, const std::shared_ptr& rsTransaction = nullptr) override; WSError UpdateSessionRect(const WSRect& rect, const SizeChangeReason reason, bool isGlobal = false, bool isFromMoveToGlobal = false) override; WSError UpdateClientRect(const WSRect& rect) override; virtual void OpenKeyboardSyncTransaction() {} virtual void CloseKeyboardSyncTransaction(const WSRect& keyboardPanelRect, bool isKeyboardShow, bool isRotating) {} WSError ChangeSessionVisibilityWithStatusBar(const sptr info, bool visible) override; WSError PendingSessionActivation(const sptr info) override; WSError TerminateSession(const sptr info) override; WSError NotifySessionException( const sptr info, bool needRemoveSession = false) override; WSError NotifySessionExceptionInner( const sptr info, bool needRemoveSession = false, bool isFromClient = false, bool startFail = false); WSError NotifyClientToUpdateRect(const std::string& updateReason, std::shared_ptr rsTransaction) override; WSError TransferPointerEvent(const std::shared_ptr& pointerEvent, bool needNotifyClient = true) override; WSError RequestSessionBack(bool needMoveToBackground) override; WSError SetAspectRatio(float ratio) override; WSError SetGlobalMaximizeMode(MaximizeMode mode) override; WSError GetGlobalMaximizeMode(MaximizeMode& mode) override; WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override; WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override; void SetZOrder(uint32_t zOrder) override; std::vector GetTouchHotAreas() const override; void NotifyUILostFocus() override; void SetScale(float scaleX, float scaleY, float pivotX, float pivotY) override; void SetFloatingScale(float floatingScale) override; WSError RaiseAboveTarget(int32_t subWindowId) override; /* * PiP Window */ PiPTemplateInfo GetPiPTemplateInfo() const; void SetPiPTemplateInfo(const PiPTemplateInfo& pipTemplateInfo); WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override; WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status) override; WSError SetAutoStartPiP(bool isAutoStart, uint32_t priority) override; void NotifyPiPWindowPrepareClose() override; void SetSessionPiPControlStatusChangeCallback(const NotifySessionPiPControlStatusChangeFunc& func); void SetAutoStartPiPStatusChangeCallback(const NotifyAutoStartPiPStatusChangeFunc& func); WSError SetPipActionEvent(const std::string& action, int32_t status); WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status); void RegisterProcessPrepareClosePiPCallback(NotifyPrepareClosePiPSessionFunc&& callback); void RequestHideKeyboard(bool isAppColdStart = false); WSError ProcessPointDownSession(int32_t posX, int32_t posY) override; WSError SendPointEventForMoveDrag(const std::shared_ptr& pointerEvent) override; void NotifyOutsideDownEvent(const std::shared_ptr& pointerEvent); WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect) override; void SetForegroundInteractiveStatus(bool interactive) override; WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override; /* * Window Layout */ WMError SetSystemWindowEnableDrag(bool enableDrag) override; WMError SetWindowEnableDragBySystem(bool enableDrag); WSError OnDefaultDensityEnabled(bool isDefaultDensityEnabled) override; void RegisterDefaultDensityEnabledCallback(NotifyDefaultDensityEnabledFunc&& callback); WSError SetKeepScreenOn(bool keepScreenOn); void SetParentPersistentId(int32_t parentId); WSError SetTurnScreenOn(bool turnScreenOn); void SetPrivacyMode(bool isPrivacy); void SetSnapshotSkip(bool isSkip); void SetSystemSceneOcclusionAlpha(double alpha); void SetSystemSceneForceUIFirst(bool forceUIFirst); void MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled); void SetRequestedOrientation(Orientation orientation); WSError SetDefaultRequestedOrientation(Orientation orientation); void SetWindowAnimationFlag(bool needDefaultAnimationFlag); void SetCollaboratorType(int32_t collaboratorType); void SetLastSafeRect(WSRect rect); void SetOriPosYBeforeRaisedByKeyboard(int32_t posY); /* * Window Hierarchy */ virtual WSError SetTopmost(bool topmost) { return WSError::WS_ERROR_INVALID_CALLING; } virtual bool IsTopmost() const { return false; } virtual WSError SetMainWindowTopmost(bool isTopmost) { return WSError::WS_ERROR_INVALID_CALLING; } virtual bool IsMainWindowTopmost() const { return false; } void SetMainWindowTopmostChangeCallback(NotifyMainWindowTopmostChangeFunc&& func); /** * PC Window */ void SetRestoreMainWindowCallback(NotifyRestoreMainWindowFunc&& func); void SetWindowRectAutoSaveCallback(NotifySetWindowRectAutoSaveFunc&& func); virtual bool IsModal() const { return false; } virtual bool IsApplicationModal() const { return false; } bool IsDialogWindow() const; WSError NotifySubModalTypeChange(SubWindowModalType subWindowModalType) override; void RegisterSubModalTypeChangeCallback(NotifySubModalTypeChangeFunc&& func); void RegisterMainModalTypeChangeCallback(NotifyMainModalTypeChangeFunc&& func); /* * PC Window Layout */ void SetIsLayoutFullScreen(bool isLayoutFullScreen); bool IsLayoutFullScreen() const; /** * Window Immersive */ WSError OnNeedAvoid(bool status) override; AvoidArea GetAvoidAreaByTypeInner(AvoidAreaType type); AvoidArea GetAvoidAreaByType(AvoidAreaType type) override; WSError GetAllAvoidAreas(std::map& avoidAreas) override; WSError SetSystemBarProperty(WindowType type, SystemBarProperty systemBarProperty); void SetIsStatusBarVisible(bool isVisible); WSError SetIsStatusBarVisibleInner(bool isVisible); WSError UpdateAvoidArea(const sptr& avoidArea, AvoidAreaType type) override; void UpdateRotationAvoidArea(); bool CheckGetAvoidAreaAvailable(AvoidAreaType type) override; bool GetIsDisplayStatusBarTemporarily() const; void SetIsDisplayStatusBarTemporarily(bool isTemporary); void SetIsLastFrameLayoutFinishedFunc(IsLastFrameLayoutFinishedFunc&& func); void RetrieveStatusBarDefaultVisibility(); void RegisterNeedAvoidCallback(NotifyNeedAvoidFunc&& callback); void RegisterSystemBarPropertyChangeCallback(NotifySystemBarPropertyChangeFunc&& callback); void MarkAvoidAreaAsDirty(); void SetAbilitySessionInfo(std::shared_ptr abilityInfo); void SetWindowDragHotAreaListener(const NotifyWindowDragHotAreaFunc& func); void SetSessionEventParam(SessionEventParam param); void SetSessionRectChangeCallback(const NotifySessionRectChangeFunc& func); void SetKeyboardGravityChangeCallback(const NotifyKeyboardGravityChangeFunc& func); void SetAdjustKeyboardLayoutCallback(const NotifyKeyboardLayoutAdjustFunc& func); void SetSkipDraw(bool skip); virtual void SetSkipSelfWhenShowOnVirtualScreen(bool isSkip); WMError SetUniqueDensityDpi(bool useUnique, float dpi); bool IsAnco() const override; void SetBlankFlag(bool isAddBlank) override; bool GetBlankFlag() const override; void SetBufferAvailableCallbackEnable(bool enable); bool GetBufferAvailableCallbackEnable() const override; int32_t GetCollaboratorType() const; WSRect GetLastSafeRect() const; WSRect GetSessionTargetRect() const; std::string GetUpdatedIconPath() const; std::string GetSessionSnapshotFilePath() const; int32_t GetParentPersistentId() const; int32_t GetMainSessionId(); virtual int32_t GetMissionId() const { return persistentId_; }; Orientation GetRequestedOrientation() const; std::vector> GetSubSession() const; std::vector> GetToastSession() const; std::shared_ptr GetAbilityInfo() const; std::string GetWindowNameAllType() const; SubWindowModalType GetSubWindowModalType() const; int32_t GetOriPosYBeforeRaisedByKeyboard() const; std::string GetClientIdentityToken() const; // Session recover bool IsRecovered() const { return isRecovered_; } void SetRecovered(bool isRecovered) { isRecovered_ = isRecovered; } bool IsVisible() const; bool IsDecorEnable() const; bool IsAppSession() const; bool IsAppOrLowerSystemSession() const; bool IsSystemSessionAboveApp() const; bool IsTurnScreenOn() const; bool IsKeepScreenOn() const; bool IsShowWhenLocked() const; bool GetShowWhenLockedFlagValue() const; bool IsFloatingWindowAppType() const; bool IsNeedDefaultAnimation() const; bool IsDirtyWindow(); void SetSystemTouchable(bool touchable) override; bool IsVisibleForAccessibility() const; bool IsDeviceWakeupByApplication() const; void SetStartingWindowExitAnimationFlag(bool enable); bool NeedStartingWindowExitAnimation() const override; void NotifyWindowVisibility(); WSError OnShowWhenLocked(bool showWhenLocked); void SaveUpdatedIcon(const std::shared_ptr& icon); void NotifyTouchOutside(); bool CheckTouchOutsideCallbackRegistered(); void UpdateNativeVisibility(bool visible); void DumpSessionElementInfo(const std::vector& params); void NotifyForceHideChange(bool hide); WSError BindDialogSessionTarget(const sptr& sceneSession); void DumpSessionInfo(std::vector& info) const; bool AddSubSession(const sptr& subSession); bool RemoveSubSession(int32_t persistentId); bool AddToastSession(const sptr& toastSession); bool RemoveToastSession(int32_t persistentId); void NotifySessionForeground(uint32_t reason, bool withAnimation); void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits); void RegisterSessionChangeCallback(const sptr& sessionChangeCallback); void RegisterForceSplitListener(const NotifyForceSplitFunc& func); void SetUpdatePrivateStateAndNotifyFunc(const UpdatePrivateStateAndNotifyFunc& func); /* * Window Input Event */ void RegisterTouchOutsideCallback(NotifyTouchOutsideFunc&& callback); /* * Window Rotation */ void RegisterRequestedOrientationChangeCallback(NotifyReqOrientationChangeFunc&& callback); /** * Window Animation */ void RegisterIsCustomAnimationPlayingCallback(NotifyIsCustomAnimationPlayingCallback&& callback); void RegisterDefaultAnimationFlagChangeCallback(NotifyWindowAnimationFlagChangeFunc&& callback); /* * Window Visibility */ void SetNotifyVisibleChangeFunc(const NotifyVisibleChangeFunc& func); /* * Window Lifecycle */ void RegisterUpdateAppUseControlCallback(UpdateAppUseControlFunc&& callback); void NotifyUpdateAppUseControl(ControlAppType type, bool isNeedControl); void ClearSpecificSessionCbMap(); void RegisterShowWhenLockedCallback(NotifyShowWhenLockedFunc&& callback); void RegisterForceHideChangeCallback(NotifyForceHideChangeFunc&& callback); void RegisterClearCallbackMapCallback(ClearCallbackMapFunc&& callback); virtual WSError HideSync() { return WSError::WS_DO_NOTHING; } void SendPointerEventToUI(std::shared_ptr pointerEvent); bool SendKeyEventToUI(std::shared_ptr keyEvent, bool isPreImeEvent = false); bool IsStartMoving() override; void SetIsStartMoving(bool startMoving); bool IsSystemSpecificSession() const; void SetIsSystemSpecificSession(bool isSystemSpecificSession); void SetShouldHideNonSecureWindows(bool shouldHide); void UpdateExtWindowFlags(int32_t extPersistentId, const ExtensionWindowFlags& extWindowFlags, const ExtensionWindowFlags& extWindowActions); ExtensionWindowFlags GetCombinedExtWindowFlags(); void RemoveExtWindowFlags(int32_t extPersistentId); void ClearExtWindowFlags(); void NotifyDisplayMove(DisplayId from, DisplayId to); void NotifySessionFullScreen(bool fullScreen); void SetDefaultDisplayIdIfNeed(); void SetSessionState(SessionState state) override; void UpdateSessionState(SessionState state) override; void SetForceHideState(ForceHideState forceHideState); ForceHideState GetForceHideState() const; bool IsTemporarilyShowWhenLocked() const; void SetTemporarilyShowWhenLocked(bool isTemporarilyShowWhenLocked); std::shared_ptr keepScreenLock_; static const wptr GetEnterWindow(); static void ClearEnterWindow(); static MaximizeMode maximizeMode_; static uint32_t GetWindowDragHotAreaType(uint32_t type, int32_t pointerX, int32_t pointerY); static void AddOrUpdateWindowDragHotArea(uint32_t type, const WSRect& area); WSError UpdateRectChangeListenerRegistered(bool isRegister) override; int32_t GetCustomDecorHeight() override { return customDecorHeight_; } void SetCustomDecorHeight(int32_t height) override { if (height < MIN_DECOR_HEIGHT || height > MAX_DECOR_HEIGHT) { return; } customDecorHeight_ = height; } WMError UpdateSessionPropertyByAction(const sptr& property, WSPropertyChangeAction action) override; void SetSessionChangeByActionNotifyManagerListener(const SessionChangeByActionNotifyManagerFunc& func); /* * UIExtension */ bool IsShowOnLockScreen(uint32_t lockScreenZOrder); void AddExtensionTokenInfo(const UIExtensionTokenInfo& tokenInfo); void RemoveExtensionTokenInfo(const sptr& abilityToken); void CheckExtensionOnLockScreenToClose(); void CloseExtensionSync(const UIExtensionTokenInfo& tokenInfo); void OnNotifyAboveLockScreen(); void AddModalUIExtension(const ExtensionWindowEventInfo& extensionInfo); void RemoveModalUIExtension(int32_t persistentId); void UpdateModalUIExtension(const ExtensionWindowEventInfo& extensionInfo); std::optional GetLastModalUIExtensionEventInfo(); Vector2f GetSessionGlobalPosition(bool useUIExtension); void AddUIExtSurfaceNodeId(uint64_t surfaceNodeId, int32_t persistentId); void RemoveUIExtSurfaceNodeId(int32_t persistentId); int32_t GetUIExtPersistentIdBySurfaceNodeId(uint64_t surfaceNodeId) const; bool IsFreeMultiWindowMode() const { return systemConfig_.IsFreeMultiWindowMode(); } WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) override; bool IsPcOrPadEnableActivation() const; void UnregisterSessionChangeListeners() override; // WMSPipeline-related: only accessed on SSM thread uint32_t UpdateUIParam(const SessionUIParam& uiParam); // update visible session, return dirty flags uint32_t UpdateUIParam(); // update invisible session, return dirty flags void SetPostProcessFocusState(PostProcessFocusState state); PostProcessFocusState GetPostProcessFocusState() const; void ResetPostProcessFocusState(); void SetPostProcessProperty(bool state); bool GetPostProcessProperty() const; void PostProcessNotifyAvoidArea(); bool IsImmersiveType() const; bool SetFrameGravity(Gravity gravity); /* * Gesture Back */ bool GetGestureBackEnabled(); bool GetEnableGestureBackHadSet(); /* * Move Drag */ void SetAppDragResizeType(DragResizeType dragResizeType) { appDragResizeType_ = dragResizeType; } DragResizeType GetAppDragResizeType() const { return appDragResizeType_; } /* * Window Layout */ void ResetSizeChangeReasonIfDirty(); /* * PC Window */ void SetTitleAndDockHoverShowChangeCallback(NotifyTitleAndDockHoverShowChangeFunc&& func); protected: void NotifySessionRectChange(const WSRect& rect, const SizeChangeReason& reason = SizeChangeReason::UNDEFINED); void NotifyIsCustomAnimationPlaying(bool isPlaying); void SetMoveDragCallback(); std::string GetRatioPreferenceKey(); WSError NotifyClientToUpdateRectTask(const std::string& updateReason, std::shared_ptr rsTransaction); bool CheckPermissionWithPropertyAnimation(const sptr& property) const; std::string GetRectInfo(const WSRect& rect) { using std::to_string; return "[" + to_string(rect.width_) + ", " + to_string(rect.height_) + "; " + to_string(rect.posX_) + ", " + to_string(rect.posY_) + "]"; } /* * Window Pipeline */ bool UpdateVisibilityInner(bool visibility); bool UpdateInteractiveInner(bool interactive); virtual void NotifyClientToUpdateInteractive(bool interactive) {} bool PipelineNeedNotifyClientToUpdateRect() const; bool UpdateRectInner(const SessionUIParam& uiParam, SizeChangeReason reason); bool NotifyServerToUpdateRect(const SessionUIParam& uiParam, SizeChangeReason reason); bool IsTransformNeedChange(float scaleX, float scaleY, float pivotX, float pivotY); bool UpdateScaleInner(float scaleX, float scaleY, float pivotX, float pivotY); bool UpdateZOrderInner(uint32_t zOrder); /** * Window Immersive */ virtual void NotifyClientToUpdateAvoidArea(); bool PipelineNeedNotifyClientToUpdateAvoidArea(uint32_t dirty) const; /* * Gesture Back */ void UpdateGestureBackEnabled() override; sptr specificCallback_ = nullptr; sptr sessionChangeCallback_ = nullptr; sptr moveDragController_ = nullptr; sptr keyboardPanelSession_ = nullptr; sptr keyboardSession_ = nullptr; NotifyKeyboardGravityChangeFunc keyboardGravityChangeFunc_; NotifyKeyboardLayoutAdjustFunc adjustKeyboardLayoutFunc_; /* * Window Hierarchy */ NotifyMainWindowTopmostChangeFunc mainWindowTopmostChangeFunc_; /* * Window Immersive */ NotifyNeedAvoidFunc onNeedAvoid_; NotifySystemBarPropertyChangeFunc onSystemBarPropertyChange_; /** * PC Window */ NotifyRestoreMainWindowFunc onRestoreMainWindowFunc_; NotifySetWindowRectAutoSaveFunc onSetWindowRectAutoSaveFunc_; NotifySubModalTypeChangeFunc onSubModalTypeChange_; NotifyMainModalTypeChangeFunc onMainModalTypeChange_; /* * PiP Window */ NotifyPrepareClosePiPSessionFunc onPrepareClosePiPSession_; /* * Window Layout */ NotifyDefaultDensityEnabledFunc onDefaultDensityEnabledFunc_; /* * Window Lifecycle */ NotifyShowWhenLockedFunc onShowWhenLockedFunc_; NotifyForceHideChangeFunc onForceHideChangeFunc_; ClearCallbackMapFunc clearCallbackMapFunc_; UpdateAppUseControlFunc onUpdateAppUseControlFunc_; std::unordered_map appUseControlMap_; /* * PC Window */ NotifyTitleAndDockHoverShowChangeFunc onTitleAndDockHoverShowChangeFunc_; private: void NotifyAccessibilityVisibilityChange(); void CalculateCombinedExtWindowFlags(); void HandleStyleEvent(MMI::WindowArea area) override; WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY); /** * Window Immersive */ void CalculateAvoidAreaRect(WSRect& rect, WSRect& avoidRect, AvoidArea& avoidArea) const; void GetSystemAvoidArea(WSRect& rect, AvoidArea& avoidArea); void GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea); void GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea); void GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea) const; /* * Window Lifecycle */ bool CheckIdentityTokenIfMatched(const std::string& identityToken); bool CheckPidIfMatched(); // session lifecycle funcs WSError ForegroundTask(const sptr& property); /* * Move Drag */ bool IsDragResizeWhenEnd(SizeChangeReason reason); void SetDragResizeTypeDuringDrag(DragResizeType dragResizeType) { dragResizeTypeDuringDrag_ = dragResizeType; } DragResizeType GetDragResizeTypeDuringDrag() const { return dragResizeTypeDuringDrag_; } void HandleSessionDragEvent(SessionEvent event); /* * Gesture Back */ WMError SetGestureBackEnabled(bool isEnabled) override; /* * UIExtension */ void UpdateAllModalUIExtensions(const WSRect& globalRect); #ifdef DEVICE_STATUS_ENABLE void RotateDragWindow(std::shared_ptr rsTransaction); #endif // DEVICE_STATUS_ENABLE void OnMoveDragCallback(const SizeChangeReason& reason); void HandleCompatibleModeMoveDrag(WSRect& rect, const SizeChangeReason& reason, bool isSupportDragInPcCompatibleMode); void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr); bool FixRectByAspectRatio(WSRect& rect); bool SaveAspectRatio(float ratio); void NotifyPropertyWhenConnect(); WSError RaiseAppMainWindowToTop() override; void SetSurfaceBounds(const WSRect& rect); void UpdateWinRectForSystemBar(WSRect& rect); bool IsKeyboardNeedLeftOffset(bool isPhone, const sptr& sessionProperty); bool UpdateInputMethodSessionRect(const WSRect& rect, WSRect& newWinRect, WSRect& newRequestRect); bool IsMovableWindowType(); bool IsFullScreenMovable(); void HandleCastScreenConnection(SessionInfo& info, sptr session); void UpdateSessionRectInner(const WSRect& rect, const SizeChangeReason& reason); void FixKeyboardPositionByKeyboardPanel(sptr panelSession, sptr keyboardSession); WMError HandleUpdatePropertyByAction(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateTurnScreenOn(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateKeepScreenOn(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateFocusable(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateTouchable(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateSetBrightness(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateOrientation(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdatePrivacyMode(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateSnapshotSkip(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateMaximizeState(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateOtherProps(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateStatusProps(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateNavigationProps(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateNavigationIndicatorProps(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateFlags(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateMode(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateAnimationFlag(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateTouchHotArea(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateDecorEnable(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateWindowLimits(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateDragenabled(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateRaiseenabled(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateHideNonSystemFloatingWindows(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateTextfieldAvoidInfo(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateWindowMask(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateTopmost(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError HandleActionUpdateMainWindowTopmost(const sptr& property, WSPropertyChangeAction action); WMError HandleActionUpdateWindowModeSupportType(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); WMError ProcessUpdatePropertyByAction(const sptr& property, const sptr& sceneSession, WSPropertyChangeAction action); void HandleSpecificSystemBarProperty(WindowType type, const sptr& property, const sptr& sceneSession); void SetWindowFlags(const sptr& sceneSession, const sptr& property); void NotifySessionChangeByActionNotifyManager(const sptr& sceneSession, const sptr& property, WSPropertyChangeAction action); /* * PiP Window */ NotifySessionPiPControlStatusChangeFunc sessionPiPControlStatusChangeFunc_; NotifyAutoStartPiPStatusChangeFunc autoStartPiPStatusChangeFunc_; PiPTemplateInfo pipTemplateInfo_ = {0, 0, {}}; NotifyForceSplitFunc forceSplitFunc_; UpdatePrivateStateAndNotifyFunc updatePrivateStateAndNotifyFunc_; static wptr enterSession_; static std::mutex enterSessionMutex_; int32_t collaboratorType_ = CollaboratorType::DEFAULT_TYPE; mutable std::mutex sessionChangeCbMutex_; WSRect lastSafeRect = { 0, 0, 0, 0 }; std::vector> subSession_; std::vector> toastSession_; std::atomic_bool isDeviceWakeupByApplication_ { false }; std::atomic_bool needStartingWindowExitAnimation_ { true }; bool needDefaultAnimationFlag_ = true; SessionEventParam sessionEventParam_ = { 0, 0, 0, 0, 0 }; std::atomic_bool isStartMoving_ { false }; std::atomic_bool isVisibleForAccessibility_ { true }; bool isSystemSpecificSession_ { false }; /* * UIExtension */ std::atomic_bool shouldHideNonSecureWindows_ { false }; std::shared_mutex combinedExtWindowFlagsMutex_; ExtensionWindowFlags combinedExtWindowFlags_ { 0 }; std::map extWindowFlagsMap_; std::vector extensionTokenInfos_; int32_t customDecorHeight_ = 0; ForceHideState forceHideState_ { ForceHideState::NOT_HIDDEN }; static std::shared_mutex windowDragHotAreaMutex_; static std::map windowDragHotAreaMap_; int32_t oriPosYBeforeRaisedByKeyboard_ = 0; std::atomic_bool isTemporarilyShowWhenLocked_ { false }; std::shared_mutex modalUIExtensionInfoListMutex_; std::vector modalUIExtensionInfoList_; mutable std::shared_mutex uiExtNodeIdToPersistentIdMapMutex_; std::map uiExtNodeIdToPersistentIdMap_; std::string clientIdentityToken_ = { "" }; SessionChangeByActionNotifyManagerFunc sessionChangeByActionNotifyManagerFunc_; bool isAddBlank_ = false; bool bufferAvailableCallbackEnable_ = false; bool isScreenAngleMismatch_ = false; uint32_t targetScreenWidth_ = 0; uint32_t targetScreenHeight_ = 0; // Session recover bool isRecovered_ = false; // WMSPipeline-related: only accessed on SSM thread PostProcessFocusState postProcessFocusState_; bool postProcessProperty_ { false }; /* * Move Drag */ DragResizeType appDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED; DragResizeType dragResizeTypeDuringDrag_ = DragResizeType::RESIZE_TYPE_UNDEFINED; /** * Gesture Back */ bool isEnableGestureBack_ { true }; bool isEnableGestureBackHadSet_ { false }; /** * Window Visibility */ NotifyVisibleChangeFunc notifyVisibleChangeFunc_; /* * Window Input Event */ NotifyTouchOutsideFunc onTouchOutside_; /** * Window Immersive */ std::atomic_bool isDisplayStatusBarTemporarily_ { false }; bool isStatusBarVisible_ = true; IsLastFrameLayoutFinishedFunc isLastFrameLayoutFinishedFunc_; /* * Window Rotation */ NotifyReqOrientationChangeFunc onRequestedOrientationChange_; /** * Window Animation */ NotifyIsCustomAnimationPlayingCallback onIsCustomAnimationPlaying_; NotifyWindowAnimationFlagChangeFunc onWindowAnimationFlagChange_; /* * PC Window Layout */ bool isLayoutFullScreen_ { false }; }; } // namespace OHOS::Rosen #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_H