1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License. 5e0dac50fSopenharmony_ci * You may obtain a copy of the License at 6e0dac50fSopenharmony_ci * 7e0dac50fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e0dac50fSopenharmony_ci * 9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and 13e0dac50fSopenharmony_ci * limitations under the License. 14e0dac50fSopenharmony_ci */ 15e0dac50fSopenharmony_ci 16e0dac50fSopenharmony_ci#ifndef OHOS_ROSEN_WINDOW_SCENE_SESSION_H 17e0dac50fSopenharmony_ci#define OHOS_ROSEN_WINDOW_SCENE_SESSION_H 18e0dac50fSopenharmony_ci#include <list> 19e0dac50fSopenharmony_ci#include <mutex> 20e0dac50fSopenharmony_ci#include <shared_mutex> 21e0dac50fSopenharmony_ci#include <vector> 22e0dac50fSopenharmony_ci 23e0dac50fSopenharmony_ci#include <event_handler.h> 24e0dac50fSopenharmony_ci 25e0dac50fSopenharmony_ci#include "accessibility_element_info.h" 26e0dac50fSopenharmony_ci#include "interfaces/include/ws_common.h" 27e0dac50fSopenharmony_ci#include "session/container/include/zidl/session_stage_interface.h" 28e0dac50fSopenharmony_ci#include "session/host/include/zidl/session_stub.h" 29e0dac50fSopenharmony_ci#include "session/host/include/scene_persistence.h" 30e0dac50fSopenharmony_ci#include "wm_common.h" 31e0dac50fSopenharmony_ci#include "occupied_area_change_info.h" 32e0dac50fSopenharmony_ci#include "window_visibility_info.h" 33e0dac50fSopenharmony_ci#include "pattern_detach_callback_interface.h" 34e0dac50fSopenharmony_ci 35e0dac50fSopenharmony_cinamespace OHOS::MMI { 36e0dac50fSopenharmony_ciclass PointerEvent; 37e0dac50fSopenharmony_ciclass KeyEvent; 38e0dac50fSopenharmony_ciclass AxisEvent; 39e0dac50fSopenharmony_cienum class WindowArea; 40e0dac50fSopenharmony_ci} // namespace OHOS::MMI 41e0dac50fSopenharmony_ci 42e0dac50fSopenharmony_cinamespace OHOS::Media { 43e0dac50fSopenharmony_ciclass PixelMap; 44e0dac50fSopenharmony_ci} // namespace OHOS::Media 45e0dac50fSopenharmony_ci 46e0dac50fSopenharmony_cinamespace OHOS::Rosen { 47e0dac50fSopenharmony_ciclass RSSurfaceNode; 48e0dac50fSopenharmony_ciclass RSTransaction; 49e0dac50fSopenharmony_ciclass RSSyncTransactionController; 50e0dac50fSopenharmony_ciusing NotifySessionRectChangeFunc = std::function<void(const WSRect& rect, 51e0dac50fSopenharmony_ci const SizeChangeReason reason, const DisplayId displayId)>; 52e0dac50fSopenharmony_ciusing NotifyPendingSessionActivationFunc = std::function<void(SessionInfo& info)>; 53e0dac50fSopenharmony_ciusing NotifyChangeSessionVisibilityWithStatusBarFunc = std::function<void(SessionInfo& info, const bool visible)>; 54e0dac50fSopenharmony_ciusing NotifySessionStateChangeFunc = std::function<void(const SessionState& state)>; 55e0dac50fSopenharmony_ciusing NotifyBufferAvailableChangeFunc = std::function<void(const bool isAvailable)>; 56e0dac50fSopenharmony_ciusing NotifyLeashWindowSurfaceNodeChangedFunc = std::function<void()>; 57e0dac50fSopenharmony_ciusing NotifySessionStateChangeNotifyManagerFunc = std::function<void(int32_t persistentId, const SessionState& state)>; 58e0dac50fSopenharmony_ciusing NotifyRequestFocusStatusNotifyManagerFunc = 59e0dac50fSopenharmony_ci std::function<void(int32_t persistentId, const bool isFocused, const bool byForeground, FocusChangeReason reason)>; 60e0dac50fSopenharmony_ciusing NotifyBackPressedFunc = std::function<void(const bool needMoveToBackground)>; 61e0dac50fSopenharmony_ciusing NotifySessionFocusableChangeFunc = std::function<void(const bool isFocusable)>; 62e0dac50fSopenharmony_ciusing NotifySessionTouchableChangeFunc = std::function<void(const bool touchable)>; 63e0dac50fSopenharmony_ciusing NotifyClickFunc = std::function<void(bool requestFocus)>; 64e0dac50fSopenharmony_ciusing NotifyTerminateSessionFunc = std::function<void(const SessionInfo& info)>; 65e0dac50fSopenharmony_ciusing NotifyTerminateSessionFuncNew = 66e0dac50fSopenharmony_ci std::function<void(const SessionInfo& info, bool needStartCaller, bool isFromBroker)>; 67e0dac50fSopenharmony_ciusing NotifyTerminateSessionFuncTotal = std::function<void(const SessionInfo& info, TerminateType terminateType)>; 68e0dac50fSopenharmony_ciusing NofitySessionLabelUpdatedFunc = std::function<void(const std::string& label)>; 69e0dac50fSopenharmony_ciusing NofitySessionIconUpdatedFunc = std::function<void(const std::string& iconPath)>; 70e0dac50fSopenharmony_ciusing NotifySessionExceptionFunc = std::function<void(const SessionInfo& info, bool needRemoveSession)>; 71e0dac50fSopenharmony_ciusing NotifySessionSnapshotFunc = std::function<void(const int32_t& persistentId)>; 72e0dac50fSopenharmony_ciusing NotifyPendingSessionToForegroundFunc = std::function<void(const SessionInfo& info)>; 73e0dac50fSopenharmony_ciusing NotifyPendingSessionToBackgroundForDelegatorFunc = std::function<void(const SessionInfo& info, 74e0dac50fSopenharmony_ci bool shouldBackToCaller)>; 75e0dac50fSopenharmony_ciusing NotifyClickModalSpecificWindowOutsideFunc = std::function<void()>; 76e0dac50fSopenharmony_ciusing NotifyRaiseToTopForPointDownFunc = std::function<void()>; 77e0dac50fSopenharmony_ciusing NotifyUIRequestFocusFunc = std::function<void()>; 78e0dac50fSopenharmony_ciusing NotifyUILostFocusFunc = std::function<void()>; 79e0dac50fSopenharmony_ciusing NotifySessionInfoLockedStateChangeFunc = std::function<void(const bool lockedState)>; 80e0dac50fSopenharmony_ciusing GetStateFromManagerFunc = std::function<bool(const ManagerState key)>; 81e0dac50fSopenharmony_ciusing NotifySystemSessionPointerEventFunc = std::function<void(std::shared_ptr<MMI::PointerEvent> pointerEvent)>; 82e0dac50fSopenharmony_ciusing NotifySessionInfoChangeNotifyManagerFunc = std::function<void(int32_t persistentid)>; 83e0dac50fSopenharmony_ciusing NotifySystemSessionKeyEventFunc = std::function<bool(std::shared_ptr<MMI::KeyEvent> keyEvent, 84e0dac50fSopenharmony_ci bool isPreImeEvent)>; 85e0dac50fSopenharmony_ciusing NotifyContextTransparentFunc = std::function<void()>; 86e0dac50fSopenharmony_ciusing NotifyFrameLayoutFinishFunc = std::function<void()>; 87e0dac50fSopenharmony_ciusing VisibilityChangedDetectFunc = std::function<void(const int32_t pid, const bool isVisible, 88e0dac50fSopenharmony_ci const bool newIsVisible)>; 89e0dac50fSopenharmony_ciusing AcquireRotateAnimationConfigFunc = std::function<void(RotateAnimationConfig& config)>; 90e0dac50fSopenharmony_ci 91e0dac50fSopenharmony_ciclass ILifecycleListener { 92e0dac50fSopenharmony_cipublic: 93e0dac50fSopenharmony_ci virtual void OnActivation() {} 94e0dac50fSopenharmony_ci virtual void OnConnect() {} 95e0dac50fSopenharmony_ci virtual void OnForeground() {} 96e0dac50fSopenharmony_ci virtual void OnBackground() {} 97e0dac50fSopenharmony_ci virtual void OnDisconnect() {} 98e0dac50fSopenharmony_ci virtual void OnLayoutFinished() {} 99e0dac50fSopenharmony_ci virtual void OnDrawingCompleted() {} 100e0dac50fSopenharmony_ci virtual void OnExtensionDied() {} 101e0dac50fSopenharmony_ci virtual void OnExtensionTimeout(int32_t errorCode) {} 102e0dac50fSopenharmony_ci virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 103e0dac50fSopenharmony_ci int64_t uiExtensionIdLevel) {} 104e0dac50fSopenharmony_ci}; 105e0dac50fSopenharmony_ci 106e0dac50fSopenharmony_cienum class LifeCycleTaskType : uint32_t { 107e0dac50fSopenharmony_ci START, 108e0dac50fSopenharmony_ci STOP 109e0dac50fSopenharmony_ci}; 110e0dac50fSopenharmony_ci 111e0dac50fSopenharmony_cienum class DetectTaskState : uint32_t { 112e0dac50fSopenharmony_ci NO_TASK, 113e0dac50fSopenharmony_ci ATTACH_TASK, 114e0dac50fSopenharmony_ci DETACH_TASK 115e0dac50fSopenharmony_ci}; 116e0dac50fSopenharmony_ci 117e0dac50fSopenharmony_cistruct DetectTaskInfo { 118e0dac50fSopenharmony_ci WindowMode taskWindowMode = WindowMode::WINDOW_MODE_UNDEFINED; 119e0dac50fSopenharmony_ci DetectTaskState taskState = DetectTaskState::NO_TASK; 120e0dac50fSopenharmony_ci}; 121e0dac50fSopenharmony_ci 122e0dac50fSopenharmony_ciclass Session : public SessionStub { 123e0dac50fSopenharmony_cipublic: 124e0dac50fSopenharmony_ci friend class HidumpController; 125e0dac50fSopenharmony_ci using Task = std::function<void()>; 126e0dac50fSopenharmony_ci explicit Session(const SessionInfo& info); 127e0dac50fSopenharmony_ci virtual ~Session() = default; 128e0dac50fSopenharmony_ci bool isKeyboardPanelEnabled_ = false; 129e0dac50fSopenharmony_ci void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler>& handler, 130e0dac50fSopenharmony_ci const std::shared_ptr<AppExecFwk::EventHandler>& exportHandler = nullptr); 131e0dac50fSopenharmony_ci 132e0dac50fSopenharmony_ci virtual WSError ConnectInner(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel, 133e0dac50fSopenharmony_ci const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig, 134e0dac50fSopenharmony_ci sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr, 135e0dac50fSopenharmony_ci int32_t pid = -1, int32_t uid = -1, const std::string& identityToken = ""); 136e0dac50fSopenharmony_ci WSError Reconnect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel, 137e0dac50fSopenharmony_ci const std::shared_ptr<RSSurfaceNode>& surfaceNode, sptr<WindowSessionProperty> property = nullptr, 138e0dac50fSopenharmony_ci sptr<IRemoteObject> token = nullptr, int32_t pid = -1, int32_t uid = -1); 139e0dac50fSopenharmony_ci WSError Foreground(sptr<WindowSessionProperty> property, bool isFromClient = false, 140e0dac50fSopenharmony_ci const std::string& identityToken = "") override; 141e0dac50fSopenharmony_ci WSError Background(bool isFromClient = false, const std::string& identityToken = "") override; 142e0dac50fSopenharmony_ci WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override; 143e0dac50fSopenharmony_ci WSError Show(sptr<WindowSessionProperty> property) override; 144e0dac50fSopenharmony_ci WSError Hide() override; 145e0dac50fSopenharmony_ci WSError DrawingCompleted() override; 146e0dac50fSopenharmony_ci void ResetSessionConnectState(); 147e0dac50fSopenharmony_ci void ResetIsActive(); 148e0dac50fSopenharmony_ci 149e0dac50fSopenharmony_ci bool RegisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener); 150e0dac50fSopenharmony_ci bool UnregisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener); 151e0dac50fSopenharmony_ci 152e0dac50fSopenharmony_ci /* 153e0dac50fSopenharmony_ci * Callbacks for ILifecycleListener 154e0dac50fSopenharmony_ci */ 155e0dac50fSopenharmony_ci void NotifyActivation(); 156e0dac50fSopenharmony_ci void NotifyConnect(); 157e0dac50fSopenharmony_ci void NotifyForeground(); 158e0dac50fSopenharmony_ci void NotifyBackground(); 159e0dac50fSopenharmony_ci void NotifyDisconnect(); 160e0dac50fSopenharmony_ci void NotifyLayoutFinished(); 161e0dac50fSopenharmony_ci void NotifyExtensionDied() override; 162e0dac50fSopenharmony_ci void NotifyExtensionTimeout(int32_t errorCode) override; 163e0dac50fSopenharmony_ci void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 164e0dac50fSopenharmony_ci int64_t uiExtensionIdLevel) override; 165e0dac50fSopenharmony_ci 166e0dac50fSopenharmony_ci /* 167e0dac50fSopenharmony_ci * Cross Display Move Drag 168e0dac50fSopenharmony_ci */ 169e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> GetSurfaceNodeForMoveDrag() const; 170e0dac50fSopenharmony_ci 171e0dac50fSopenharmony_ci virtual WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, 172e0dac50fSopenharmony_ci bool needNotifyClient = true); 173e0dac50fSopenharmony_ci virtual WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent); 174e0dac50fSopenharmony_ci 175e0dac50fSopenharmony_ci virtual WSError NotifyClientToUpdateRect(const std::string& updateReason, 176e0dac50fSopenharmony_ci std::shared_ptr<RSTransaction> rsTransaction) { return WSError::WS_OK; } 177e0dac50fSopenharmony_ci WSError TransferBackPressedEventForConsumed(bool& isConsumed); 178e0dac50fSopenharmony_ci WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed, 179e0dac50fSopenharmony_ci bool isPreImeEvent = false); 180e0dac50fSopenharmony_ci WSError TransferFocusActiveEvent(bool isFocusActive); 181e0dac50fSopenharmony_ci WSError TransferFocusStateEvent(bool focusState); 182e0dac50fSopenharmony_ci virtual WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) { return WSError::WS_OK; } 183e0dac50fSopenharmony_ci 184e0dac50fSopenharmony_ci int32_t GetPersistentId() const; 185e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> GetSurfaceNode() const; 186e0dac50fSopenharmony_ci void SetLeashWinSurfaceNode(std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode); 187e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> GetLeashWinSurfaceNode() const; 188e0dac50fSopenharmony_ci std::shared_ptr<Media::PixelMap> GetSnapshot() const; 189e0dac50fSopenharmony_ci std::shared_ptr<Media::PixelMap> Snapshot( 190e0dac50fSopenharmony_ci bool runInFfrt = false, float scaleParam = 0.0f, bool useCurWindow = false) const; 191e0dac50fSopenharmony_ci void SaveSnapshot(bool useFfrt); 192e0dac50fSopenharmony_ci SessionState GetSessionState() const; 193e0dac50fSopenharmony_ci virtual void SetSessionState(SessionState state); 194e0dac50fSopenharmony_ci void SetSessionInfoAncoSceneState(int32_t ancoSceneState); 195e0dac50fSopenharmony_ci void SetSessionInfoTime(const std::string& time); 196e0dac50fSopenharmony_ci void SetSessionInfoAbilityInfo(const std::shared_ptr<AppExecFwk::AbilityInfo>& abilityInfo); 197e0dac50fSopenharmony_ci void SetSessionInfoWant(const std::shared_ptr<AAFwk::Want>& want); 198e0dac50fSopenharmony_ci void SetSessionInfoProcessOptions(const std::shared_ptr<AAFwk::ProcessOptions>& processOptions); 199e0dac50fSopenharmony_ci void ResetSessionInfoResultCode(); 200e0dac50fSopenharmony_ci void SetSessionInfoPersistentId(int32_t persistentId); 201e0dac50fSopenharmony_ci void SetSessionInfoCallerPersistentId(int32_t callerPersistentId); 202e0dac50fSopenharmony_ci void SetSessionInfoContinueState(ContinueState state); 203e0dac50fSopenharmony_ci void SetSessionInfoLockedState(bool lockedState); 204e0dac50fSopenharmony_ci void SetSessionInfoIsClearSession(bool isClearSession); 205e0dac50fSopenharmony_ci void SetSessionInfoAffinity(std::string affinity); 206e0dac50fSopenharmony_ci void GetCloseAbilityWantAndClean(AAFwk::Want& outWant); 207e0dac50fSopenharmony_ci void SetSessionInfo(const SessionInfo& info); 208e0dac50fSopenharmony_ci const SessionInfo& GetSessionInfo() const; 209e0dac50fSopenharmony_ci void SetScreenId(uint64_t screenId); 210e0dac50fSopenharmony_ci WindowType GetWindowType() const; 211e0dac50fSopenharmony_ci float GetAspectRatio() const; 212e0dac50fSopenharmony_ci WSError SetAspectRatio(float ratio) override; 213e0dac50fSopenharmony_ci WSError SetSessionProperty(const sptr<WindowSessionProperty>& property); 214e0dac50fSopenharmony_ci sptr<WindowSessionProperty> GetSessionProperty() const; 215e0dac50fSopenharmony_ci void SetSessionRect(const WSRect& rect); 216e0dac50fSopenharmony_ci WSRect GetSessionRect() const; 217e0dac50fSopenharmony_ci WSRect GetSessionGlobalRect() const; 218e0dac50fSopenharmony_ci void SetSessionGlobalRect(const WSRect& rect); 219e0dac50fSopenharmony_ci void SetSessionRequestRect(const WSRect& rect); 220e0dac50fSopenharmony_ci WSRect GetSessionRequestRect() const; 221e0dac50fSopenharmony_ci std::string GetWindowName() const; 222e0dac50fSopenharmony_ci WSRect GetLastLayoutRect() const; 223e0dac50fSopenharmony_ci WSRect GetLayoutRect() const; 224e0dac50fSopenharmony_ci void SetClientRect(const WSRect& rect); 225e0dac50fSopenharmony_ci WSRect GetClientRect() const; 226e0dac50fSopenharmony_ci 227e0dac50fSopenharmony_ci virtual WSError SetActive(bool active); 228e0dac50fSopenharmony_ci virtual WSError UpdateSizeChangeReason(SizeChangeReason reason); 229e0dac50fSopenharmony_ci SizeChangeReason GetSizeChangeReason() const { return reason_; } 230e0dac50fSopenharmony_ci virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason, 231e0dac50fSopenharmony_ci const std::string& updateReason, const std::shared_ptr<RSTransaction>& rsTransaction = nullptr); 232e0dac50fSopenharmony_ci WSError UpdateDensity(); 233e0dac50fSopenharmony_ci WSError UpdateOrientation(); 234e0dac50fSopenharmony_ci 235e0dac50fSopenharmony_ci void SetShowRecent(bool showRecent); 236e0dac50fSopenharmony_ci void SetSystemActive(bool systemActive); 237e0dac50fSopenharmony_ci bool GetShowRecent() const; 238e0dac50fSopenharmony_ci void SetOffset(float x, float y); 239e0dac50fSopenharmony_ci float GetOffsetX() const; 240e0dac50fSopenharmony_ci float GetOffsetY() const; 241e0dac50fSopenharmony_ci void SetBounds(const WSRectF& bounds); 242e0dac50fSopenharmony_ci WSRectF GetBounds(); 243e0dac50fSopenharmony_ci void SetRotation(Rotation rotation); 244e0dac50fSopenharmony_ci Rotation GetRotation() const; 245e0dac50fSopenharmony_ci void SetBufferAvailable(bool bufferAvailable); 246e0dac50fSopenharmony_ci bool GetBufferAvailable() const; 247e0dac50fSopenharmony_ci void SetNeedSnapshot(bool needSnapshot); 248e0dac50fSopenharmony_ci virtual void SetExitSplitOnBackground(bool isExitSplitOnBackground); 249e0dac50fSopenharmony_ci virtual bool IsExitSplitOnBackground() const; 250e0dac50fSopenharmony_ci virtual bool NeedStartingWindowExitAnimation() const { return true; } 251e0dac50fSopenharmony_ci 252e0dac50fSopenharmony_ci void SetPendingSessionActivationEventListener(const NotifyPendingSessionActivationFunc& func); 253e0dac50fSopenharmony_ci void SetChangeSessionVisibilityWithStatusBarEventListener( 254e0dac50fSopenharmony_ci const NotifyChangeSessionVisibilityWithStatusBarFunc& func); 255e0dac50fSopenharmony_ci void SetTerminateSessionListener(const NotifyTerminateSessionFunc& func); 256e0dac50fSopenharmony_ci WSError TerminateSessionNew(const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker); 257e0dac50fSopenharmony_ci void SetTerminateSessionListenerNew(const NotifyTerminateSessionFuncNew& func); 258e0dac50fSopenharmony_ci void SetSessionExceptionListener(const NotifySessionExceptionFunc& func, bool fromJsScene); 259e0dac50fSopenharmony_ci void SetSessionSnapshotListener(const NotifySessionSnapshotFunc& func); 260e0dac50fSopenharmony_ci WSError TerminateSessionTotal(const sptr<AAFwk::SessionInfo> info, TerminateType terminateType); 261e0dac50fSopenharmony_ci void SetTerminateSessionListenerTotal(const NotifyTerminateSessionFuncTotal& func); 262e0dac50fSopenharmony_ci WSError Clear(bool needStartCaller = false); 263e0dac50fSopenharmony_ci WSError SetSessionLabel(const std::string& label); 264e0dac50fSopenharmony_ci void SetUpdateSessionLabelListener(const NofitySessionLabelUpdatedFunc& func); 265e0dac50fSopenharmony_ci WSError SetSessionIcon(const std::shared_ptr<Media::PixelMap>& icon); 266e0dac50fSopenharmony_ci void SetUpdateSessionIconListener(const NofitySessionIconUpdatedFunc& func); 267e0dac50fSopenharmony_ci void SetSessionStateChangeListenser(const NotifySessionStateChangeFunc& func); 268e0dac50fSopenharmony_ci void SetBufferAvailableChangeListener(const NotifyBufferAvailableChangeFunc& func); 269e0dac50fSopenharmony_ci virtual void UnregisterSessionChangeListeners(); 270e0dac50fSopenharmony_ci void SetSessionStateChangeNotifyManagerListener(const NotifySessionStateChangeNotifyManagerFunc& func); 271e0dac50fSopenharmony_ci void SetSessionInfoChangeNotifyManagerListener(const NotifySessionInfoChangeNotifyManagerFunc& func); 272e0dac50fSopenharmony_ci void SetRequestFocusStatusNotifyManagerListener(const NotifyRequestFocusStatusNotifyManagerFunc& func); 273e0dac50fSopenharmony_ci void SetClickModalSpecificWindowOutsideListener(const NotifyClickModalSpecificWindowOutsideFunc& func); 274e0dac50fSopenharmony_ci void SetNotifyUIRequestFocusFunc(const NotifyUIRequestFocusFunc& func); 275e0dac50fSopenharmony_ci void SetNotifyUILostFocusFunc(const NotifyUILostFocusFunc& func); 276e0dac50fSopenharmony_ci void SetGetStateFromManagerListener(const GetStateFromManagerFunc& func); 277e0dac50fSopenharmony_ci void SetLeashWindowSurfaceNodeChangedListener(const NotifyLeashWindowSurfaceNodeChangedFunc& func); 278e0dac50fSopenharmony_ci 279e0dac50fSopenharmony_ci void SetSystemConfig(const SystemSessionConfig& systemConfig); 280e0dac50fSopenharmony_ci void SetSnapshotScale(const float snapshotScale); 281e0dac50fSopenharmony_ci void SetBackPressedListenser(const NotifyBackPressedFunc& func); 282e0dac50fSopenharmony_ci virtual WSError ProcessBackEvent(); // send back event to session_stage 283e0dac50fSopenharmony_ci 284e0dac50fSopenharmony_ci sptr<ScenePersistence> GetScenePersistence() const; 285e0dac50fSopenharmony_ci void SetParentSession(const sptr<Session>& session); 286e0dac50fSopenharmony_ci sptr<Session> GetParentSession() const; 287e0dac50fSopenharmony_ci sptr<Session> GetMainSession(); 288e0dac50fSopenharmony_ci void BindDialogToParentSession(const sptr<Session>& session); 289e0dac50fSopenharmony_ci void RemoveDialogToParentSession(const sptr<Session>& session); 290e0dac50fSopenharmony_ci std::vector<sptr<Session>> GetDialogVector() const; 291e0dac50fSopenharmony_ci void ClearDialogVector(); 292e0dac50fSopenharmony_ci WSError NotifyDestroy(); 293e0dac50fSopenharmony_ci WSError NotifyCloseExistPipWindow(); 294e0dac50fSopenharmony_ci 295e0dac50fSopenharmony_ci void SetPendingSessionToForegroundListener(const NotifyPendingSessionToForegroundFunc& func); 296e0dac50fSopenharmony_ci WSError PendingSessionToForeground(); 297e0dac50fSopenharmony_ci void SetPendingSessionToBackgroundForDelegatorListener(const NotifyPendingSessionToBackgroundForDelegatorFunc& 298e0dac50fSopenharmony_ci func); 299e0dac50fSopenharmony_ci WSError PendingSessionToBackgroundForDelegator(bool shouldBackToCaller); 300e0dac50fSopenharmony_ci 301e0dac50fSopenharmony_ci void SetSessionFocusableChangeListener(const NotifySessionFocusableChangeFunc& func); 302e0dac50fSopenharmony_ci void SetSessionTouchableChangeListener(const NotifySessionTouchableChangeFunc& func); 303e0dac50fSopenharmony_ci void SetClickListener(const NotifyClickFunc& func); 304e0dac50fSopenharmony_ci void NotifySessionFocusableChange(bool isFocusable); 305e0dac50fSopenharmony_ci void NotifySessionTouchableChange(bool touchable); 306e0dac50fSopenharmony_ci void NotifyClick(bool requestFocus = true); 307e0dac50fSopenharmony_ci bool GetStateFromManager(const ManagerState key); 308e0dac50fSopenharmony_ci virtual void PresentFoucusIfNeed(int32_t pointerAcrion); 309e0dac50fSopenharmony_ci virtual WSError UpdateWindowMode(WindowMode mode); 310e0dac50fSopenharmony_ci WSError SetCompatibleModeInPc(bool enable, bool isSupportDragInPcCompatibleMode); 311e0dac50fSopenharmony_ci WSError SetAppSupportPhoneInPc(bool isSupportPhone); 312e0dac50fSopenharmony_ci WSError SetCompatibleWindowSizeInPc(int32_t portraitWidth, int32_t portraitHeight, 313e0dac50fSopenharmony_ci int32_t landscapeWidth, int32_t landscapeHeight); 314e0dac50fSopenharmony_ci WSError SetCompatibleModeEnableInPad(bool enable); 315e0dac50fSopenharmony_ci WSError CompatibleFullScreenRecover(); 316e0dac50fSopenharmony_ci WSError CompatibleFullScreenMinimize(); 317e0dac50fSopenharmony_ci WSError CompatibleFullScreenClose(); 318e0dac50fSopenharmony_ci WSError SetIsPcAppInPad(bool enable); 319e0dac50fSopenharmony_ci bool NeedNotify() const; 320e0dac50fSopenharmony_ci void SetNeedNotify(bool needNotify); 321e0dac50fSopenharmony_ci WSError SetTouchable(bool touchable); 322e0dac50fSopenharmony_ci bool GetTouchable() const; 323e0dac50fSopenharmony_ci bool GetRectChangeBySystem() const; 324e0dac50fSopenharmony_ci void SetRectChangeBySystem(bool rectChangeBySystem); 325e0dac50fSopenharmony_ci void SetForceTouchable(bool touchable); 326e0dac50fSopenharmony_ci virtual void SetSystemTouchable(bool touchable); 327e0dac50fSopenharmony_ci bool GetSystemTouchable() const; 328e0dac50fSopenharmony_ci virtual WSError SetRSVisible(bool isVisible); 329e0dac50fSopenharmony_ci bool GetRSVisible() const; 330e0dac50fSopenharmony_ci WSError SetVisibilityState(WindowVisibilityState state); 331e0dac50fSopenharmony_ci WindowVisibilityState GetVisibilityState() const; 332e0dac50fSopenharmony_ci WSError SetDrawingContentState(bool isRSDrawing); 333e0dac50fSopenharmony_ci bool GetDrawingContentState() const; 334e0dac50fSopenharmony_ci WSError SetBrightness(float brightness); 335e0dac50fSopenharmony_ci float GetBrightness() const; 336e0dac50fSopenharmony_ci void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info, 337e0dac50fSopenharmony_ci const std::shared_ptr<RSTransaction>& rsTransaction = nullptr); 338e0dac50fSopenharmony_ci void SetSessionInfoLockedStateChangeListener(const NotifySessionInfoLockedStateChangeFunc& func); 339e0dac50fSopenharmony_ci void NotifySessionInfoLockedStateChange(bool lockedState); 340e0dac50fSopenharmony_ci void SetContextTransparentFunc(const NotifyContextTransparentFunc& func); 341e0dac50fSopenharmony_ci void NotifyContextTransparent(); 342e0dac50fSopenharmony_ci bool NeedCheckContextTransparent() const; 343e0dac50fSopenharmony_ci 344e0dac50fSopenharmony_ci /* 345e0dac50fSopenharmony_ci * Window Rotate Animation 346e0dac50fSopenharmony_ci */ 347e0dac50fSopenharmony_ci void SetAcquireRotateAnimationConfigFunc(const AcquireRotateAnimationConfigFunc& func); 348e0dac50fSopenharmony_ci 349e0dac50fSopenharmony_ci /* 350e0dac50fSopenharmony_ci * Window Focus 351e0dac50fSopenharmony_ci */ 352e0dac50fSopenharmony_ci virtual WSError SetSystemSceneBlockingFocus(bool blocking); 353e0dac50fSopenharmony_ci bool GetBlockingFocus() const; 354e0dac50fSopenharmony_ci WSError SetFocusable(bool isFocusable); 355e0dac50fSopenharmony_ci bool GetFocusable() const; 356e0dac50fSopenharmony_ci void SetFocusedOnShow(bool focusedOnShow); // Used when creating ability 357e0dac50fSopenharmony_ci bool IsFocusedOnShow() const; 358e0dac50fSopenharmony_ci WSError SetFocusableOnShow(bool isFocusableOnShow) override; // Used when showing window 359e0dac50fSopenharmony_ci bool IsFocusableOnShow() const; 360e0dac50fSopenharmony_ci virtual void SetSystemFocusable(bool systemFocusable); // Used by SCB 361e0dac50fSopenharmony_ci bool GetSystemFocusable() const; 362e0dac50fSopenharmony_ci bool CheckFocusable() const; 363e0dac50fSopenharmony_ci bool IsFocused() const; 364e0dac50fSopenharmony_ci bool GetFocused() const; 365e0dac50fSopenharmony_ci virtual WSError UpdateFocus(bool isFocused); 366e0dac50fSopenharmony_ci virtual void PresentFocusIfPointDown(); 367e0dac50fSopenharmony_ci WSError RequestFocus(bool isFocused) override; 368e0dac50fSopenharmony_ci void NotifyRequestFocusStatusNotifyManager(bool isFocused, bool byForeground = true, 369e0dac50fSopenharmony_ci FocusChangeReason reason = FocusChangeReason::DEFAULT); 370e0dac50fSopenharmony_ci void NotifyUIRequestFocus(); 371e0dac50fSopenharmony_ci virtual void NotifyUILostFocus(); 372e0dac50fSopenharmony_ci WSError NotifyFocusStatus(bool isFocused); 373e0dac50fSopenharmony_ci 374e0dac50fSopenharmony_ci /* 375e0dac50fSopenharmony_ci * Multi Window 376e0dac50fSopenharmony_ci */ 377e0dac50fSopenharmony_ci void SetIsMidScene(bool isMidScene); 378e0dac50fSopenharmony_ci bool GetIsMidScene() const; 379e0dac50fSopenharmony_ci 380e0dac50fSopenharmony_ci bool IsSessionValid() const; 381e0dac50fSopenharmony_ci bool IsActive() const; 382e0dac50fSopenharmony_ci bool IsSystemActive() const; 383e0dac50fSopenharmony_ci bool IsSystemSession() const; 384e0dac50fSopenharmony_ci bool IsTerminated() const; 385e0dac50fSopenharmony_ci bool IsSessionForeground() const; 386e0dac50fSopenharmony_ci virtual bool IsAnco() const { return false; } 387e0dac50fSopenharmony_ci virtual void SetBlankFlag(bool isAddBlank) {}; 388e0dac50fSopenharmony_ci virtual bool GetBlankFlag() const { return false; } 389e0dac50fSopenharmony_ci virtual bool GetBufferAvailableCallbackEnable() const { return false; } 390e0dac50fSopenharmony_ci 391e0dac50fSopenharmony_ci sptr<IRemoteObject> dialogTargetToken_ = nullptr; 392e0dac50fSopenharmony_ci int32_t GetWindowId() const; 393e0dac50fSopenharmony_ci void SetAppIndex(const int32_t appIndex); 394e0dac50fSopenharmony_ci int32_t GetAppIndex() const; 395e0dac50fSopenharmony_ci void SetCallingPid(int32_t id); 396e0dac50fSopenharmony_ci void SetCallingUid(int32_t id); 397e0dac50fSopenharmony_ci int32_t GetCallingPid() const; 398e0dac50fSopenharmony_ci int32_t GetCallingUid() const; 399e0dac50fSopenharmony_ci void SetAbilityToken(sptr<IRemoteObject> token); 400e0dac50fSopenharmony_ci sptr<IRemoteObject> GetAbilityToken() const; 401e0dac50fSopenharmony_ci WindowMode GetWindowMode() const; 402e0dac50fSopenharmony_ci 403e0dac50fSopenharmony_ci /* 404e0dac50fSopenharmony_ci * Window ZOrder 405e0dac50fSopenharmony_ci */ 406e0dac50fSopenharmony_ci virtual void SetZOrder(uint32_t zOrder); 407e0dac50fSopenharmony_ci uint32_t GetZOrder() const; 408e0dac50fSopenharmony_ci uint32_t GetLastZOrder() const; 409e0dac50fSopenharmony_ci 410e0dac50fSopenharmony_ci void SetUINodeId(uint32_t uiNodeId); 411e0dac50fSopenharmony_ci uint32_t GetUINodeId() const; 412e0dac50fSopenharmony_ci virtual void SetFloatingScale(float floatingScale); 413e0dac50fSopenharmony_ci float GetFloatingScale() const; 414e0dac50fSopenharmony_ci virtual void SetScale(float scaleX, float scaleY, float pivotX, float pivotY); 415e0dac50fSopenharmony_ci float GetScaleX() const; 416e0dac50fSopenharmony_ci float GetScaleY() const; 417e0dac50fSopenharmony_ci float GetPivotX() const; 418e0dac50fSopenharmony_ci float GetPivotY() const; 419e0dac50fSopenharmony_ci void SetSCBKeepKeyboard(bool scbKeepKeyboardFlag); 420e0dac50fSopenharmony_ci bool GetSCBKeepKeyboardFlag() const; 421e0dac50fSopenharmony_ci 422e0dac50fSopenharmony_ci void SetRaiseToAppTopForPointDownFunc(const NotifyRaiseToTopForPointDownFunc& func); 423e0dac50fSopenharmony_ci void SetFrameLayoutFinishListener(const NotifyFrameLayoutFinishFunc& func); 424e0dac50fSopenharmony_ci void NotifyScreenshot(); 425e0dac50fSopenharmony_ci void RemoveLifeCycleTask(const LifeCycleTaskType& taskType); 426e0dac50fSopenharmony_ci void PostLifeCycleTask(Task &&task, const std::string& name, const LifeCycleTaskType& taskType); 427e0dac50fSopenharmony_ci WSError UpdateMaximizeMode(bool isMaximize); 428e0dac50fSopenharmony_ci void NotifySessionForeground(uint32_t reason, bool withAnimation); 429e0dac50fSopenharmony_ci void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits); 430e0dac50fSopenharmony_ci void HandlePointDownDialog(); 431e0dac50fSopenharmony_ci bool CheckDialogOnForeground(); 432e0dac50fSopenharmony_ci std::shared_ptr<Media::PixelMap> GetSnapshotPixelMap(const float oriScale = 1.0f, const float newScale = 1.0f); 433e0dac50fSopenharmony_ci virtual std::vector<Rect> GetTouchHotAreas() const 434e0dac50fSopenharmony_ci { 435e0dac50fSopenharmony_ci return std::vector<Rect>(); 436e0dac50fSopenharmony_ci } 437e0dac50fSopenharmony_ci 438e0dac50fSopenharmony_ci virtual void SetTouchHotAreas(const std::vector<Rect>& touchHotAreas); 439e0dac50fSopenharmony_ci 440e0dac50fSopenharmony_ci void SetVpr(float vpr) 441e0dac50fSopenharmony_ci { 442e0dac50fSopenharmony_ci vpr_ = vpr; 443e0dac50fSopenharmony_ci } 444e0dac50fSopenharmony_ci 445e0dac50fSopenharmony_ci bool operator==(const Session* session) const 446e0dac50fSopenharmony_ci { 447e0dac50fSopenharmony_ci if (session == nullptr) { 448e0dac50fSopenharmony_ci return false; 449e0dac50fSopenharmony_ci } 450e0dac50fSopenharmony_ci return (persistentId_ == session->persistentId_ && callingPid_ == session->callingPid_); 451e0dac50fSopenharmony_ci } 452e0dac50fSopenharmony_ci 453e0dac50fSopenharmony_ci bool operator!=(const Session* session) const 454e0dac50fSopenharmony_ci { 455e0dac50fSopenharmony_ci return !this->operator==(session); 456e0dac50fSopenharmony_ci } 457e0dac50fSopenharmony_ci 458e0dac50fSopenharmony_ci virtual void HandleStyleEvent(MMI::WindowArea area) {}; 459e0dac50fSopenharmony_ci WSError SetPointerStyle(MMI::WindowArea area); 460e0dac50fSopenharmony_ci const char* DumpPointerWindowArea(MMI::WindowArea area) const; 461e0dac50fSopenharmony_ci WSRectF UpdateHotRect(const WSRect& rect); 462e0dac50fSopenharmony_ci WSError RaiseToAppTopForPointDown(); 463e0dac50fSopenharmony_ci 464e0dac50fSopenharmony_ci virtual void NotifyForegroundInteractiveStatus(bool interactive); 465e0dac50fSopenharmony_ci WSError UpdateTitleInTargetPos(bool isShow, int32_t height); 466e0dac50fSopenharmony_ci void SetNotifySystemSessionPointerEventFunc(const NotifySystemSessionPointerEventFunc& func); 467e0dac50fSopenharmony_ci void SetNotifySystemSessionKeyEventFunc(const NotifySystemSessionKeyEventFunc& func); 468e0dac50fSopenharmony_ci bool IsSystemInput(); 469e0dac50fSopenharmony_ci // ForegroundInteractiveStatus interface only for event use 470e0dac50fSopenharmony_ci bool GetForegroundInteractiveStatus() const; 471e0dac50fSopenharmony_ci virtual void SetForegroundInteractiveStatus(bool interactive); 472e0dac50fSopenharmony_ci void SetAttachState(bool isAttach, WindowMode windowMode = WindowMode::WINDOW_MODE_UNDEFINED); 473e0dac50fSopenharmony_ci bool GetAttachState() const; 474e0dac50fSopenharmony_ci void RegisterDetachCallback(const sptr<IPatternDetachCallback>& callback); 475e0dac50fSopenharmony_ci SystemSessionConfig GetSystemConfig() const; 476e0dac50fSopenharmony_ci void RectCheckProcess(); 477e0dac50fSopenharmony_ci virtual void RectCheck(uint32_t curWidth, uint32_t curHeight) {}; 478e0dac50fSopenharmony_ci void RectSizeCheckProcess(uint32_t curWidth, uint32_t curHeight, uint32_t minWidth, 479e0dac50fSopenharmony_ci uint32_t minHeight, uint32_t maxFloatingWindowSize); 480e0dac50fSopenharmony_ci DetectTaskInfo GetDetectTaskInfo() const; 481e0dac50fSopenharmony_ci void SetDetectTaskInfo(const DetectTaskInfo& detectTaskInfo); 482e0dac50fSopenharmony_ci WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj); 483e0dac50fSopenharmony_ci void CreateWindowStateDetectTask(bool isAttach, WindowMode windowMode); 484e0dac50fSopenharmony_ci void RegisterIsScreenLockedCallback(const std::function<bool()>& callback); 485e0dac50fSopenharmony_ci void ProcessClickModalSpecificWindowOutside(int32_t posX, int32_t posY); 486e0dac50fSopenharmony_ci std::string GetWindowDetectTaskName() const; 487e0dac50fSopenharmony_ci void RemoveWindowDetectTask(); 488e0dac50fSopenharmony_ci WSError SwitchFreeMultiWindow(bool enable); 489e0dac50fSopenharmony_ci 490e0dac50fSopenharmony_ci virtual bool CheckGetAvoidAreaAvailable(AvoidAreaType type) { return true; } 491e0dac50fSopenharmony_ci 492e0dac50fSopenharmony_ci virtual bool IsVisibleForeground() const; 493e0dac50fSopenharmony_ci void SetIsStarting(bool isStarting); 494e0dac50fSopenharmony_ci void SetUIStateDirty(bool dirty); 495e0dac50fSopenharmony_ci void SetMainSessionUIStateDirty(bool dirty); 496e0dac50fSopenharmony_ci bool GetUIStateDirty() const; 497e0dac50fSopenharmony_ci void ResetDirtyFlags(); 498e0dac50fSopenharmony_ci static bool IsScbCoreEnabled(); 499e0dac50fSopenharmony_ci static void SetScbCoreEnabled(bool enabled); 500e0dac50fSopenharmony_ci bool IsVisible() const; 501e0dac50fSopenharmony_ci virtual bool IsNeedSyncScenePanelGlobalPosition() { return true; } 502e0dac50fSopenharmony_ci void SetAppInstanceKey(const std::string& appInstanceKey); 503e0dac50fSopenharmony_ci std::string GetAppInstanceKey() const; 504e0dac50fSopenharmony_ci 505e0dac50fSopenharmony_ciprotected: 506e0dac50fSopenharmony_ci class SessionLifeCycleTask : public virtual RefBase { 507e0dac50fSopenharmony_ci public: 508e0dac50fSopenharmony_ci SessionLifeCycleTask(const Task& task, const std::string& name, const LifeCycleTaskType& type) 509e0dac50fSopenharmony_ci : task(task), name(name), type(type) {} 510e0dac50fSopenharmony_ci Task task; 511e0dac50fSopenharmony_ci const std::string name; 512e0dac50fSopenharmony_ci LifeCycleTaskType type; 513e0dac50fSopenharmony_ci std::chrono::steady_clock::time_point startTime = std::chrono::steady_clock::now(); 514e0dac50fSopenharmony_ci bool running = false; 515e0dac50fSopenharmony_ci }; 516e0dac50fSopenharmony_ci void StartLifeCycleTask(sptr<SessionLifeCycleTask> lifeCycleTask); 517e0dac50fSopenharmony_ci void GeneratePersistentId(bool isExtension, int32_t persistentId); 518e0dac50fSopenharmony_ci virtual void UpdateSessionState(SessionState state); 519e0dac50fSopenharmony_ci void NotifySessionStateChange(const SessionState& state); 520e0dac50fSopenharmony_ci void UpdateSessionTouchable(bool touchable); 521e0dac50fSopenharmony_ci virtual WSError UpdateActiveStatus(bool isActive) { return WSError::WS_OK; } 522e0dac50fSopenharmony_ci 523e0dac50fSopenharmony_ci /* 524e0dac50fSopenharmony_ci * Gesture Back 525e0dac50fSopenharmony_ci */ 526e0dac50fSopenharmony_ci virtual void UpdateGestureBackEnabled() {} 527e0dac50fSopenharmony_ci 528e0dac50fSopenharmony_ci WSRectF UpdateTopBottomArea(const WSRectF& rect, MMI::WindowArea area); 529e0dac50fSopenharmony_ci WSRectF UpdateLeftRightArea(const WSRectF& rect, MMI::WindowArea area); 530e0dac50fSopenharmony_ci WSRectF UpdateInnerAngleArea(const WSRectF& rect, MMI::WindowArea area); 531e0dac50fSopenharmony_ci virtual void UpdatePointerArea(const WSRect& rect); 532e0dac50fSopenharmony_ci virtual bool CheckPointerEventDispatch(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const; 533e0dac50fSopenharmony_ci bool IsTopDialog() const; 534e0dac50fSopenharmony_ci void HandlePointDownDialog(int32_t pointAction); 535e0dac50fSopenharmony_ci void NotifySessionInfoChange(); 536e0dac50fSopenharmony_ci 537e0dac50fSopenharmony_ci void PostTask(Task&& task, const std::string& name = "sessionTask", int64_t delayTime = 0); 538e0dac50fSopenharmony_ci void PostExportTask(Task&& task, const std::string& name = "sessionExportTask", int64_t delayTime = 0); 539e0dac50fSopenharmony_ci template<typename SyncTask, typename Return = std::invoke_result_t<SyncTask>> 540e0dac50fSopenharmony_ci Return PostSyncTask(SyncTask&& task, const std::string& name = "sessionTask") 541e0dac50fSopenharmony_ci { 542e0dac50fSopenharmony_ci Return ret; 543e0dac50fSopenharmony_ci if (!handler_ || handler_->GetEventRunner()->IsCurrentRunnerThread()) { 544e0dac50fSopenharmony_ci StartTraceForSyncTask(name); 545e0dac50fSopenharmony_ci ret = task(); 546e0dac50fSopenharmony_ci FinishTraceForSyncTask(); 547e0dac50fSopenharmony_ci return ret; 548e0dac50fSopenharmony_ci } 549e0dac50fSopenharmony_ci auto syncTask = [&ret, &task, name]() { 550e0dac50fSopenharmony_ci StartTraceForSyncTask(name); 551e0dac50fSopenharmony_ci ret = task(); 552e0dac50fSopenharmony_ci FinishTraceForSyncTask(); 553e0dac50fSopenharmony_ci }; 554e0dac50fSopenharmony_ci handler_->PostSyncTask(std::move(syncTask), name, AppExecFwk::EventQueue::Priority::IMMEDIATE); 555e0dac50fSopenharmony_ci return ret; 556e0dac50fSopenharmony_ci } 557e0dac50fSopenharmony_ci 558e0dac50fSopenharmony_ci static std::shared_ptr<AppExecFwk::EventHandler> mainHandler_; 559e0dac50fSopenharmony_ci int32_t persistentId_ = INVALID_SESSION_ID; 560e0dac50fSopenharmony_ci std::atomic<SessionState> state_ = SessionState::STATE_DISCONNECT; 561e0dac50fSopenharmony_ci SessionInfo sessionInfo_; 562e0dac50fSopenharmony_ci std::recursive_mutex sessionInfoMutex_; 563e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> surfaceNode_; 564e0dac50fSopenharmony_ci mutable std::mutex snapshotMutex_; 565e0dac50fSopenharmony_ci std::shared_ptr<Media::PixelMap> snapshot_; 566e0dac50fSopenharmony_ci sptr<ISessionStage> sessionStage_; 567e0dac50fSopenharmony_ci std::mutex lifeCycleTaskQueueMutex_; 568e0dac50fSopenharmony_ci std::list<sptr<SessionLifeCycleTask>> lifeCycleTaskQueue_; 569e0dac50fSopenharmony_ci bool isActive_ = false; 570e0dac50fSopenharmony_ci bool isSystemActive_ = false; 571e0dac50fSopenharmony_ci WSRect winRect_; 572e0dac50fSopenharmony_ci WSRect clientRect_; // rect saved when prelayout or notify client to update rect 573e0dac50fSopenharmony_ci WSRect lastLayoutRect_; // rect saved when go background 574e0dac50fSopenharmony_ci WSRect layoutRect_; // rect of root view 575e0dac50fSopenharmony_ci WSRect globalRect_; // globalRect include translate 576e0dac50fSopenharmony_ci mutable std::mutex globalRectMutex_; 577e0dac50fSopenharmony_ci WSRectF bounds_; 578e0dac50fSopenharmony_ci Rotation rotation_; 579e0dac50fSopenharmony_ci float offsetX_ = 0.0f; 580e0dac50fSopenharmony_ci float offsetY_ = 0.0f; 581e0dac50fSopenharmony_ci std::atomic_bool isExitSplitOnBackground_ = false; 582e0dac50fSopenharmony_ci bool isVisible_ = false; 583e0dac50fSopenharmony_ci SizeChangeReason reason_ = SizeChangeReason::UNDEFINED; 584e0dac50fSopenharmony_ci 585e0dac50fSopenharmony_ci NotifySessionRectChangeFunc sessionRectChangeFunc_; 586e0dac50fSopenharmony_ci NotifyPendingSessionActivationFunc pendingSessionActivationFunc_; 587e0dac50fSopenharmony_ci NotifyChangeSessionVisibilityWithStatusBarFunc changeSessionVisibilityWithStatusBarFunc_; 588e0dac50fSopenharmony_ci NotifySessionStateChangeFunc sessionStateChangeFunc_; 589e0dac50fSopenharmony_ci NotifyBufferAvailableChangeFunc bufferAvailableChangeFunc_; 590e0dac50fSopenharmony_ci NotifyLeashWindowSurfaceNodeChangedFunc leashWindowSurfaceNodeChangedFunc_; 591e0dac50fSopenharmony_ci NotifySessionInfoChangeNotifyManagerFunc sessionInfoChangeNotifyManagerFunc_; 592e0dac50fSopenharmony_ci NotifySessionStateChangeNotifyManagerFunc sessionStateChangeNotifyManagerFunc_; 593e0dac50fSopenharmony_ci NotifyRequestFocusStatusNotifyManagerFunc requestFocusStatusNotifyManagerFunc_; 594e0dac50fSopenharmony_ci NotifyClickModalSpecificWindowOutsideFunc clickModalSpecificWindowOutsideFunc_; 595e0dac50fSopenharmony_ci NotifyUIRequestFocusFunc requestFocusFunc_; 596e0dac50fSopenharmony_ci NotifyUILostFocusFunc lostFocusFunc_; 597e0dac50fSopenharmony_ci GetStateFromManagerFunc getStateFromManagerFunc_; 598e0dac50fSopenharmony_ci NotifyBackPressedFunc backPressedFunc_; 599e0dac50fSopenharmony_ci NotifySessionFocusableChangeFunc sessionFocusableChangeFunc_; 600e0dac50fSopenharmony_ci NotifySessionTouchableChangeFunc sessionTouchableChangeFunc_; 601e0dac50fSopenharmony_ci NotifyClickFunc clickFunc_; 602e0dac50fSopenharmony_ci NotifyTerminateSessionFunc terminateSessionFunc_; 603e0dac50fSopenharmony_ci NotifyTerminateSessionFuncNew terminateSessionFuncNew_; 604e0dac50fSopenharmony_ci NotifyTerminateSessionFuncTotal terminateSessionFuncTotal_; 605e0dac50fSopenharmony_ci NofitySessionLabelUpdatedFunc updateSessionLabelFunc_; 606e0dac50fSopenharmony_ci NofitySessionIconUpdatedFunc updateSessionIconFunc_; 607e0dac50fSopenharmony_ci std::shared_ptr<NotifySessionExceptionFunc> sessionExceptionFunc_; 608e0dac50fSopenharmony_ci std::shared_ptr<NotifySessionExceptionFunc> jsSceneSessionExceptionFunc_; 609e0dac50fSopenharmony_ci NotifySessionSnapshotFunc notifySessionSnapshotFunc_; 610e0dac50fSopenharmony_ci NotifyPendingSessionToForegroundFunc pendingSessionToForegroundFunc_; 611e0dac50fSopenharmony_ci NotifyPendingSessionToBackgroundForDelegatorFunc pendingSessionToBackgroundForDelegatorFunc_; 612e0dac50fSopenharmony_ci NotifyRaiseToTopForPointDownFunc raiseToTopForPointDownFunc_; 613e0dac50fSopenharmony_ci NotifySessionInfoLockedStateChangeFunc sessionInfoLockedStateChangeFunc_; 614e0dac50fSopenharmony_ci NotifySystemSessionPointerEventFunc systemSessionPointerEventFunc_; 615e0dac50fSopenharmony_ci NotifySystemSessionKeyEventFunc systemSessionKeyEventFunc_; 616e0dac50fSopenharmony_ci NotifyContextTransparentFunc contextTransparentFunc_; 617e0dac50fSopenharmony_ci NotifyFrameLayoutFinishFunc frameLayoutFinishFunc_; 618e0dac50fSopenharmony_ci VisibilityChangedDetectFunc visibilityChangedDetectFunc_; 619e0dac50fSopenharmony_ci 620e0dac50fSopenharmony_ci /* 621e0dac50fSopenharmony_ci * Window Rotate Animation 622e0dac50fSopenharmony_ci */ 623e0dac50fSopenharmony_ci AcquireRotateAnimationConfigFunc acquireRotateAnimationConfigFunc_; 624e0dac50fSopenharmony_ci 625e0dac50fSopenharmony_ci SystemSessionConfig systemConfig_; 626e0dac50fSopenharmony_ci bool needSnapshot_ = false; 627e0dac50fSopenharmony_ci float snapshotScale_ = 0.5; 628e0dac50fSopenharmony_ci sptr<ScenePersistence> scenePersistence_ = nullptr; 629e0dac50fSopenharmony_ci 630e0dac50fSopenharmony_ci /* 631e0dac50fSopenharmony_ci * Window ZOrder 632e0dac50fSopenharmony_ci */ 633e0dac50fSopenharmony_ci uint32_t zOrder_ = 0; 634e0dac50fSopenharmony_ci uint32_t lastZOrder_ = 0; 635e0dac50fSopenharmony_ci 636e0dac50fSopenharmony_ci /* 637e0dac50fSopenharmony_ci * Window Focus 638e0dac50fSopenharmony_ci */ 639e0dac50fSopenharmony_ci bool isFocused_ = false; 640e0dac50fSopenharmony_ci bool blockingFocus_ {false}; 641e0dac50fSopenharmony_ci 642e0dac50fSopenharmony_ci uint32_t uiNodeId_ = 0; 643e0dac50fSopenharmony_ci float aspectRatio_ = 0.0f; 644e0dac50fSopenharmony_ci std::map<MMI::WindowArea, WSRectF> windowAreas_; 645e0dac50fSopenharmony_ci bool isTerminating_ = false; 646e0dac50fSopenharmony_ci float floatingScale_ = 1.0f; 647e0dac50fSopenharmony_ci float scaleX_ = 1.0f; 648e0dac50fSopenharmony_ci float scaleY_ = 1.0f; 649e0dac50fSopenharmony_ci float pivotX_ = 0.0f; 650e0dac50fSopenharmony_ci float pivotY_ = 0.0f; 651e0dac50fSopenharmony_ci bool scbKeepKeyboardFlag_ = false; 652e0dac50fSopenharmony_ci mutable std::shared_mutex dialogVecMutex_; 653e0dac50fSopenharmony_ci std::vector<sptr<Session>> dialogVec_; 654e0dac50fSopenharmony_ci mutable std::shared_mutex parentSessionMutex_; 655e0dac50fSopenharmony_ci sptr<Session> parentSession_; 656e0dac50fSopenharmony_ci sptr<IWindowEventChannel> windowEventChannel_; 657e0dac50fSopenharmony_ci 658e0dac50fSopenharmony_ci mutable std::mutex pointerEventMutex_; 659e0dac50fSopenharmony_ci mutable std::shared_mutex keyEventMutex_; 660e0dac50fSopenharmony_ci bool rectChangeListenerRegistered_ = false; 661e0dac50fSopenharmony_ci uint32_t dirtyFlags_ = 0; // only accessed on SSM thread 662e0dac50fSopenharmony_ci bool isStarting_ = false; // when start app, session is starting state until foreground 663e0dac50fSopenharmony_ci std::atomic_bool mainUIStateDirty_ = false; 664e0dac50fSopenharmony_ci static bool isScbCoreEnabled_; 665e0dac50fSopenharmony_ci 666e0dac50fSopenharmony_ciprivate: 667e0dac50fSopenharmony_ci void HandleDialogForeground(); 668e0dac50fSopenharmony_ci void HandleDialogBackground(); 669e0dac50fSopenharmony_ci WSError HandleSubWindowClick(int32_t action); 670e0dac50fSopenharmony_ci 671e0dac50fSopenharmony_ci template<typename T> 672e0dac50fSopenharmony_ci bool RegisterListenerLocked(std::vector<std::shared_ptr<T>>& holder, const std::shared_ptr<T>& listener); 673e0dac50fSopenharmony_ci template<typename T> 674e0dac50fSopenharmony_ci bool UnregisterListenerLocked(std::vector<std::shared_ptr<T>>& holder, const std::shared_ptr<T>& listener); 675e0dac50fSopenharmony_ci bool IsStateMatch(bool isAttach) const; 676e0dac50fSopenharmony_ci bool IsSupportDetectWindow(bool isAttach); 677e0dac50fSopenharmony_ci bool ShouldCreateDetectTask(bool isAttach, WindowMode windowMode) const; 678e0dac50fSopenharmony_ci bool ShouldCreateDetectTaskInRecent(bool newShowRecent, bool oldShowRecent, bool isAttach) const; 679e0dac50fSopenharmony_ci void CreateDetectStateTask(bool isAttach, WindowMode windowMode); 680e0dac50fSopenharmony_ci 681e0dac50fSopenharmony_ci /* 682e0dac50fSopenharmony_ci * Window Rotate Animation 683e0dac50fSopenharmony_ci */ 684e0dac50fSopenharmony_ci int32_t GetRotateAnimationDuration(); 685e0dac50fSopenharmony_ci 686e0dac50fSopenharmony_ci /* 687e0dac50fSopenharmony_ci * Window Property 688e0dac50fSopenharmony_ci */ 689e0dac50fSopenharmony_ci void InitSessionPropertyWhenConnect(const sptr<WindowSessionProperty>& property); 690e0dac50fSopenharmony_ci void InitSystemSessionDragEnable(const sptr<WindowSessionProperty>& property); 691e0dac50fSopenharmony_ci 692e0dac50fSopenharmony_ci template<typename T1, typename T2, typename Ret> 693e0dac50fSopenharmony_ci using EnableIfSame = typename std::enable_if<std::is_same_v<T1, T2>, Ret>::type; 694e0dac50fSopenharmony_ci template<typename T> 695e0dac50fSopenharmony_ci inline EnableIfSame<T, ILifecycleListener, std::vector<std::weak_ptr<ILifecycleListener>>> GetListeners() 696e0dac50fSopenharmony_ci { 697e0dac50fSopenharmony_ci std::vector<std::weak_ptr<ILifecycleListener>> lifecycleListeners; 698e0dac50fSopenharmony_ci { 699e0dac50fSopenharmony_ci std::lock_guard<std::recursive_mutex> lock(lifecycleListenersMutex_); 700e0dac50fSopenharmony_ci for (auto& listener : lifecycleListeners_) { 701e0dac50fSopenharmony_ci lifecycleListeners.push_back(listener); 702e0dac50fSopenharmony_ci } 703e0dac50fSopenharmony_ci } 704e0dac50fSopenharmony_ci return lifecycleListeners; 705e0dac50fSopenharmony_ci } 706e0dac50fSopenharmony_ci 707e0dac50fSopenharmony_ci std::recursive_mutex lifecycleListenersMutex_; 708e0dac50fSopenharmony_ci std::vector<std::shared_ptr<ILifecycleListener>> lifecycleListeners_; 709e0dac50fSopenharmony_ci std::shared_ptr<AppExecFwk::EventHandler> handler_; 710e0dac50fSopenharmony_ci std::shared_ptr<AppExecFwk::EventHandler> exportHandler_; 711e0dac50fSopenharmony_ci std::function<bool()> isScreenLockedCallback_; 712e0dac50fSopenharmony_ci 713e0dac50fSopenharmony_ci mutable std::shared_mutex propertyMutex_; 714e0dac50fSopenharmony_ci sptr<WindowSessionProperty> property_; 715e0dac50fSopenharmony_ci 716e0dac50fSopenharmony_ci /* 717e0dac50fSopenharmony_ci * Window Focus 718e0dac50fSopenharmony_ci */ 719e0dac50fSopenharmony_ci mutable std::shared_mutex uiRequestFocusMutex_; 720e0dac50fSopenharmony_ci mutable std::shared_mutex uiLostFocusMutex_; 721e0dac50fSopenharmony_ci bool focusedOnShow_ = true; 722e0dac50fSopenharmony_ci std::atomic_bool systemFocusable_ = true; 723e0dac50fSopenharmony_ci bool focusableOnShow_ = true; // if false, ignore request focus when session onAttach 724e0dac50fSopenharmony_ci 725e0dac50fSopenharmony_ci bool showRecent_ = false; 726e0dac50fSopenharmony_ci bool bufferAvailable_ = false; 727e0dac50fSopenharmony_ci 728e0dac50fSopenharmony_ci /* 729e0dac50fSopenharmony_ci * Multi Window 730e0dac50fSopenharmony_ci */ 731e0dac50fSopenharmony_ci bool isMidScene_ = false; 732e0dac50fSopenharmony_ci 733e0dac50fSopenharmony_ci WSRect preRect_; 734e0dac50fSopenharmony_ci int32_t callingPid_ = -1; 735e0dac50fSopenharmony_ci int32_t callingUid_ = -1; 736e0dac50fSopenharmony_ci int32_t appIndex_ = { 0 }; 737e0dac50fSopenharmony_ci std::string callingBundleName_ { "unknown" }; 738e0dac50fSopenharmony_ci bool isRSVisible_ {false}; 739e0dac50fSopenharmony_ci WindowVisibilityState visibilityState_ { WINDOW_LAYER_STATE_MAX}; 740e0dac50fSopenharmony_ci bool needNotify_ {true}; 741e0dac50fSopenharmony_ci bool isRSDrawing_ {false}; 742e0dac50fSopenharmony_ci sptr<IRemoteObject> abilityToken_ = nullptr; 743e0dac50fSopenharmony_ci float vpr_ { 1.5f }; 744e0dac50fSopenharmony_ci bool forceTouchable_ { true }; 745e0dac50fSopenharmony_ci bool systemTouchable_ { true }; 746e0dac50fSopenharmony_ci std::atomic<bool> rectChangeBySystem_ { false }; 747e0dac50fSopenharmony_ci std::atomic_bool foregroundInteractiveStatus_ { true }; 748e0dac50fSopenharmony_ci std::atomic<bool> isAttach_{ false }; 749e0dac50fSopenharmony_ci sptr<IPatternDetachCallback> detachCallback_ = nullptr; 750e0dac50fSopenharmony_ci 751e0dac50fSopenharmony_ci std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode_; 752e0dac50fSopenharmony_ci mutable std::mutex leashWinSurfaceNodeMutex_; 753e0dac50fSopenharmony_ci DetectTaskInfo detectTaskInfo_; 754e0dac50fSopenharmony_ci mutable std::shared_mutex detectTaskInfoMutex_; 755e0dac50fSopenharmony_ci}; 756e0dac50fSopenharmony_ci} // namespace OHOS::Rosen 757e0dac50fSopenharmony_ci 758e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_H