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_MANAGER_H 17 #define OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_MANAGER_H 18 19 #include <cstdint> 20 #include <unordered_map> 21 #include <mutex> 22 #include <shared_mutex> 23 24 #ifndef OHOS_BUILD_ENABLE_SECURITY_COMPONENT // pointer_envent.h 25 #define OHOS_BUILD_ENABLE_SECURITY_COMPONENT 26 #endif 27 #ifndef SUPPORT_SCREEN 28 #define SUPPORT_SCREEN 29 #endif 30 31 #include "ability_info.h" 32 #include "agent_death_recipient.h" 33 #include "app_debug_listener_interface.h" 34 #include "app_mgr_client.h" 35 #include "common/include/task_scheduler.h" 36 #include "display_change_info.h" 37 #include "display_change_listener.h" 38 #include "display_info.h" 39 #include "future.h" 40 #include "include/core/SkRegion.h" 41 #include "interfaces/include/ws_common.h" 42 #include "mission_snapshot.h" 43 #include "scb_session_handler.h" 44 #include "scene_session_converter.h" 45 #include "screen_fold_data.h" 46 #include "screen_session_manager_client.h" 47 #include "session/host/include/keyboard_session.h" 48 #include "session/host/include/session.h" 49 #include "session/host/include/root_scene_session.h" 50 #include "session_listener_controller.h" 51 #include "session_manager/include/ffrt_queue_helper.h" 52 #include "session_manager/include/window_manager_lru.h" 53 #include "session_manager/include/zidl/scene_session_manager_stub.h" 54 #include "thread_safety_annotations.h" 55 #include "transaction/rs_interfaces.h" 56 #include "window_focus_controller.h" 57 #include "window_scene_config.h" 58 #include "wm_single_instance.h" 59 #include "zidl/session_lifecycle_listener_interface.h" 60 #include "zidl/session_router_stack_listener.h" 61 62 namespace OHOS::AAFwk { 63 class SessionInfo; 64 } // namespace OHOS::AAFwk 65 66 namespace OHOS::AppExecFwk { 67 class IBundleMgr; 68 struct AbilityInfo; 69 struct BundleInfo; 70 class LauncherService; 71 } // namespace OHOS::AppExecFwk 72 73 namespace OHOS::Global::Resource { 74 class ResourceManager; 75 } // namespace OHOS::Global::Resource 76 77 namespace OHOS::Rosen { 78 class RSNode; 79 namespace AncoConsts { 80 constexpr const char* ANCO_MISSION_ID = "ohos.anco.param.missionId"; 81 constexpr const char* ANCO_SESSION_ID = "ohos.anco.param.sessionId"; 82 } 83 constexpr const char* IS_CALL_BY_SCB = "isCallBySCB"; 84 85 struct SCBAbilityInfo { 86 AppExecFwk::AbilityInfo abilityInfo_; 87 uint32_t sdkVersion_; 88 std::string codePath_; 89 bool isAbilityHook_; 90 bool isForceRotate_; 91 }; 92 93 struct SCBApplicationInfo { 94 AppExecFwk::StartMode startMode_; 95 }; 96 97 struct SessionIdentityInfo { 98 std::string bundleName_; 99 std::string moduleName_; 100 std::string abilityName_; 101 int32_t appIndex_ = 0; 102 std::string instanceKey_; 103 uint32_t windowType_ = static_cast<uint32_t>(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); 104 bool isAtomicService_ = false; 105 std::string specifiedFlag_; 106 }; 107 108 class SceneSession; 109 struct SecSurfaceInfo; 110 class RSUIExtensionData; 111 class AccessibilityWindowInfo; 112 class UnreliableWindowInfo; 113 class ScbDumpSubscriber; 114 class StartingWindowRdbManager; 115 struct StartingWindowRdbItemKey; 116 class IUIEffectController; 117 class IUIEffectControllerClient; 118 119 using NotifyCreateSystemSessionFunc = std::function<void(const sptr<SceneSession>& session)>; 120 using NotifyCreateKeyboardSessionFunc = std::function<void(const sptr<SceneSession>& keyboardSession, 121 const sptr<SceneSession>& panelSession)>; 122 using NotifyCreateSubSessionFunc = std::function<void(const sptr<SceneSession>& session)>; 123 using NotifyRecoverSceneSessionFunc = 124 std::function<void(const sptr<SceneSession>& session, const SessionInfo& sessionInfo)>; 125 using ProcessStatusBarEnabledChangeFunc = std::function<void(bool enable, const std::string& bundleName)>; 126 using ProcessGestureNavigationEnabledChangeFunc = std::function<void(bool enable, const std::string& bundleName, 127 GestureBackType type)>; 128 using ProcessOutsideDownEventFunc = std::function<void(int32_t x, int32_t y)>; 129 using ProcessShiftFocusFunc = std::function<void(int32_t persistentId, DisplayId displayGroupId)>; 130 using NotifySetFocusSessionFunc = std::function<void(const sptr<SceneSession>& session)>; 131 using DumpRootSceneElementInfoFunc = std::function<void(const sptr<SceneSession>& session, 132 const std::vector<std::string>& params, std::vector<std::string>& infos)>; 133 using WindowChangedFunc = std::function<void(int32_t persistentId, WindowUpdateType type)>; 134 using TraverseFunc = std::function<bool(const sptr<SceneSession>& session)>; 135 using CmpFunc = std::function<bool(std::pair<int32_t, sptr<SceneSession>>& lhs, 136 std::pair<int32_t, sptr<SceneSession>>& rhs)>; 137 using ProcessStartUIAbilityErrorFunc = std::function<void(int32_t startUIAbilityError)>; 138 using NotifySCBAfterUpdateFocusFunc = std::function<void(DisplayId displayId)>; 139 using NotifyDiffSCBAfterUpdateFocusFunc = std::function<void(DisplayId prevDisplayId, DisplayId currDisplayId)>; 140 using ProcessCallingSessionIdChangeFunc = std::function<void(uint32_t callingSessionId)>; 141 using FlushWindowInfoTask = std::function<void()>; 142 using ProcessVirtualPixelRatioChangeFunc = std::function<void(float density, const Rect& rect)>; 143 using DumpUITreeFunc = std::function<void(std::string& dumpInfo)>; 144 using RootSceneProcessBackEventFunc = std::function<void()>; 145 using ProcessCloseTargetFloatWindowFunc = std::function<void(const std::string& bundleName)>; 146 using AbilityManagerCollaboratorRegisteredFunc = std::function<void()>; 147 using OnFlushUIParamsFunc = std::function<void()>; 148 using IsRootSceneLastFrameLayoutFinishedFunc = std::function<bool()>; 149 using NotifyStartPiPFailedFunc = std::function<void(DisplayId displayId)>; 150 using NotifyAppUseControlListFunc = 151 std::function<void(ControlAppType type, int32_t userId, const std::vector<AppUseControlInfo>& controlList)>; 152 using NotifyRootSceneAvoidAreaChangeFunc = std::function<void(const sptr<AvoidArea>& avoidArea, AvoidAreaType type, 153 const sptr<OccupiedAreaChangeInfo>& info)>; 154 using NotifyWatchGestureConsumeResultFunc = std::function<void(int32_t keyCode, bool isConsumed)>; 155 using NotifyWatchFocusActiveChangeFunc = std::function<void(bool isActive)>; 156 using GetRSNodeByStringIDFunc = std::function<std::shared_ptr<Rosen::RSNode>(const std::string& id)>; 157 using SetTopWindowBoundaryByIDFunc = std::function<void(const std::string& id)>; 158 using SetForegroundWindowNumFunc = std::function<void(uint32_t windowNum)>; 159 using MinimizeByWindowIdFunc = std::function<void(const std::vector<int32_t>& windowIds)>; 160 using NotifySceneSessionDestructFunc = std::function<void(int32_t persistentId)>; 161 using NotifyTransferSessionToTargetScreenFunc = std::function<void(const TransferSessionInfo& info)>; 162 using HasRootSceneRequestedVsyncFunc = std::function<bool()>; 163 using RequestVsyncByRootSceneWhenModeChangeFunc = 164 std::function<void(const std::shared_ptr<VsyncCallback>& vsyncCallback)>; 165 using UpdateKioskAppListFunc = std::function<void(const std::vector<std::string>& kioskAppList)>; 166 using KioskModeChangeFunc = std::function<void(bool isKioskMode, int32_t persistentId)>; 167 using NotifySessionRecoverStateChangeFunc = std::function<void(const SessionRecoverState& state, 168 const sptr<WindowSessionProperty>& property)>; 169 using NotifyRecoverStateChangeFunc = std::function<void(const RecoverState& state)>; 170 171 class AppAnrListener : public IRemoteStub<AppExecFwk::IAppDebugListener> { 172 public: 173 void OnAppDebugStarted(const std::vector<AppExecFwk::AppDebugInfo>& debugInfos) override; 174 void OnAppDebugStoped(const std::vector<AppExecFwk::AppDebugInfo>& debugInfos) override; 175 }; 176 177 class DisplayChangeListener : public IDisplayChangeListener { 178 public: 179 void OnDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 180 const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type) override; 181 void OnScreenshot(DisplayId displayId) override; 182 void OnImmersiveStateChange(ScreenId screenId, bool& immersive) override; 183 void OnGetSurfaceNodeIdsFromMissionIds(std::vector<uint64_t>& missionIds, 184 std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false) override; 185 void OnSetSurfaceNodeIds(DisplayId displayId, const std::vector<uint64_t>& surfaceNodeIds) override; 186 void OnVirtualScreenDisconnected(DisplayId displayId) override; 187 188 /* 189 * Fold Screen Status Change Report 190 */ 191 void OnScreenFoldStatusChanged(const std::vector<std::string>& screenFoldInfo) override; 192 }; 193 194 class ScreenConnectionChangeListener : public IScreenConnectionChangeListener { 195 public: 196 void OnScreenConnected(const sptr<ScreenSession>& screenSession) override; 197 void OnScreenDisconnected(const sptr<ScreenSession>& screenSession) override; 198 }; 199 200 class SceneSessionManager : public SceneSessionManagerStub { 201 WM_DECLARE_SINGLE_INSTANCE_BASE(SceneSessionManager) 202 public: 203 friend class AnomalyDetection; 204 bool IsSessionVisible(const sptr<SceneSession>& session) const; 205 bool IsSessionVisibleForeground(const sptr<SceneSession>& session) const; 206 207 void SetRootSceneContext(const std::weak_ptr<AbilityRuntime::Context>& contextWeak); 208 sptr<RootSceneSession> GetRootSceneSession(); 209 sptr<SceneSession> GetSceneSession(int32_t persistentId); 210 sptr<SceneSession> GetMainParentSceneSession(int32_t persistentId, 211 const std::map<int32_t, sptr<SceneSession>>& sessionMap); 212 void PostFlushWindowInfoTask(FlushWindowInfoTask&& task, const std::string& taskName, const int delayTime); 213 214 sptr<SceneSession> GetSceneSessionByIdentityInfo(const SessionIdentityInfo& info); 215 sptr<SceneSession> GetSceneSessionByType(WindowType type); 216 std::vector<sptr<SceneSession>> GetSceneSessionByBundleName(const std::string& bundleName); 217 218 WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, 219 const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, 220 sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session, 221 SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr) override; 222 WSError DestroyAndDisconnectSpecificSession(const int32_t persistentId) override; 223 WSError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId, 224 const sptr<IRemoteObject>& callback) override; 225 void SetCreateSystemSessionListener(const NotifyCreateSystemSessionFunc& func); 226 void SetCreateKeyboardSessionListener(const NotifyCreateKeyboardSessionFunc& func); 227 void SetStatusBarEnabledChangeListener(const ProcessStatusBarEnabledChangeFunc& func); 228 void SetStartUIAbilityErrorListener(const ProcessStartUIAbilityErrorFunc& func); 229 void SetGestureNavigationEnabledChangeListener(const ProcessGestureNavigationEnabledChangeFunc& func); 230 void SetDumpRootSceneElementInfoListener(const DumpRootSceneElementInfoFunc& func); 231 void SetOutsideDownEventListener(const ProcessOutsideDownEventFunc& func); 232 void SetShiftFocusListener(const ProcessShiftFocusFunc& func); 233 void SetSCBFocusedListener(const NotifySCBAfterUpdateFocusFunc& func); 234 void SetSCBUnfocusedListener(const NotifySCBAfterUpdateFocusFunc& func); 235 void SetSCBFocusChangeListener(const NotifyDiffSCBAfterUpdateFocusFunc&& func); 236 void SetCallingSessionIdSessionListenser(const ProcessCallingSessionIdChangeFunc& func); 237 void SetDumpUITreeFunc(const DumpUITreeFunc& func); 238 const AppWindowSceneConfig& GetWindowSceneConfig() const; 239 240 /* 241 * Window Recover 242 */ 243 WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage, 244 const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, 245 sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr) override; 246 WSError RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage, 247 const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, 248 sptr<ISession>& session, sptr<WindowSessionProperty> property = nullptr, 249 sptr<IRemoteObject> token = nullptr) override; 250 WSError GetBatchAbilityInfos(const std::vector<std::string>& bundleNames, int32_t userId, 251 std::vector<SCBAbilityInfo>& scbAbilityInfos); 252 void SetRecoverSceneSessionListener(const NotifyRecoverSceneSessionFunc& func); 253 void UpdateRecoveredSessionInfo(const std::vector<int32_t>& recoveredPersistentIds); 254 void NotifyRecoveringFinished(); 255 bool IsInputEventEnabled() const; 256 void SetEnableInputEvent(bool enabled); 257 void SetAlivePersistentIds(const std::vector<int32_t>& alivePersistentIds); 258 259 /* 260 * Window Input Event 261 */ 262 void RegisterWatchGestureConsumeResultCallback(NotifyWatchGestureConsumeResultFunc&& func); 263 WMError NotifyWatchGestureConsumeResult(int32_t keyCode, bool isConsumed) override; 264 void RegisterWatchFocusActiveChangeCallback(NotifyWatchFocusActiveChangeFunc&& func); 265 WMError NotifyWatchFocusActiveChange(bool isActive) override; 266 void RegisterFlushWindowInfoCallback(); 267 void FlushWindowInfoToMMI(const bool forceFlush = false); 268 void SendCancelEventBeforeEraseSession(const sptr<SceneSession>& sceneSession); 269 void BuildCancelPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, int32_t fingerId, 270 int32_t action, int32_t wid); 271 272 /* 273 * Window Rotate Animation 274 */ 275 void UpdateRotateAnimationConfig(const RotateAnimationConfig& config); 276 void CloseSyncTransaction(std::function<void()> func); 277 const std::vector<sptr<SceneSession>> GetActiveSceneSessionCopy(); 278 279 WSError ProcessBackEvent(); 280 WSError BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken) override; 281 WMError SetGestureNavigationEnabled(bool enable) override; 282 WMError RegisterWindowManagerAgent(WindowManagerAgentType type, 283 const sptr<IWindowManagerAgent>& windowManagerAgent) override; 284 WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, 285 const sptr<IWindowManagerAgent>& windowManagerAgent) override; 286 287 /* 288 * Dump 289 */ 290 WSError GetAllSessionDumpInfo(std::string& info); 291 WSError GetAllSessionDumpDetailInfo(std::string& info); 292 WSError GetSpecifiedSessionDumpInfo(std::string& dumpInfo, const std::vector<std::string>& params, 293 const std::string& strId); 294 WSError GetSCBDebugDumpInfo(std::string&& cmd, std::string& dumpInfo); 295 WSError GetSessionDumpInfo(const std::vector<std::string>& params, std::string& info) override; 296 WSError DumpSessionAll(std::vector<std::string>& infos) override; 297 WSError DumpSessionWithId(int32_t persistentId, std::vector<std::string>& infos) override; 298 299 /* 300 * Window Focus 301 */ 302 WSError SetFocusedSessionId(const int32_t persistentId, const DisplayId displayId); 303 int32_t GetFocusedSessionId(DisplayId displayId = DEFAULT_DISPLAY_ID) const; 304 DisplayId GetDisplayGroupId(DisplayId displayId = DEFAULT_DISPLAY_ID) const; 305 std::vector<std::pair<DisplayId, int32_t>> GetAllFocusedSessionList() const; GetFocusChangeReason()306 FocusChangeReason GetFocusChangeReason() const { return focusChangeReason_; } 307 WMError RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground = true, 308 FocusChangeReason reason = FocusChangeReason::DEFAULT) override; 309 WMError RequestFocusStatusBySCB(int32_t persistentId, bool isFocused, bool byForeground = true, 310 FocusChangeReason reason = FocusChangeReason::DEFAULT); 311 WMError RequestFocusStatusBySA(int32_t persistentId, bool isFocused = true, 312 bool byForeground = true, FocusChangeReason reason = FocusChangeReason::SA_REQUEST) override; 313 void RequestAllAppSessionUnfocus(); 314 WSError UpdateFocus(int32_t persistentId, bool isFocused); 315 WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) override; 316 void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override; 317 WSError GetFocusSessionToken(sptr<IRemoteObject>& token, DisplayId displayId = DEFAULT_DISPLAY_ID) override; 318 WSError GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId = DEFAULT_DISPLAY_ID) override; 319 WSError IsFocusWindowParent(const sptr<IRemoteObject>& token, bool& isParent); 320 WSError AddFocusGroup(DisplayGroupId displayGroupId, DisplayId displayId); 321 WSError RemoveFocusGroup(DisplayGroupId displayGroupId, DisplayId displayId); 322 WSError SendPointerEventForHover(const std::shared_ptr<MMI::PointerEvent>& pointerEvent); 323 324 WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode); 325 WSError SendTouchEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, uint32_t zIndex); 326 WSError RaiseWindowToTop(int32_t persistentId) override; 327 void SetScreenLocked(const bool isScreenLocked); 328 bool IsScreenLocked() const; 329 void ConfigSupportZLevel(); 330 331 /* 332 * Multi User 333 */ 334 WSError InitUserInfo(int32_t userId, std::string& fileDir); 335 void HandleUserSwitch(const UserSwitchEventType type, const bool isUserActive); 336 int32_t GetCurrentUserId() const; 337 338 void StartWindowInfoReportLoop(); 339 340 void NotifyCompleteFirstFrameDrawing(int32_t persistentId); 341 void NotifySessionMovedToFront(int32_t persistentId); 342 WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) override; 343 WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) override; 344 WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) override; 345 void HandleTurnScreenOn(const sptr<SceneSession>& sceneSession); 346 void HandleKeepScreenOn(const sptr<SceneSession>& sceneSession, bool requireLock, 347 const std::string& screenLockPrefix, std::shared_ptr<PowerMgr::RunningLock>& screenLock); 348 void InitWithRenderServiceAdded(); 349 350 WSError RegisterSessionListener(const sptr<ISessionListener>& listener) override; 351 WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) override; 352 WSError GetSessionInfos(const std::string& deviceId, int32_t numMax, 353 std::vector<SessionInfoBean>& sessionInfos) override; 354 WSError GetMainWindowStatesByPid(int32_t pid, std::vector<MainWindowState>& windowStates); 355 WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) override; 356 WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId, 357 SessionInfoBean& sessionInfo) override; 358 WSError GetAllAbilityInfos(const AAFwk::Want& want, int32_t userId, 359 std::vector<SCBAbilityInfo>& scbAbilityInfos); 360 WSError GetAbilityInfo(const std::string& bundleName, const std::string& moduleName, 361 const std::string& abilityName, int32_t userId, SCBAbilityInfo& scbAbilityInfo); 362 WSError PrepareTerminate(int32_t persistentId, bool& isPrepareTerminate); 363 364 WSError UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener) override; 365 WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId, 366 SessionSnapshot& snapshot, bool isLowResolution) override; 367 WMError GetSessionSnapshotById(int32_t persistentId, SessionSnapshot& snapshot) override; 368 WSError SetVmaCacheStatus(bool flag); 369 WSError GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj) override; 370 WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) override; 371 WSError LockSession(int32_t sessionId) override; 372 WSError UnlockSession(int32_t sessionId) override; 373 WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override; 374 WMError GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId) override; 375 376 /* 377 * PC Window 378 */ 379 WMError IsPcWindow(bool& isPcWindow) override; 380 WMError IsFreeMultiWindow(bool& isFreeMultiWindow) override; 381 WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) override; 382 WMError IsWindowRectAutoSave(const std::string& key, bool& enabled, int persistentId) override; 383 void SetIsWindowRectAutoSave(const std::string& key, bool enabled, 384 const std::string& abilityKey, bool isSaveBySpecifiedFlag); 385 int32_t ChangeUIAbilityVisibilityBySCB(const sptr<SceneSession>& sceneSession, bool visibility, 386 bool isNewWant, bool isFromClient = true); 387 WMError ShiftAppWindowPointerEvent(int32_t sourcePersistentId, int32_t targetPersistentId, 388 int32_t fingerId) override; 389 void SetFocusedSessionDisplayIdIfNeeded(sptr<SceneSession>& newSession); 390 WMError GetWindowLimits(int32_t windowId, WindowLimits& windowLimits); 391 392 /* 393 * Sub Window 394 */ 395 WMError SetParentWindow(int32_t subWindowId, int32_t newParentWindowId) override; 396 397 std::map<int32_t, sptr<SceneSession>>& GetSessionMapByScreenId(ScreenId id); 398 void UpdatePrivateStateAndNotify(uint32_t persistentId); 399 void InitPersistentStorage(); 400 void OnOutsideDownEvent(int32_t x, int32_t y); 401 WSError GetDisplayGroupIdFromSceneSession(const sptr<SceneSession>& session, DisplayId& displayGroupId) const; 402 bool IsSameDisplayGroupId(const sptr<SceneSession>& session, const DisplayId touchDisplayGroupId) const; 403 void NotifySessionTouchOutside(int32_t persistentId, DisplayId displayId); 404 405 WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) override; 406 WMError GetUnreliableWindowInfo(int32_t windowId, 407 std::vector<sptr<UnreliableWindowInfo>>& infos) override; 408 WSError SetWindowFlags(const sptr<SceneSession>& sceneSession, const sptr<WindowSessionProperty>& property); 409 410 void OnScreenshot(DisplayId displayId); 411 void NotifyDumpInfoResult(const std::vector<std::string>& info) override; 412 void SetVirtualPixelRatioChangeListener(const ProcessVirtualPixelRatioChangeFunc& func); 413 void ProcessVirtualPixelRatioChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 414 const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type); 415 void ProcessUpdateRotationChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, 416 const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type); 417 418 void SetRootSceneProcessBackEventFunc(const RootSceneProcessBackEventFunc& processBackEventFunc); 419 void RegisterWindowChanged(const WindowChangedFunc& func); 420 WSError CloneWindow(int32_t fromPersistentId, int32_t toPersistentId, bool needOffScreen = true); 421 422 /* 423 * Collaborator 424 */ 425 void SetAbilityManagerCollaboratorRegisteredFunc(const AbilityManagerCollaboratorRegisteredFunc& func); 426 WSError RegisterIAbilityManagerCollaborator(int32_t type, 427 const sptr<AAFwk::IAbilityManagerCollaborator>& impl) override; 428 WSError UnregisterIAbilityManagerCollaborator(int32_t type) override; 429 void ClearAllCollaboratorSessions(); 430 431 WMError CheckWindowId(int32_t windowId, int32_t& pid) override; 432 void GetSceneSessionPrivacyModeBundles(DisplayId displayId, std::unordered_set<std::string>& privacyBundles); 433 BrokerStates CheckIfReuseSession(SessionInfo& sessionInfo); 434 bool CheckCollaboratorType(int32_t type); 435 sptr<SceneSession> FindSessionByAffinity(const std::string& affinity); 436 void AddWindowDragHotArea(DisplayId displayId, uint32_t type, WSRect& area); 437 void PreloadInLakeApp(const std::string& bundleName); 438 WSError UpdateMaximizeMode(int32_t persistentId, bool isMaximize); 439 WSError UpdateSessionDisplayId(int32_t persistentId, uint64_t screenId); 440 WSError NotifyStackEmpty(int32_t persistentId); 441 void NotifySessionUpdate(const SessionInfo& sessionInfo, ActionType type, 442 ScreenId fromScreenId = SCREEN_ID_INVALID); 443 WMError GetSurfaceNodeIdsFromMissionIds(std::vector<uint64_t>& missionIds, 444 std::vector<uint64_t>& surfaceNodeIds, bool isBlackList = false); 445 WMError GetSurfaceNodeIdsFromSubSession( 446 const sptr<SceneSession>& sceneSession, std::vector<uint64_t>& surfaceNodeIds); 447 WMError UpdateSubSessionBlackList(const sptr<SceneSession>& sceneSession); 448 WMError RemoveSessionFromBlackList(const sptr<SceneSession>& sceneSession); 449 WMError SetSurfaceNodeIds(DisplayId displayId, const std::vector<uint64_t>& surfaceNodeIds); 450 WMError OnVirtualScreenDisconnected(DisplayId displayId); 451 WSError UpdateTitleInTargetPos(int32_t persistentId, bool isShow, int32_t height); 452 453 /* 454 * Window Immersive 455 */ 456 WSError GetIsLayoutFullScreen(bool& isLayoutFullScreen); 457 WSError UpdateSessionAvoidAreaListener(int32_t persistentId, bool haveListener) override; 458 void RegisterNotifyRootSceneAvoidAreaChangeFunc(NotifyRootSceneAvoidAreaChangeFunc&& func); 459 void UpdateRootSceneAvoidArea(); 460 bool GetImmersiveState(ScreenId screenId); 461 WSError NotifyStatusBarShowStatus(int32_t persistentId, bool isVisible); 462 void NotifyStatusBarConstantlyShow(DisplayId displayId, bool isVisible); 463 void GetStatusBarConstantlyShow(DisplayId displayId, bool& isVisible) const; 464 WSError NotifyAINavigationBarShowStatus(bool isVisible, WSRect barArea, uint64_t displayId); 465 WSError NotifyNextAvoidRectInfo(AvoidAreaType type, 466 const WSRect& portraitRect, const WSRect& landspaceRect, DisplayId displayId); 467 WSError GetNextAvoidRectInfo(DisplayId displayId, AvoidAreaType type, 468 std::pair<WSRect, WSRect>& nextSystemBarAvoidAreaRectInfo); 469 WSRect GetAINavigationBarArea(uint64_t displayId); 470 void ClearDisplayStatusBarTemporarilyFlags(); 471 AvoidArea GetRootSessionAvoidAreaByType(AvoidAreaType type); 472 uint32_t GetRootSceneStatusBarHeight() const; 473 void SetOnFlushUIParamsFunc(OnFlushUIParamsFunc&& func); 474 void SetIsRootSceneLastFrameLayoutFinishedFunc(IsRootSceneLastFrameLayoutFinishedFunc&& func); 475 void SetStatusBarDefaultVisibilityPerDisplay(DisplayId displayId, bool visible); 476 bool GetStatusBarDefaultVisibilityByDisplayId(DisplayId displayId); 477 void SetStatusBarAvoidHeight(DisplayId displayId, int32_t height); 478 void GetStatusBarAvoidHeight(DisplayId displayId, WSRect& barArea); 479 480 WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override; 481 void DealwithVisibilityChange(const std::vector<std::pair<uint64_t, WindowVisibilityState>>& visibilityChangeInfos, 482 const std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData); 483 void NotifyUpdateRectAfterLayout(); 484 void FlushUIParams(ScreenId screenId, std::unordered_map<int32_t, SessionUIParam>&& uiParams); 485 WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener) override; 486 WMError SetSystemAnimatedScenes(SystemAnimatedSceneType sceneType, bool isRegularAnimation = false); 487 488 std::shared_ptr<Media::PixelMap> GetSessionSnapshotPixelMap(const int32_t persistentId, const float scaleParam, 489 const SnapshotNodeType snapshotNode = SnapshotNodeType::DEFAULT_NODE, bool needSnapshot = true); 490 WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override; 491 const std::map<int32_t, sptr<SceneSession>> GetSceneSessionMap(); 492 void GetAllSceneSession(std::vector<sptr<SceneSession>>& sceneSessions); 493 void GetAllWindowVisibilityInfos(std::vector<std::pair<int32_t, uint32_t>>& windowVisibilityInfos); 494 495 /* 496 * Keyboard Window 497 */ 498 void RequestInputMethodCloseKeyboard(int32_t persistentId); 499 void GetKeyboardOccupiedAreaWithRotation( 500 int32_t persistentId, Rotation rotation, std::vector<std::pair<bool, WSRect>>& avoidAreas); 501 void ReportKeyboardCreateException(sptr<SceneSession>& keyboardSession); 502 void ConfigSupportFunctionType(SupportFunctionType funcType); 503 504 /* 505 * UIExtension 506 */ 507 uint32_t GetLockScreenZOrder(); 508 WMError CheckUIExtensionCreation(int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName& element, 509 AppExecFwk::ExtensionAbilityType extensionAbilityType, int32_t& pid); 510 void OnNotifyAboveLockScreen(const std::vector<int32_t>& windowIds); 511 void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage, 512 const sptr<IRemoteObject>& token, uint64_t surfaceNodeId, bool isConstrainedModal = false) override; 513 void RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage, 514 const sptr<IRemoteObject>& token, bool isConstrainedModal = false) override; 515 void UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect) override; 516 void ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY) override; 517 WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override; 518 WSError CheckExtWindowFlagsPermission(ExtensionWindowFlags& actions) const; 519 WSError UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags, 520 uint32_t extWindowActions) override; 521 void CheckSceneZOrder(); 522 WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override; 523 WSError GetHostGlobalScaledRect(int32_t hostWindowId, Rect& globalScaledRect) override; 524 WMError GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus) override; 525 WMError GetCallingWindowRect(int32_t persistentId, Rect& rect) override; 526 WMError GetWindowModeType(WindowModeType& windowModeType) override; 527 WMError GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber, 528 int32_t x, int32_t y, std::vector<int32_t>& windowIds) override; 529 void ChangeWindowRectYInVirtualDisplay(DisplayId& displayId, int32_t& y); 530 WSError UseImplicitAnimation(int32_t hostWindowId, bool useImplicit) override; 531 532 int32_t ReclaimPurgeableCleanMem(); 533 void OnBundleUpdated(const std::string& bundleName, int userId); 534 void OnConfigurationUpdated(const std::shared_ptr<AppExecFwk::Configuration>& configuration); 535 GetTaskScheduler()536 std::shared_ptr<TaskScheduler> GetTaskScheduler() { return taskScheduler_; } 537 538 int32_t GetCustomDecorHeight(int32_t persistentId); 539 540 /* 541 * Free Multi Window 542 */ 543 WSError SwitchFreeMultiWindow(bool enable); 544 WSError GetFreeMultiWindowEnableState(bool& enable) override; 545 WMError SetForegroundWindowNum(uint32_t windowNum) override; 546 void RegisterSetForegroundWindowNumCallback(SetForegroundWindowNumFunc&& func); 547 548 const SystemSessionConfig& GetSystemSessionConfig() const; 549 WSError NotifyEnterRecentTask(bool enterRecent); 550 WMError UpdateDisplayHookInfo(int32_t uid, uint32_t width, uint32_t height, float_t density, bool enable); 551 WMError UpdateAppHookDisplayInfo(int32_t uid, const HookInfo& hookInfo, bool enable); 552 WMError NotifyHookOrientationChange(int32_t persistentId); 553 void InitScheduleUtils(); 554 void ProcessDisplayScale(sptr<DisplayInfo>& displayInfo); 555 WMError GetRootMainWindowId(int32_t persistentId, int32_t& hostWindowId); 556 557 /* 558 * Move Drag 559 */ 560 WMError SetGlobalDragResizeType(DragResizeType dragResizeType) override; 561 WMError GetGlobalDragResizeType(DragResizeType& dragResizeType) override; 562 WMError SetAppDragResizeType(const std::string& bundleName, DragResizeType dragResizeType) override; 563 WMError GetAppDragResizeType(const std::string& bundleName, DragResizeType& dragResizeType) override; 564 WMError SetAppDragResizeTypeInner(const std::string& bundleName, DragResizeType dragResizeType); 565 WMError SetAppKeyFramePolicy(const std::string& bundleName, const KeyFramePolicy& keyFramePolicy) override; 566 KeyFramePolicy GetAppKeyFramePolicy(const std::string& bundleName); 567 568 /* 569 * Window Layout 570 */ 571 SingleHandTransform GetNormalSingleHandTransform() const; 572 SingleHandScreenInfo GetSingleHandScreenInfo() const; 573 WSRect GetOriginRect() const; 574 WSRect GetSingleHandRect() const; 575 void NotifySingleHandInfoChange(SingleHandScreenInfo singleHandScreenInfo, WSRect originRect, 576 WSRect singleHandRect); 577 void RegisterGetRSNodeByStringIDFunc(GetRSNodeByStringIDFunc&& func); 578 void RegisterSetTopWindowBoundaryByIDFunc(SetTopWindowBoundaryByIDFunc&& func); 579 void RegisterSingleHandContainerNode(const std::string& stringId); 580 const SingleHandCompatibleModeConfig& GetSingleHandCompatibleModeConfig() const; 581 void ConfigSupportFollowParentWindowLayout(); 582 void ConfigSupportFollowRelativePositionToParent(); 583 void SetHasRootSceneRequestedVsyncFunc(HasRootSceneRequestedVsyncFunc&& func); 584 void SetRequestVsyncByRootSceneWhenModeChangeFunc(RequestVsyncByRootSceneWhenModeChangeFunc&& func); 585 WMError UpdateWindowModeByIdForUITest(int32_t windowId, int32_t updateMode) override; 586 WMError UpdateAppHookWindowInfo(const std::string& bundleName, const HookWindowInfo& hookWindowInfo); 587 HookWindowInfo GetAppHookWindowInfo(const std::string& bundleName); 588 void UpdateAppHookWindowInfoWhenSwitchFreeMultiWindow(bool isOpenFreeMultiWindow); 589 590 /* 591 * Window Property 592 */ 593 WMError UpdateScreenLockStatusForApp(const std::string& bundleName, bool isRelease) override; 594 void DealwithDrawingContentChange(const std::vector<std::pair<uint64_t, bool>>& drawingContentChangeInfo); 595 WMError ListWindowInfo(const WindowInfoOption& windowInfoOption, std::vector<sptr<WindowInfo>>& infos) override; 596 WMError GetAllWindowLayoutInfo(DisplayId displayId, std::vector<sptr<WindowLayoutInfo>>& infos) override; 597 WMError GetGlobalWindowMode(DisplayId displayId, GlobalWindowMode& globalWinMode) override; 598 WMError GetTopNavDestinationName(int32_t windowId, std::string& topNavDestName) override; 599 void SetSkipSelfWhenShowOnVirtualScreen(uint64_t surfaceNodeId, bool isSkip); 600 WMError AddSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t>& persistentIds) override; 601 WMError RemoveSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t>& persistentIds) override; 602 WMError SetScreenPrivacyWindowTagSwitch( 603 uint64_t screenId, const std::vector<std::string>& privacyWindowTags, bool enable) override; 604 void NotifyOnAttachToFrameNode(const sptr<Session>& session); 605 WMError NotifyScreenshotEvent(ScreenshotEventType type) override; 606 WMError UpdateSessionScreenshotAppEventListener(int32_t persistentId, bool haveListener); 607 WMError AddSessionBlackList(const std::unordered_set<std::string>& bundleNames, 608 const std::unordered_set<std::string>& privacyWindowTags) override; 609 WMError RemoveSessionBlackList(const std::unordered_set<std::string>& bundleNames, 610 const std::unordered_set<std::string>& privacyWindowTags) override; 611 612 /* 613 * Multi Window 614 */ 615 void SetCloseTargetFloatWindowFunc(const ProcessCloseTargetFloatWindowFunc& func); 616 WMError CloseTargetFloatWindow(const std::string& bundleName); 617 618 /* 619 * Fold Screen Status Change Report 620 */ 621 WMError ReportScreenFoldStatusChange(const std::vector<std::string>& screenFoldInfo); 622 623 void SetBehindWindowFilterEnabled(bool enabled); 624 void UpdateSecSurfaceInfo(std::shared_ptr<RSUIExtensionData> secExtensionData, uint64_t userId); 625 void UpdateConstrainedModalUIExtInfo(std::shared_ptr<RSUIExtensionData> constrainedModalUIExtData, uint64_t userId); 626 WSError SetAppForceLandscapeConfig(const std::string& bundleName, const AppForceLandscapeConfig& config); 627 AppForceLandscapeConfig GetAppForceLandscapeConfig(const std::string& bundleName); 628 WMError GetWindowStyleType(WindowStyleType& windowStyletype) override; 629 WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, 630 const std::vector<int32_t>& persistentIds, std::vector<uint64_t>& surfaceNodeIds) override; 631 632 /* 633 * Window ZOrder: PC 634 */ 635 void RefreshPcZOrderList(uint32_t startZOrder, std::vector<int32_t>&& persistentIds); 636 637 /* 638 * PiP Window 639 */ 640 WMError CloseTargetPiPWindow(const std::string& bundleName); 641 WMError GetCurrentPiPWindowInfo(std::string& bundleName); 642 WMError GetPiPSettingSwitchStatus(bool& switchStatus) override; 643 void SetPiPSettingSwitchStatus(bool switchStatus); 644 void SetStartPiPFailedListener(NotifyStartPiPFailedFunc&& func); 645 646 /* 647 * FloatingBall Window 648 */ 649 WMError GetFbPanelWindowId(uint32_t& windowId); 650 651 /* 652 * Window Watermark 653 */ 654 WMError SetProcessWatermark(int32_t pid, const std::string& watermarkName, bool isEnabled) override; 655 656 /* 657 * Window Snapshot 658 */ 659 WMError SkipSnapshotForAppProcess(int32_t pid, bool skip) override; 660 WMError SkipSnapshotByUserIdAndBundleNames(int32_t userId, 661 const std::vector<std::string>& bundleNameList) override; 662 663 /* 664 * Multi Instance 665 */ 666 uint32_t GetMaxInstanceCount(const std::string& bundleName); 667 uint32_t GetInstanceCount(const std::string& bundleName); 668 std::string GetLastInstanceKey(const std::string& bundleName); 669 void RefreshAppInfo(const std::string& bundleName); 670 671 /* 672 * Screen Manager 673 */ 674 WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds, 675 std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) override; 676 677 /* 678 * Specific Window 679 */ 680 void RegisterCreateSubSessionListener(int32_t persistentId, const NotifyCreateSubSessionFunc& func); 681 void RegisterBindDialogTargetListener(const sptr<SceneSession>& session, NotifyBindDialogSessionFunc&& func); 682 void UnregisterSpecificSessionCreateListener(int32_t persistentId); 683 WMError HasFloatingWindowForeground(const sptr<IRemoteObject>& abilityToken, 684 bool& hasOrNot) override; 685 686 /* 687 * Window Lifecycle 688 */ 689 void GetMainSessionByBundleNameAndAppIndex( 690 const std::string& bundleName, int32_t appIndex, std::vector<sptr<SceneSession>>& mainSessions); 691 WSError NotifyAppUseControlList( 692 ControlAppType type, int32_t userId, const std::vector<AppUseControlInfo>& controlList); 693 void RegisterNotifyAppUseControlListCallback(NotifyAppUseControlListFunc&& func); 694 WMError MinimizeMainSession(const std::string& bundleName, int32_t appIndex, int32_t userId); 695 sptr<SceneSession> RequestSceneSession(const SessionInfo& sessionInfo, 696 sptr<WindowSessionProperty> property = nullptr); 697 void UpdateSceneSessionWant(const SessionInfo& sessionInfo); 698 WSError RequestSceneSessionActivation(const sptr<SceneSession>& sceneSession, bool isNewActive, 699 int32_t requestId = DEFAULT_REQUEST_FROM_SCB_ID); 700 WSError RequestSceneSessionBackground(const sptr<SceneSession>& sceneSession, const bool isDelegator = false, 701 const bool isToDesktop = false, const bool isSaveSnapshot = true, 702 ScreenLockReason reason = ScreenLockReason::DEFAULT); 703 WSError RequestSceneSessionDestruction(const sptr<SceneSession>& sceneSession, bool needRemoveSession = true, 704 bool isSaveSnapshot = true, const bool isForceClean = false, bool isUserRequestedExit = false); 705 WSError RequestSceneSessionDestructionInner(sptr<SceneSession>& sceneSession, 706 sptr<AAFwk::SessionInfo> sceneSessionInfo, const bool needRemoveSession, const bool isForceClean = false, 707 bool isUserRequestedExit = false); 708 void NotifyForegroundInteractiveStatus(const sptr<SceneSession>& sceneSession, bool interactive); 709 WSError RequestSceneSessionByCall(const sptr<SceneSession>& sceneSession, 710 int32_t requestId = DEFAULT_REQUEST_FROM_SCB_ID); 711 void StartAbilityBySpecified(const SessionInfo& sessionInfo); 712 void NotifyWindowStateErrorFromMMI(int32_t pid, int32_t persistentId); 713 void RemoveLifeCycleTaskByPersistentId(int32_t persistentId, const LifeCycleTaskType taskType); 714 WSError PendingSessionToForeground(const sptr<IRemoteObject>& token) override; 715 WSError PendingSessionToBackground(const sptr<IRemoteObject>& token, const BackgroundParams& params); 716 WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token, 717 bool shouldBackToCaller = true) override; 718 WSError TerminateSessionNew( 719 const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) override; 720 WSError ClearSession(int32_t persistentId) override; 721 WSError ClearAllSessions() override; 722 WSError MoveSessionsToForeground(const std::vector<int32_t>& sessionIds, int32_t topSessionId) override; 723 WSError MoveSessionsToBackground(const std::vector<int32_t>& sessionIds, std::vector<int32_t>& result) override; 724 int32_t StartUIAbilityBySCB(sptr<AAFwk::SessionInfo>& abilitySessionInfo, sptr<SceneSession>& sceneSession); 725 int32_t StartUIAbilityBySCB(sptr<SceneSession>& sceneSessions); 726 WMError GetMainWindowInfos(int32_t topNum, std::vector<MainWindowInfo>& topNInfo); 727 WMError GetCallingWindowInfo(CallingWindowInfo& callingWindowInfo); 728 void NotifyDisplayIdChanged(int32_t persistentId, uint64_t displayId); 729 WMError GetAllMainWindowInfos(std::vector<MainWindowInfo>& infos) const; 730 WMError ClearMainSessions(const std::vector<int32_t>& persistentIds, std::vector<int32_t>& clearFailedIds); 731 WMError TerminateSessionByPersistentId(int32_t persistentId); 732 void SetUserAuthPassed(bool isUserAuthPassed); 733 bool IsUserAuthPassed() const; 734 void GetMainSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, 735 std::vector<sptr<SceneSession>>& mainSessions) const; 736 WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, bool isLock); 737 WMError RegisterSessionLifecycleListener(const sptr<ISessionLifecycleListener>& listener, 738 const std::vector<int32_t>& persistentIdList); 739 WMError RegisterSessionLifecycleListener(const sptr<ISessionLifecycleListener>& listener, 740 const std::vector<std::string>& bundleNameList); 741 WMError UnregisterSessionLifecycleListener(const sptr<ISessionLifecycleListener>& listener); 742 bool IsMainWindowByPersistentId(int32_t persistentId); 743 WMError MinimizeByWindowId(const std::vector<int32_t>& windowIds) override; 744 void RegisterMinimizeByWindowIdCallback(MinimizeByWindowIdFunc&& func); 745 void RegisterSceneSessionDestructCallback(NotifySceneSessionDestructFunc&& func); 746 void RegisterTransferSessionToTargetScreenCallback(NotifyTransferSessionToTargetScreenFunc&& func); 747 WMError NotifyTransferSessionToTargetScreen(const TransferSessionInfo& info); 748 void NotifySessionTransferToTargetScreenEvent(const int32_t persistentId, 749 const uint32_t resultCode, const uint64_t fromScreenid, const uint64_t toScreenId); 750 WSError GetApplicationInfo(const std::string& bundleName, SCBApplicationInfo& scbApplicationInfo); 751 WSError GetRecentMainSessionInfoList(std::vector<RecentSessionInfo>& recentSessionInfoList); 752 void UpdateRecentMainSessionInfos(const std::vector<int32_t>& recentMainSessionIdList); 753 sptr<SceneSession> GetMainSessionByPersistentId(int32_t persistentId) const; 754 WMError GetRouterStackInfo(int32_t persistentId, const sptr<ISessionRouterStackListener>& listener); 755 WMError CreateNewInstanceKey(const std::string& bundleName, std::string& instanceKey); 756 WMError RemoveInstanceKey(const std::string& bundleName, const std::string& instanceKey); 757 void RefreshAllAppUseControlMap(const AppUseControlInfo& appUseControlInfo, ControlAppType type); 758 void NotifyAmsPendingSessionWhenFail(uint32_t resultCode, std::string resultMessage, 759 int32_t requestId); 760 WSError PendingSessionToBackgroundByPersistentId(const int32_t persistentId, bool shouldBackToCaller = true); 761 WMError UpdateKioskAppList(const std::vector<std::string>& kioskAppList); 762 WMError EnterKioskMode(const sptr<IRemoteObject>& token); 763 WMError ExitKioskMode(); 764 void ConfigSupportCreateFloatWindow(); 765 void RegisterGetStartWindowConfigCallback(const sptr<SceneSession>& sceneSession); 766 void RegisterUpdateKioskAppListCallback(UpdateKioskAppListFunc&& func); 767 void RegisterKioskModeChangeCallback(KioskModeChangeFunc&& func); 768 769 /* 770 * Window Pattern 771 */ 772 void SetDelayRemoveSnapshot(bool delayRemoveSnapshot); 773 bool GetDelayRemoveSnapshot() const; 774 void InitSnapshotCache(); 775 void VisitSnapshotFromCache(int32_t persistentId); 776 void PutSnapshotToCache(int32_t persistentId); 777 void RemoveSnapshotFromCache(int32_t persistentId); 778 void GetStartupPage(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo); 779 std::shared_ptr<Media::PixelMap> GetPreLoadStartingWindow(const SessionInfo& sessionInfo); 780 void RemovePreLoadStartingWindowFromMap(const SessionInfo& sessionInfo); 781 WSError RegisterSaveSnapshotFunc(const sptr<SceneSession>& sceneSession); 782 WSError RegisterRemoveSnapshotFunc(const sptr<SceneSession>& sceneSession); 783 std::shared_ptr<Media::PixelMap> GetPixelMap(uint32_t resourceId, 784 std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo); 785 bool GetPersistentImageFit(int32_t persistentId, int32_t& imageFit); 786 WMError SetStartWindowBackgroundColor(const std::string& moduleName, const std::string& abilityName, 787 uint32_t color, int32_t uid) override; 788 void ConfigSupportSnapshotAllSessionStatus(); 789 790 /* 791 * Window Animation 792 */ 793 WMError AnimateTo(int32_t windowId, const WindowAnimationProperty& animationProperty, 794 const WindowAnimationOption& animationOption) override; 795 796 std::vector<sptr<SceneSession>> GetSceneSessions(ScreenId screenId); 797 WMError UpdateScreenLockState(int32_t persistentId); 798 WMError UpdateSystemDecorEnable(bool enable); 799 800 protected: 801 SceneSessionManager(); 802 virtual ~SceneSessionManager(); 803 804 private: 805 std::atomic<bool> enterRecent_ { false }; 806 bool isKeyboardPanelEnabled_ = false; 807 static sptr<SceneSessionManager> CreateInstance(); isNotCurrentScreen(sptr<SceneSession> sceneSession,ScreenId screenId)808 static inline bool isNotCurrentScreen(sptr<SceneSession> sceneSession, ScreenId screenId) 809 { 810 return sceneSession->GetSessionInfo().screenId_ != screenId && 811 sceneSession->GetSessionInfo().screenId_ != SCREEN_ID_INVALID; 812 } 813 void Init(); 814 void RegisterAppListener(); 815 void InitPrepareTerminateConfig(); 816 void LoadWindowSceneXml(); 817 void LoadWindowParameter(); 818 void ConfigWindowSceneXml(); 819 void ConfigWindowSceneXml(const WindowSceneConfig::ConfigItem& config); 820 void ConfigWindowEffect(const WindowSceneConfig::ConfigItem& effectConfig); 821 void ConfigWindowImmersive(const WindowSceneConfig::ConfigItem& immersiveConfig); 822 void ConfigKeyboardAnimation(const WindowSceneConfig::ConfigItem& animationConfig); 823 void ConfigDefaultKeyboardAnimation(KeyboardSceneAnimationConfig& animationIn, 824 KeyboardSceneAnimationConfig& animationOut); 825 bool ConfigAppWindowCornerRadius(const WindowSceneConfig::ConfigItem& item, float& out); 826 bool ConfigAppWindowShadow(const WindowSceneConfig::ConfigItem& shadowConfig, WindowShadowConfig& outShadow); 827 bool ConfigStatusBar(const WindowSceneConfig::ConfigItem& config, StatusBarConfig& statusBarConfig); 828 void ConfigSystemUIStatusBar(const WindowSceneConfig::ConfigItem& statusBarConfig); 829 void ConfigDecor(const WindowSceneConfig::ConfigItem& decorConfig, bool mainConfig = true); 830 void ConfigWindowAnimation(const WindowSceneConfig::ConfigItem& windowAnimationConfig); 831 void ConfigStartingWindowAnimation(const WindowSceneConfig::ConfigItem& startingWindowConfig); 832 void ConfigWindowSizeLimits(); 833 void ConfigMainWindowSizeLimits(const WindowSceneConfig::ConfigItem& mainWindowSizeConifg); 834 void ConfigSubWindowSizeLimits(const WindowSceneConfig::ConfigItem& subWindowSizeConifg); 835 void ConfigDialogWindowSizeLimits(const WindowSceneConfig::ConfigItem& dialogWindowSizeConifg); 836 void ConfigSnapshotScale(); 837 void ConfigFreeMultiWindow(); 838 void LoadFreeMultiWindowConfig(bool enable); 839 840 std::tuple<std::string, std::vector<float>> CreateCurve(const WindowSceneConfig::ConfigItem& curveConfig); 841 void LoadKeyboardAnimation(const WindowSceneConfig::ConfigItem& item, KeyboardSceneAnimationConfig& config); 842 sptr<SceneSession::SpecificSessionCallback> CreateSpecificSessionCallback(); 843 sptr<KeyboardSession::KeyboardSessionCallback> CreateKeyboardSessionCallback(); 844 void FillSessionInfo(sptr<SceneSession>& sceneSession); 845 std::shared_ptr<AppExecFwk::AbilityInfo> QueryAbilityInfoFromBMS(const int32_t uId, const std::string& bundleName, 846 const std::string& abilityName, const std::string& moduleName, bool isAtomicServiceFreeInstall = false); 847 std::vector<sptr<SceneSession>> GetSubSceneSession(int32_t parentWindowId); 848 void RemoveDuplicateSubSession(const std::vector<std::pair<uint64_t, WindowVisibilityState>>& visibilityChangeInfo, 849 std::vector<sptr<SceneSession>>& subSessions); 850 void SetSessionVisibilityInfo(const sptr<SceneSession>& session, WindowVisibilityState visibleState, 851 std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos, std::string& visibilityInfo); 852 void UpdateSubWindowVisibility(const sptr<SceneSession>& session, WindowVisibilityState visibleState, 853 const std::vector<std::pair<uint64_t, WindowVisibilityState>>& visibilityChangeInfo, 854 std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos, std::string& visibilityInfo, 855 const std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData); 856 bool GetSessionRSVisible(const sptr<Session>& session, 857 const std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData); 858 std::string GetFloatWidth(const int width, float value); 859 860 /* 861 * Window Pipeline 862 */ 863 void ProcessFocusZOrderChange(uint32_t dirty); 864 void PostProcessFocus(); 865 void PostProcessProperty(uint32_t dirty); 866 867 /* 868 * Window Lifecycle 869 */ 870 bool isUserAuthPassed_ {false}; 871 NotifySceneSessionDestructFunc onSceneSessionDestruct_; 872 NotifyTransferSessionToTargetScreenFunc onTransferSessionToTargetScreen_; 873 std::unordered_map<std::string, std::unordered_map<ControlAppType, ControlInfo>> allAppUseControlMap_; 874 sptr<SceneSession> GetSceneSessionBySessionInfo(const SessionInfo& sessionInfo); 875 void CreateRootSceneSession(); 876 void InitSceneSession(sptr<SceneSession>& sceneSession, const SessionInfo& sessionInfo, 877 const sptr<WindowSessionProperty>& property) REQUIRES(SCENE_GUARD); 878 void InitFbWindow(const sptr<SceneSession>& sceneSession, const sptr<WindowSessionProperty>& property); 879 void RegisterSessionExceptionFunc(const sptr<SceneSession>& sceneSession); 880 void NotifySessionForeground(const sptr<SceneSession>& session, uint32_t reason, bool withAnimation); 881 void NotifySessionBackground(const sptr<SceneSession>& session, uint32_t reason, bool withAnimation, 882 bool isFromInnerkits); 883 std::vector<AppExecFwk::SupportWindowMode> ExtractSupportWindowModeFromMetaData( 884 const std::shared_ptr<AppExecFwk::AbilityInfo>& abilityInfo); 885 std::vector<AppExecFwk::SupportWindowMode> ParseWindowModeFromMetaData( 886 const std::string& supportModesInFreeMultiWindow); 887 WSError ClearSession(sptr<SceneSession> sceneSession); 888 bool IsSessionClearable(sptr<SceneSession> sceneSession); 889 void GetAllClearableSessions(std::vector<sptr<SceneSession>>& sessionVector); 890 sptr<AAFwk::SessionInfo> SetAbilitySessionInfo(const sptr<SceneSession>& sceneSession, 891 int32_t requestId = DEFAULT_REQUEST_FROM_SCB_ID); 892 void ResetWantInfo(const sptr<SceneSession>& sceneSession); 893 void ResetSceneSessionInfoWant(const sptr<AAFwk::SessionInfo>& sceneSessionInfo); 894 int32_t StartUIAbilityBySCBTimeoutCheck(const sptr<SceneSession>& sceneSession, 895 const sptr<AAFwk::SessionInfo>& abilitySessionInfo, 896 const uint32_t& windowStateChangeReason, bool& isColdStart); 897 sptr<SceneSession> GetHookedSessionByModuleName(const SessionInfo& sessionInfo); 898 void RegisterHookSceneSessionActivationFunc(const sptr<SceneSession>& sceneSession); 899 void SetSessionInfoStartWindowType(const sptr<SceneSession>& sceneSession); 900 void RegisterSceneSessionDestructNotifyManagerFunc(const sptr<SceneSession>& sceneSession); 901 void ResetSceneMissionInfo(const sptr<AAFwk::SessionInfo>& abilitySessionInfo); 902 void UpdateAbilityHookState(sptr<SceneSession>& sceneSession, bool isAbilityHook); 903 void CloseAllFd(std::shared_ptr<AAFwk::Want>& want); 904 905 /* 906 * Window Focus 907 */ 908 std::mutex highlightIdsMutex_; 909 std::unordered_set<int32_t> highlightIds_; 910 std::vector<std::pair<int32_t, sptr<SceneSession>>> GetSceneSessionVector(CmpFunc cmp); 911 void TraverseSessionTree(TraverseFunc func, bool isFromTopToBottom); 912 void TraverseSessionTreeFromTopToBottom(TraverseFunc func); 913 void TraverseSessionTreeFromBottomToTop(TraverseFunc func); 914 915 /* 916 * Window Focus 917 */ 918 WSError RequestSessionFocus(int32_t persistentId, bool byForeground = true, 919 FocusChangeReason reason = FocusChangeReason::DEFAULT); 920 WSError RequestSessionFocusImmediately(int32_t persistentId, bool blockNotifyUntilVisible = true); 921 WSError RequestSessionUnfocus(int32_t persistentId, FocusChangeReason reason = FocusChangeReason::DEFAULT); 922 WSError RequestAllAppSessionUnfocusInner(); 923 WSError RequestSessionFocusCheck(const sptr<SceneSession>& sceneSession, const sptr<FocusGroup>& focusGroup, 924 int32_t persistentId, bool byForeground, FocusChangeReason reason); 925 WSError RequestFocusBasicCheck(int32_t persistentId, const sptr<FocusGroup>& focusGroup); 926 bool CheckLastFocusedAppSessionFocus(const sptr<SceneSession>& focusedSession, 927 const sptr<SceneSession>& nextSession); 928 WSError RequestFocusSpecificCheck(DisplayId displayId, const sptr<SceneSession>& sceneSession, bool byForeground, 929 FocusChangeReason reason = FocusChangeReason::DEFAULT); 930 bool CheckTopmostWindowFocus(const sptr<SceneSession>& focusedSession, const sptr<SceneSession>& sceneSession); 931 bool CheckRequestFocusImmediately(const sptr<SceneSession>& sceneSession); 932 bool CheckRequestFocusSubWindowImmediately(const sptr<SceneSession>& sceneSession); 933 bool CheckFocusIsDownThroughBlockingType(const sptr<SceneSession>& requestSceneSession, 934 const sptr<SceneSession>& focusedSession, bool includingAppSession); 935 bool CheckClickFocusIsDownThroughFullScreen(const sptr<SceneSession>& focusedSession, 936 const sptr<SceneSession>& sceneSession, FocusChangeReason reason); 937 bool IsParentSessionVisible(const sptr<SceneSession>& session); 938 sptr<SceneSession> GetNextFocusableSession(DisplayId displayId, int32_t persistentId); 939 sptr<SceneSession> GetTopFloatingSession(DisplayId displayGroupId, int32_t persistentId); 940 sptr<SceneSession> GetNextFocusableSessionWhenFloatWindowExist(DisplayId displayGroupId, int32_t persistentId); 941 sptr<SceneSession> GetTopNearestBlockingFocusSession(DisplayId displayId, uint32_t zOrder, 942 bool includingAppSession); 943 sptr<SceneSession> GetTopFocusableNonAppSession(); 944 bool CheckBlockingFocus(const sptr<SceneSession>& session, bool includingAppSession); 945 WSError ShiftFocus(DisplayId displayId, const sptr<SceneSession>& nextSession, bool isProactiveUnfocus, 946 FocusChangeReason reason = FocusChangeReason::DEFAULT); 947 void UpdateFocusStatus(DisplayId displayId, const sptr<SceneSession>& sceneSession, bool isFocused); 948 void NotifyFocusStatus(const sptr<SceneSession>& sceneSession, bool isFocused, 949 const sptr<FocusGroup>& focusGroup); 950 int32_t NotifyRssThawApp(const int32_t uid, const std::string& bundleName, const std::string& reason); 951 void NotifyFocusStatusByMission(const sptr<SceneSession>& prevSession, const sptr<SceneSession>& currSession); 952 void NotifyUnFocusedByMission(const sptr<SceneSession>& sceneSession); 953 void NotifyFocusedByMission(const sptr<SceneSession>& sceneSession); 954 bool MissionChanged(const sptr<SceneSession>& prevSession, const sptr<SceneSession>& currSession); 955 std::string GetAllSessionFocusInfo(); 956 void RegisterRequestFocusStatusNotifyManagerFunc(const sptr<SceneSession>& sceneSession); 957 void ProcessUpdateLastFocusedAppId(const std::vector<std::pair<uint32_t, uint32_t>>& zOrderList); 958 WSError ProcessModalTopmostRequestFocusImmediately(const sptr<SceneSession>& sceneSession); 959 WSError ProcessSubWindowRequestFocusImmediately(const sptr<SceneSession>& sceneSession); 960 WSError ProcessDialogRequestFocusImmediately(const sptr<SceneSession>& sceneSession); 961 962 void RegisterGetStateFromManagerFunc(sptr<SceneSession>& sceneSession); 963 void RegisterSessionChangeByActionNotifyManagerFunc(sptr<SceneSession>& sceneSession); 964 965 WSError DestroyDialogWithMainWindow(const sptr<SceneSession>& sceneSession) REQUIRES(SCENE_GUARD); 966 sptr<SceneSession> FindMainWindowWithToken(sptr<IRemoteObject> targetToken); 967 WSError UpdateParentSessionForDialog(const sptr<SceneSession>& sceneSession, sptr<WindowSessionProperty> property); 968 void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); 969 void UpdateFocusableProperty(int32_t persistentId); 970 WMError UpdateTopmostProperty(const sptr<WindowSessionProperty>& property, const sptr<SceneSession>& sceneSession); 971 std::vector<sptr<SceneSession>> GetSceneSessionVectorByTypeAndDisplayId(WindowType type, uint64_t displayId); 972 std::vector<sptr<SceneSession>> GetSceneSessionVectorByType(WindowType type); 973 void UpdateOccupiedAreaIfNeed(int32_t persistentId); 974 void NotifyMMIWindowPidChange(int32_t windowId, bool startMoving); 975 void UpdateHighlightStatus(DisplayId displayId, const sptr<SceneSession>& preSceneSession, 976 const sptr<SceneSession>& currSceneSession, bool isProactiveUnfocus); 977 void SetHighlightSessionIds(const sptr<SceneSession>& sceneSession, bool needBlockHighlightNotify); 978 void AddHighlightSessionIds(const sptr<SceneSession>& sceneSession, bool needBlockHighlightNotify); 979 void RemoveHighlightSessionIds(const sptr<SceneSession>& sceneSession); 980 std::string GetHighlightIdsStr(); 981 982 /* 983 * PC Window 984 */ 985 WMError ShiftAppWindowPointerEventInner( 986 int32_t sourceWindowId, int32_t targetWindowId, DisplayId targetDisplayId, int32_t fingerId); 987 988 /* 989 * Window Animation 990 */ 991 WMError CreateUIEffectController(const sptr<IUIEffectControllerClient>& controllerClient, 992 sptr<IUIEffectController>& controller, int32_t& controllerId) override; 993 994 /* 995 * Sub Window 996 */ 997 WMError SetParentWindowInner(const sptr<SceneSession>& subSession, 998 const sptr<SceneSession>& oldParentSession, const sptr<SceneSession>& newParentSession); 999 1000 /* 1001 * Window Immersive 1002 */ 1003 void UpdateAvoidSessionAvoidArea(WindowType type); 1004 void UpdateNormalSessionAvoidArea(int32_t persistentId, const sptr<SceneSession>& sceneSession, bool& needUpdate); 1005 void UpdateAvoidArea(int32_t persistentId); 1006 void UpdateRootSceneSessionAvoidArea(int32_t persistentId, bool& needUpdate); 1007 void NotifyWindowSystemBarPropertyChange(WindowType type, const SystemBarProperty& systemBarProperty); 1008 1009 WSError IsLastFrameLayoutFinished(bool& isLayoutFinished); 1010 void HandleSpecificSystemBarProperty(WindowType type, const sptr<WindowSessionProperty>& property, 1011 const sptr<SceneSession>& sceneSession); 1012 1013 sptr<AppExecFwk::IBundleMgr> GetBundleManager(); 1014 std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager(const AppExecFwk::AbilityInfo& abilityInfo); 1015 1016 bool CheckIsRemote(const std::string& deviceId); 1017 bool GetLocalDeviceId(std::string& localDeviceId); 1018 std::string AnonymizeDeviceId(const std::string& deviceId); 1019 int GetRemoteSessionInfos(const std::string& deviceId, int32_t numMax, 1020 std::vector<SessionInfoBean>& sessionInfos); 1021 int GetRemoteSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo); 1022 WSError GetTotalUITreeInfo(std::string& dumpInfo); 1023 1024 void PerformRegisterInRequestSceneSession(sptr<SceneSession>& sceneSession); 1025 WSError RequestSceneSessionActivationInner(sptr<SceneSession>& sceneSession, bool isNewActive, 1026 int32_t requestId = DEFAULT_REQUEST_FROM_SCB_ID) REQUIRES(SCENE_GUARD); 1027 WSError SetBrightness(const sptr<SceneSession>& sceneSession, float brightness); 1028 void PostBrightnessTask(float brightness); 1029 WSError UpdateBrightness(int32_t persistentId); 1030 void SetDisplayBrightness(float brightness); 1031 float GetDisplayBrightness() const; 1032 void HandleHideNonSystemFloatingWindows(const sptr<WindowSessionProperty>& property, 1033 const sptr<SceneSession>& sceneSession); 1034 void UpdateForceHideState(const sptr<SceneSession>& sceneSession, const sptr<WindowSessionProperty>& property, 1035 bool add); 1036 void NotifyWindowInfoChange(int32_t persistentId, WindowUpdateType type); 1037 void NotifyWindowInfoChangeFromSession(int32_t persistentid); 1038 bool FillWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos, 1039 const sptr<SceneSession>& sceneSession); 1040 std::vector<std::pair<uint64_t, WindowVisibilityState>> GetWindowVisibilityChangeInfo( 1041 std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData); 1042 void GetWindowLayerChangeInfo(std::shared_ptr<RSOcclusionData> occlusionData, 1043 std::vector<std::pair<uint64_t, WindowVisibilityState>>& currVisibleData, 1044 std::vector<std::pair<uint64_t, bool>>& currDrawingContentData); 1045 void WindowLayerInfoChangeCallback(std::shared_ptr<RSOcclusionData> occlusiontionData); 1046 sptr<SceneSession> SelectSesssionFromMap(const uint64_t& surfaceId); 1047 void WindowDestroyNotifyVisibility(const sptr<SceneSession>& sceneSession); 1048 void RegisterSessionSnapshotFunc(const sptr<SceneSession>& sceneSession); 1049 1050 /* 1051 * Window Property 1052 */ 1053 std::unordered_map<std::string, std::unordered_set<int32_t>> releasedScreenLockMap_; 1054 std::vector<std::pair<uint64_t, bool>> GetWindowDrawingContentChangeInfo( 1055 const std::vector<std::pair<uint64_t, bool>>& currDrawingContentData); 1056 bool GetPreWindowDrawingState(uint64_t surfaceId, bool currentWindowDrawing, int32_t& pid); 1057 bool GetProcessDrawingState(uint64_t surfaceId, int32_t pid); 1058 void UpdateWindowDrawingData(uint64_t surfaceId, int32_t pid, int32_t uid); 1059 bool GetSpecifiedDrawingData(uint64_t surfaceId, int32_t& pid, int32_t& uid); 1060 void RemoveSpecifiedDrawingData(uint64_t surfaceId); 1061 WMError ReleaseScreenLockForApp(const std::string& bundleName); 1062 WMError RelockScreenLockForApp(const std::string& bundleName); 1063 void GetAllSessionsToReleaseScreenLock( 1064 std::vector<sptr<SceneSession>>& sessionsToReleaseScreenLock, const std::string& bundleName); 1065 bool FilterForListWindowInfo(const WindowInfoOption& windowInfoOption, 1066 const sptr<SceneSession>& sceneSession) const; 1067 void FilterForGetAllWindowLayoutInfo(DisplayId displayId, bool isVirtualDisplay, 1068 std::vector<sptr<SceneSession>>& filteredSessions); 1069 bool IsGetWindowLayoutInfoNeeded(const sptr<SceneSession>& session) const; 1070 int32_t GetFoldLowerScreenPosY() const; 1071 bool IsSessionInSpecificDisplay(const sptr<SceneSession>& session, DisplayId displayId) const; 1072 DisplayId UpdateSpecificSessionClientDisplayId(const sptr<WindowSessionProperty>& property); 1073 void SetSkipEventOnCastPlusInner(int32_t windowId, bool isSkip); 1074 void UpdateSessionDisplayIdBySessionInfo(sptr<SceneSession> sceneSession, const SessionInfo& sessionInfo); 1075 void CheckFloatWindowIsAnco(pid_t pid, const sptr<SceneSession>& newSession); 1076 bool IsNeedUpdateBrightness(int32_t persistentId, float brightness); 1077 void RegisterSessionPropertyChangeNotifyManagerFunc(const sptr<SceneSession>& sceneSession); 1078 void NotifySessionPropertyChangeFromSession(int32_t persistentId, WindowInfoKey windowInfoKey); 1079 1080 /* 1081 * Window Rotate Animation 1082 */ 1083 void RegisterAcquireRotateAnimationConfigFunc(const sptr<SceneSession>& sceneSession); 1084 1085 void RegisterVisibilityChangedDetectFunc(const sptr<SceneSession>& sceneSession); 1086 void NotifySessionForCallback(const sptr<SceneSession>& sceneSession, const bool needRemoveSession); 1087 void AddClientDeathRecipient(const sptr<ISessionStage>& sessionStage, const sptr<SceneSession>& sceneSession); 1088 void DestroySpecificSession(const sptr<IRemoteObject>& remoteObject); 1089 bool GetExtensionWindowIds(const sptr<IRemoteObject>& token, int32_t& persistentId, int32_t& parentId); 1090 void DestroyExtensionSession(const sptr<IRemoteObject>& remoteExtSession, bool isConstrainedModal = false); 1091 void EraseSceneSessionMapById(int32_t persistentId); 1092 void EraseSceneSessionAndMarkDirtyLocked(int32_t persistentId); 1093 WSError GetAbilityInfosFromBundleInfo(const std::vector<AppExecFwk::BundleInfo>& bundleInfos, 1094 std::vector<SCBAbilityInfo>& scbAbilityInfos, int32_t userId = 0); 1095 void GetOrientationFromResourceManager(AppExecFwk::AbilityInfo& abilityInfo); 1096 void UpdatePrivateStateAndNotifyForAllScreens(); 1097 1098 void ClosePipWindowIfExist(WindowType type); 1099 void NotifySessionAINavigationBarChange(int32_t persistentId); 1100 void ReportWindowProfileInfos(); 1101 void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing); 1102 void GetAllSceneSessionForAccessibility(std::vector<sptr<SceneSession>>& sceneSessionList); 1103 void FillAccessibilityInfo(std::vector<sptr<SceneSession>>& sceneSessionList, 1104 std::vector<sptr<AccessibilityWindowInfo>>& accessibilityInfo); 1105 void FilterSceneSessionCovered(std::vector<sptr<SceneSession>>& sceneSessionList); 1106 bool SubtractIntersectArea(std::shared_ptr<SkRegion>& unaccountedSpace, const sptr<SceneSession>& sceneSession); 1107 void NotifyAllAccessibilityInfo(); 1108 void RegisterSecSurfaceInfoListener(); 1109 void RegisterConstrainedModalUIExtInfoListener(); 1110 void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground); 1111 1112 /* 1113 * UIExtension 1114 */ 1115 void DestroyUIServiceExtensionSubWindow(const sptr<SceneSession>& sceneSession); 1116 WSError CheckSubSessionStartedByExtensionAndSetDisplayId(const sptr<IRemoteObject>& token, 1117 const sptr<WindowSessionProperty>& property, const sptr<ISessionStage>& sessionStage); 1118 void ReportSubWindowCreationFailure(const int32_t& pid, const std::string& abilityName, 1119 const std::string& parentBundleName, const std::string& hostBundleName); 1120 1121 /* 1122 * Multi User 1123 */ 1124 bool IsPcSceneSessionLifecycle(const sptr<SceneSession>& sceneSession); 1125 bool IsNeedChangeLifeCycleOnUserSwitch(const sptr<SceneSession>& sceneSession, int32_t pid); 1126 WSError StartOrMinimizeUIAbilityBySCB(const sptr<SceneSession>& sceneSession, bool isUserActive); 1127 void ProcessUIAbilityOnUserSwitch(bool isUserActive); 1128 void HandleUserSwitching(bool isUserActive); 1129 void HandleUserSwitched(bool isUserActive); 1130 1131 /* 1132 * Window Recover 1133 */ 1134 bool IsWindowSupportCacheForRecovering(const sptr<SceneSession>& sceneSession, 1135 const sptr<WindowSessionProperty>& property); 1136 void CacheSpecificSessionForRecovering(const sptr<SceneSession>& sceneSession, 1137 const sptr<WindowSessionProperty>& property); 1138 void RecoverCachedSubSession(int32_t persistentId); 1139 void RecoverCachedDialogSession(int32_t persistentId); 1140 void RemoveFailRecoveredSession(); 1141 void ClearUnrecoveredSessions(const std::vector<int32_t>& recoveredPersistentIds) REQUIRES(SCENE_GUARD); 1142 void RecoverSessionInfo(const sptr<WindowSessionProperty>& property); 1143 bool IsNeedRecover(const int32_t persistentId); 1144 WSError CheckSessionPropertyOnRecovery(const sptr<WindowSessionProperty>& property, bool isSpecificSession); 1145 void UpdateRecoverPropertyForSuperFold(const sptr<WindowSessionProperty>& property); 1146 void RegisterSessionRecoverStateChangeListener(); 1147 void RegisterRecoverStateChangeListener(); 1148 void OnSessionRecoverStateChange(const SessionRecoverState& state, 1149 const sptr<WindowSessionProperty>& property); 1150 void OnRecoverStateChange(const RecoverState& state); 1151 NotifySessionRecoverStateChangeFunc sessionRecoverStateChangeFunc_; 1152 NotifyRecoverStateChangeFunc recoverStateChangeFunc_; 1153 1154 /* 1155 * Gesture Back 1156 */ 1157 void UpdateGestureBackEnabled(int32_t persistentId); 1158 std::unordered_set<int32_t> gestureBackEnableWindowIdSet_; // ONLY Accessed on OS_sceneSession thread 1159 1160 /* 1161 * Window Input Event 1162 */ 1163 NotifyWatchGestureConsumeResultFunc onWatchGestureConsumeResultFunc_; 1164 NotifyWatchFocusActiveChangeFunc onWatchFocusActiveChangeFunc_; 1165 1166 sptr<RootSceneSession> rootSceneSession_; 1167 std::weak_ptr<AbilityRuntime::Context> rootSceneContextWeak_; 1168 mutable std::shared_mutex sceneSessionMapMutex_; 1169 std::map<int32_t, sptr<SceneSession>> sceneSessionMap_; 1170 std::map<int32_t, sptr<SceneSession>> systemTopSceneSessionMap_; 1171 std::map<int32_t, sptr<SceneSession>> nonSystemFloatSceneSessionMap_; 1172 sptr<ScbSessionHandler> scbSessionHandler_; 1173 std::shared_ptr<SessionListenerController> listenerController_; 1174 std::unordered_map<sptr<IRemoteObject>, int32_t, SptrHash<IRemoteObject>> remoteObjectMap_; 1175 1176 /* 1177 * UIExtension 1178 */ 1179 std::unordered_map<sptr<IRemoteObject>, sptr<IRemoteObject>, SptrHash<IRemoteObject>> remoteExtSessionMap_; 1180 std::unordered_map<sptr<IRemoteObject>, 1181 ExtensionWindowAbilityInfo, SptrHash<IRemoteObject>> extSessionInfoMap_; 1182 std::unordered_map<int32_t, ExtensionWindowFlags> extWindowFlagsMap_; 1183 ExtensionWindowFlags combinedExtWindowFlags_ { 0 }; 1184 std::atomic_bool shouldHideNonSecureFloatingWindows_ { false }; 1185 std::atomic_bool specialExtWindowHasPrivacyMode_ { false }; 1186 bool lastWaterMarkShowState_ { false }; 1187 sptr<AgentDeathRecipient> extensionDeath_ = new AgentDeathRecipient( 1188 [this](const sptr<IRemoteObject>& remoteExtSession) { this->DestroyExtensionSession(remoteExtSession); }); 1189 1190 std::set<int32_t> touchOutsideListenerSessionSet_; 1191 std::set<int32_t> windowVisibilityListenerSessionSet_; 1192 1193 NotifyCreateSystemSessionFunc createSystemSessionFunc_; 1194 NotifyCreateKeyboardSessionFunc createKeyboardSessionFunc_; 1195 ProcessStatusBarEnabledChangeFunc statusBarEnabledChangeFunc_; 1196 ProcessGestureNavigationEnabledChangeFunc gestureNavigationEnabledChangeFunc_; 1197 ProcessOutsideDownEventFunc outsideDownEventFunc_; 1198 ProcessShiftFocusFunc shiftFocusFunc_; 1199 NotifySCBAfterUpdateFocusFunc notifySCBAfterFocusedFunc_; 1200 NotifySCBAfterUpdateFocusFunc notifySCBAfterUnfocusedFunc_; 1201 NotifyDiffSCBAfterUpdateFocusFunc notifyDiffSCBAfterUnfocusedFunc_; 1202 ProcessCallingSessionIdChangeFunc callingSessionIdChangeFunc_; 1203 ProcessStartUIAbilityErrorFunc startUIAbilityErrorFunc_; 1204 DumpRootSceneElementInfoFunc dumpRootSceneFunc_; 1205 DumpUITreeFunc dumpUITreeFunc_; 1206 ProcessVirtualPixelRatioChangeFunc processVirtualPixelRatioChangeFunc_ = nullptr; 1207 ProcessCloseTargetFloatWindowFunc closeTargetFloatWindowFunc_; 1208 SetForegroundWindowNumFunc setForegroundWindowNumFunc_; 1209 MinimizeByWindowIdFunc minimizeByWindowIdFunc_; 1210 1211 AppWindowSceneConfig appWindowSceneConfig_; 1212 1213 /* 1214 * Window Recover 1215 */ 1216 bool recoveringFinished_ = false; 1217 NotifyRecoverSceneSessionFunc recoverSceneSessionFunc_; 1218 std::set<int32_t> failRecoveredPersistentIdSet_; 1219 1220 /* 1221 * Window Rotate Animation 1222 */ 1223 RotateAnimationConfig rotateAnimationConfig_; 1224 1225 /* 1226 * PiP Window 1227 */ 1228 NotifyStartPiPFailedFunc startPiPFailedFunc_; 1229 1230 SystemSessionConfig systemConfig_; 1231 float snapshotScale_ = 0.5; 1232 int32_t brightnessSessionId_ = INVALID_SESSION_ID; 1233 float displayBrightness_ = UNDEFINED_BRIGHTNESS; 1234 bool isScreenLocked_ { false }; 1235 bool isPrepareTerminateEnable_ { false }; 1236 1237 /* 1238 * Window Focus 1239 */ 1240 sptr<WindowFocusController> windowFocusController_; 1241 FocusChangeReason focusChangeReason_ = FocusChangeReason::DEFAULT; 1242 bool needBlockNotifyFocusStatusUntilForeground_ { false }; 1243 bool needBlockNotifyUnfocusStatus_ { false }; 1244 1245 /* 1246 * DFX 1247 */ 1248 bool openDebugTrace_ { false }; 1249 1250 std::atomic<bool> enableInputEvent_ = true; 1251 std::vector<int32_t> alivePersistentIds_ = {}; 1252 std::vector<VisibleWindowNumInfo> lastInfo_ = {}; 1253 std::shared_mutex lastInfoMutex_; 1254 1255 std::shared_ptr<AppExecFwk::EventHandler> mainHandler_; 1256 std::shared_ptr<TaskScheduler> taskScheduler_; 1257 sptr<AppExecFwk::IBundleMgr> bundleMgr_; 1258 sptr<AppAnrListener> appAnrListener_; 1259 sptr<AppExecFwk::LauncherService> launcherService_; 1260 std::shared_mutex startingWindowMapMutex_; 1261 const size_t MAX_CACHE_COUNT = 100; 1262 std::map<std::string, std::map<std::string, StartingWindowInfo>> startingWindowMap_; 1263 std::shared_mutex preLoadstartingWindowMapMutex_; 1264 std::unordered_map<std::string, std::shared_ptr<Media::PixelMap>> preLoadStartingWindowMap_; 1265 std::shared_mutex startingWindowColorFromAppMapMutex_; 1266 std::unordered_map<std::string, std::unordered_map<std::string, uint32_t>> startingWindowColorFromAppMap_; 1267 std::unordered_map<std::string, AppForceLandscapeConfig> appForceLandscapeMap_; 1268 std::shared_mutex appForceLandscapeMutex_; 1269 1270 std::mutex privacyBundleMapMutex_; 1271 std::unordered_map<DisplayId, std::unordered_set<std::string>> privacyBundleMap_; 1272 1273 WindowModeType lastWindowModeType_ { WindowModeType::WINDOW_MODE_OTHER }; 1274 1275 /* 1276 * Multi User 1277 */ 1278 static constexpr int32_t DEFAULT_USERID = -1; 1279 std::atomic<int32_t> currentUserId_ { DEFAULT_USERID }; 1280 bool isUserBackground_ = false; // Only accessed on SSM thread 1281 1282 // displayRegionMap_ stores the screen display area for AccessibilityNotification, 1283 // the read and write operations must be performed in the same thread, current is in task thread. 1284 std::unordered_map<DisplayId, std::shared_ptr<SkRegion>> displayRegionMap_; 1285 std::shared_ptr<SkRegion> GetDisplayRegion(DisplayId displayId); 1286 void UpdateDisplayRegion(const sptr<DisplayInfo>& displayInfo); 1287 1288 std::shared_ptr<AppExecFwk::EventRunner> eventLoop_; 1289 std::shared_ptr<AppExecFwk::EventHandler> eventHandler_; 1290 bool isReportTaskStart_ = false; 1291 std::vector<std::pair<uint64_t, WindowVisibilityState> > lastVisibleData_; 1292 RSInterfaces& rsInterface_; 1293 void RegisterSessionStateChangeNotifyManagerFunc(sptr<SceneSession>& sceneSession); 1294 void RegisterSessionInfoChangeNotifyManagerFunc(sptr<SceneSession>& sceneSession); 1295 void RegisterDisplayIdChangedNotifyManagerFunc(const sptr<SceneSession>& sceneSession); 1296 void OnSessionStateChange(int32_t persistentId, const SessionState& state) REQUIRES(SCENE_GUARD); 1297 void ProcessFocusWhenForeground(sptr<SceneSession>& sceneSession); 1298 void ProcessFocusWhenForegroundScbCore(sptr<SceneSession>& sceneSession); 1299 void ProcessSubSessionForeground(sptr<SceneSession>& sceneSession); 1300 void ProcessSubSessionBackground(sptr<SceneSession>& sceneSession); 1301 sptr<SceneSession> FindSessionByToken(const sptr<IRemoteObject>& token, 1302 WindowType type = WindowType::APP_MAIN_WINDOW_BASE); 1303 1304 void CheckAndNotifyWaterMarkChangedResult(); 1305 WSError NotifyWaterMarkFlagChangedResult(bool hasWaterMark); 1306 void ProcessPreload(const AppExecFwk::AbilityInfo& abilityInfo) const; 1307 WindowChangedFunc WindowChangedFunc_; 1308 sptr<AgentDeathRecipient> windowDeath_ = new AgentDeathRecipient( 1309 [this](const sptr<IRemoteObject>& remoteObject) { this->DestroySpecificSession(remoteObject); }); 1310 1311 int GetRemoteSessionSnapshotInfo(const std::string& deviceId, int32_t sessionId, 1312 AAFwk::MissionSnapshot& sessionSnapshot); 1313 1314 /* 1315 * Collaborator 1316 */ 1317 AbilityManagerCollaboratorRegisteredFunc abilityManagerCollaboratorRegisteredFunc_; 1318 const int32_t BROKER_UID = 5557; 1319 const int32_t BROKER_RESERVE_UID = 5005; 1320 std::shared_mutex collaboratorMapLock_; 1321 std::unordered_map<int32_t, sptr<AAFwk::IAbilityManagerCollaborator>> collaboratorMap_; 1322 std::atomic<int64_t> containerStartAbilityTime_ { 0 }; 1323 sptr<AgentDeathRecipient> collaboratorDeathRecipient_; 1324 BrokerStates NotifyStartAbility( 1325 int32_t collaboratorType, const SessionInfo& sessionInfo, int32_t persistentId = 0); 1326 void NotifySessionCreate(const sptr<SceneSession> sceneSession, const SessionInfo& sessionInfo); 1327 void NotifyLoadAbility(int32_t collaboratorType, sptr<AAFwk::SessionInfo> abilitySessionInfo, 1328 std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo); 1329 void NotifyUpdateSessionInfo(const sptr<SceneSession> sceneSession); 1330 void NotifyClearSession(int32_t collaboratorType, int32_t persistentId); 1331 void NotifyMoveSessionToForeground(int32_t collaboratorType, int32_t persistentId); 1332 bool PreHandleCollaboratorStartAbility(sptr<SceneSession>& sceneSession, int32_t persistentId = 0); 1333 bool PreHandleCollaborator(sptr<SceneSession>& sceneSession, int32_t persistentId = 0); 1334 void NotifyCollaboratorAfterStart(sptr<SceneSession>& sceneSession, sptr<AAFwk::SessionInfo>& sceneSessionInfo); 1335 void UpdateCollaboratorSessionWant(sptr<SceneSession>& session, int32_t persistentId = 0); 1336 sptr<AAFwk::IAbilityManagerCollaborator> GetCollaboratorByType(int32_t collaboratorType); 1337 void GetCollaboratorAbilityInfos(const std::vector<AppExecFwk::BundleInfo>& bundleInfos, 1338 std::vector<SCBAbilityInfo>& scbAbilityInfos, int32_t userId); 1339 1340 std::vector<uint64_t> skipSurfaceNodeIds_; 1341 std::atomic_bool processingFlushUIParams_ { false }; 1342 1343 /* 1344 * PiP Window 1345 */ 1346 std::mutex pipSettingSwitchMutex_; 1347 uint64_t pipWindowSurfaceId_ = 0; 1348 bool pipSwitchStatus_ = true; 1349 bool CheckPiPPriority(const PiPTemplateInfo& pipTemplateInfo, DisplayId displayId = 0); 1350 bool IsEnablePiPCreate(const sptr<WindowSessionProperty>& property); 1351 bool IsPiPForbidden(const sptr<WindowSessionProperty>& property, const WindowType& type); 1352 bool IsLastPiPWindowVisible(uint64_t surfaceId, WindowVisibilityState lastVisibilityState); 1353 void NotifyPiPWindowVisibleChange(bool isScreenLocked); 1354 1355 /* 1356 * Floating ball 1357 */ 1358 WSError IsFloatingBallValid(const sptr<SceneSession>& parentSession); 1359 1360 void DestroySubSession(const sptr<SceneSession>& sceneSession); 1361 void DestroyToastSession(const sptr<SceneSession>& sceneSession); 1362 void NotifyCreateSubSession(int32_t persistentId, sptr<SceneSession> session, uint32_t windowFlags = 0); 1363 void NotifyCreateToastSession(int32_t persistentId, sptr<SceneSession> session); 1364 void NotifySessionUnfocusedToClient(int32_t persistentId); 1365 void NotifyCreateSpecificSession(sptr<SceneSession> session, 1366 sptr<WindowSessionProperty> property, const WindowType& type); 1367 sptr<SceneSession> CreateSceneSession(const SessionInfo& sessionInfo, sptr<WindowSessionProperty> property); 1368 1369 /* 1370 * Keyboard 1371 */ 1372 void CreateKeyboardPanelSession(sptr<SceneSession> keyboardSession); 1373 sptr<SceneSession> RequestKeyboardPanelSession(const std::string& panelName, uint64_t displayId); 1374 sptr<SceneSession> GetKeyboardSession(DisplayId displayId, bool isSystemKeyboard); 1375 void HandleKeyboardAvoidChange(const sptr<SceneSession>& sceneSession, DisplayId displayId, 1376 SystemKeyboardAvoidChangeReason reason); 1377 void UpdateKeyboardAvoidAreaActive(bool systemKeyboardAvoidAreaActive); 1378 1379 /* 1380 * Specific Window 1381 */ 1382 void ClearSpecificSessionRemoteObjectMap(int32_t persistentId); 1383 WSError DestroyAndDisconnectSpecificSessionInner(const int32_t persistentId); 1384 1385 WSError GetAppMainSceneSession(int32_t persistentId, sptr<SceneSession>& sceneSession); 1386 void CalculateCombinedExtWindowFlags(); 1387 void UpdateSpecialExtWindowFlags(int32_t persistentId, ExtensionWindowFlags flags, ExtensionWindowFlags actions); 1388 void HideNonSecureFloatingWindows(); 1389 void HideNonSecureSubWindows(const sptr<SceneSession>& sceneSession); 1390 WSError HandleSecureSessionShouldHide(const sptr<SceneSession>& sceneSession); 1391 bool CheckSystemWindowPermission(const sptr<WindowSessionProperty>& property); 1392 bool CheckModalSubWindowPermission(const sptr<WindowSessionProperty>& property); 1393 1394 /* 1395 * Window Snapshot 1396 */ 1397 void SetSessionSnapshotSkipForAppProcess(const sptr<SceneSession>& sceneSession) REQUIRES(SCENE_GUARD); 1398 void RemoveProcessSnapshotSkip(int32_t pid) REQUIRES(SCENE_GUARD); 1399 void SetSessionSnapshotSkipForAppBundleName(const sptr<SceneSession>& sceneSession) REQUIRES(SCENE_GUARD); 1400 1401 void HandleSpecialExtWindowFlagsChange(int32_t persistentId, ExtensionWindowFlags extWindowFlags, 1402 ExtensionWindowFlags extWindowActions); 1403 void ProcessWindowModeType(); 1404 WindowModeType CheckWindowModeType(); 1405 void NotifyRSSWindowModeTypeUpdate(); 1406 void CacVisibleWindowNum(); 1407 bool IsVectorSame(const std::vector<VisibleWindowNumInfo>& lastInfo, 1408 const std::vector<VisibleWindowNumInfo>& currentInfo); 1409 bool IsKeyboardForeground(); 1410 WindowStatus GetWindowStatus(WindowMode mode, SessionState sessionState, 1411 const sptr<WindowSessionProperty>& property); 1412 void DeleteStateDetectTask(); 1413 bool JudgeNeedNotifyPrivacyInfo(DisplayId displayId, const std::unordered_set<std::string>& privacyBundles); 1414 1415 /* 1416 * Window Visibility 1417 */ 1418 bool NotifyVisibleChange(int32_t persistentId); 1419 1420 /* 1421 * Fold Screen Status Change Report 1422 */ 1423 WMError MakeScreenFoldData(const std::vector<std::string>& screenFoldInfo, ScreenFoldData& screenFoldData); 1424 WMError CheckAndReportScreenFoldStatus(ScreenFoldData& data); 1425 WMError ReportScreenFoldStatus(const ScreenFoldData& data); 1426 void RecoveryVisibilityPidCount(int32_t pid) REQUIRES(SCENE_GUARD); 1427 1428 /* 1429 * Window Watermark 1430 */ 1431 bool SetSessionWatermarkForAppProcess(const sptr<SceneSession>& sceneSession); 1432 void RemoveProcessWatermarkPid(int32_t pid); 1433 1434 /* 1435 * Window Layout 1436 */ 1437 std::shared_ptr<VsyncCallback> vsyncCallback_ = nullptr; 1438 std::shared_ptr<VsyncStation> vsyncStation_ = nullptr; 1439 SingleHandTransform singleHandTransform_; 1440 WSRect originRect_; 1441 WSRect singleHandRect_; 1442 SingleHandScreenInfo singleHandScreenInfo_; 1443 GetRSNodeByStringIDFunc getRSNodeByStringIDFunc_; 1444 SetTopWindowBoundaryByIDFunc setTopWindowBoundaryByIDFunc_; 1445 SingleHandCompatibleModeConfig singleHandCompatibleModeConfig_; 1446 std::unordered_set<std::string> appsWithDeduplicatedWindowStatus_; 1447 std::shared_mutex appHookWindowInfoMapMutex_; 1448 std::unordered_map<std::string, HookWindowInfo> appHookWindowInfoMap_; 1449 void InitVsyncStation(); 1450 void RegisterRequestVsyncFunc(const sptr<SceneSession>& sceneSession); 1451 bool GetDisplaySizeById(DisplayId displayId, int32_t& displayWidth, int32_t& displayHeight); 1452 void UpdateSessionWithFoldStateChange(DisplayId displayId, SuperFoldStatus status, SuperFoldStatus prevStatus); 1453 void ConfigSingleHandCompatibleMode(const WindowSceneConfig::ConfigItem& configItem); 1454 void ConfigAppsWithDeduplicatedWindowStatus(); 1455 void SetWindowStatusDeduplicationBySystemConfig(const SessionInfo& sessionInfo, SystemSessionConfig& systemConfig); 1456 HasRootSceneRequestedVsyncFunc hasRootSceneRequestedVsyncFunc_; 1457 RequestVsyncByRootSceneWhenModeChangeFunc requestVsyncByRootSceneWhenModeChangeFunc_; 1458 WSError HasRootSceneRequestedVsync(bool& hasRootSceneRequestedVsync); 1459 WSError RequestVsyncByRootSceneWhenModeChange(const std::shared_ptr<VsyncCallback>& vsyncCallback); 1460 1461 /* 1462 * Window Snapshot 1463 */ 1464 std::unordered_set<int32_t> snapshotSkipPidSet_ GUARDED_BY(SCENE_GUARD); // ONLY Accessed on OS_sceneSession thread 1465 std::unordered_set<std::string> snapshotSkipBundleNameSet_ GUARDED_BY(SCENE_GUARD); 1466 1467 uint32_t sessionMapDirty_ { 0 }; 1468 std::condition_variable nextFlushCompletedCV_; 1469 std::mutex nextFlushCompletedMutex_; 1470 RootSceneProcessBackEventFunc rootSceneProcessBackEventFunc_ = nullptr; 1471 1472 /* 1473 * Window Watermark 1474 */ 1475 std::unordered_map<int32_t, std::string> processWatermarkPidMap_; // ONLY Accessed on OS_sceneSession thread 1476 1477 /* 1478 * Dump 1479 */ 1480 std::shared_ptr<ScbDumpSubscriber> scbDumpSubscriber_; 1481 RunnableFuture<std::vector<std::string>> dumpInfoFuture_; 1482 void DumpSessionInfo(const sptr<SceneSession>& session, std::ostringstream& oss); 1483 void DumpFocusInfo(std::ostringstream& oss); 1484 void DumpSessionElementInfo(const sptr<SceneSession>& session, 1485 const std::vector<std::string>& params, std::string& dumpInfo); 1486 void DumpAllSessionFocusableInfo(int32_t persistentId); 1487 1488 /* 1489 * Screen Manager 1490 */ 1491 bool IsInDefaultScreen(const sptr<SceneSession>& sceneSession); 1492 1493 /* 1494 * Window Mode Type 1495 */ 1496 bool IsNeedSkipWindowModeTypeCheck(const sptr<SceneSession>& sceneSession, bool isSmallFold); 1497 1498 /* 1499 * Window Immersive 1500 */ 1501 NotifyRootSceneAvoidAreaChangeFunc onNotifyAvoidAreaChangeForRootFunc_; 1502 OnFlushUIParamsFunc onFlushUIParamsFunc_; 1503 IsRootSceneLastFrameLayoutFinishedFunc isRootSceneLastFrameLayoutFinishedFunc_; 1504 bool isAINavigationBarVisible_ = false; 1505 std::shared_mutex currAINavigationBarAreaMapMutex_; 1506 std::map<uint64_t, WSRect> currAINavigationBarAreaMap_; 1507 std::mutex nextAvoidRectInfoMapMutex_; 1508 std::unordered_map<AvoidAreaType, std::unordered_map<DisplayId, std::pair<WSRect, WSRect>>> nextAvoidRectInfoMap_; 1509 std::unordered_map<DisplayId, bool> statusBarDefaultVisibilityPerDisplay_; 1510 std::set<int32_t> avoidAreaListenerSessionSet_; 1511 static constexpr int32_t INVALID_STATUS_BAR_AVOID_HEIGHT = -1; 1512 std::unordered_map<DisplayId, int32_t> statusBarAvoidHeight_; 1513 std::unordered_map<DisplayId, bool> statusBarConstantlyShowMap_; 1514 std::mutex lastSystemBarPropertyMapMutex_; 1515 std::unordered_map<WindowType, SystemBarProperty> lastSystemBarPropertyMap_; 1516 1517 struct SessionInfoList { 1518 int32_t uid_; 1519 std::string bundleName_; 1520 std::string abilityName_; 1521 std::string moduleName_; 1522 bool operator==(const SessionInfoList& list) const 1523 { 1524 return this->uid_ == list.uid_ && this->bundleName_ == list.bundleName_ && 1525 this->abilityName_ == list.abilityName_ && this->moduleName_ == list.moduleName_; 1526 } 1527 friend struct SessionHasher; 1528 }; 1529 struct SessionHasher { operatorSessionHasher1530 size_t operator()(const SessionInfoList& sessionInfo) const 1531 { 1532 return std::hash<int32_t>()(sessionInfo.uid_) + std::hash<std::string>()(sessionInfo.bundleName_) + 1533 std::hash<std::string>()(sessionInfo.abilityName_) + std::hash<std::string>()(sessionInfo.moduleName_); 1534 } 1535 }; 1536 std::unordered_map<SessionInfoList, std::shared_ptr<AppExecFwk::AbilityInfo>, SessionHasher> abilityInfoMap_; 1537 1538 /* 1539 * Window Property 1540 */ 1541 void UpdateDarkColorModeToRS(); 1542 struct DrawingSessionInfo { 1543 int32_t pid_ = 0; 1544 int32_t uid_ = 0; 1545 }; 1546 uint32_t observedFlags_ = 0; 1547 uint32_t interestedFlags_ = 0; 1548 std::unordered_map<uint64_t, DrawingSessionInfo> lastDrawingSessionInfoMap_; 1549 std::unordered_set<int32_t> screenshotAppEventListenerSessionSet_; 1550 void NotifyWindowPropertyChangeByWindowInfoKey( 1551 const sptr<SceneSession>& sceneSession, WindowInfoKey windowInfoKey); 1552 void NotifyWindowPropertyChange(ScreenId screenId); 1553 WMError RegisterWindowPropertyChangeAgent(WindowInfoKey windowInfoKey, 1554 uint32_t interestInfo, const sptr<IWindowManagerAgent>& windowManagerAgent) override; 1555 WMError UnregisterWindowPropertyChangeAgent(WindowInfoKey windowInfoKey, 1556 uint32_t interestInfo, const sptr<IWindowManagerAgent>& windowManagerAgent) override; 1557 WMError RecoverWindowPropertyChangeFlag(uint32_t observedFlags, uint32_t interestedFlags) override; 1558 void PackWindowPropertyChangeInfo(const sptr<SceneSession>& sceneSession, 1559 std::unordered_map<WindowInfoKey, WindowChangeInfoType>& windowPropertyChangeInfo); 1560 WMError AddSessionBlackList(const std::vector<sptr<SceneSession>>& sceneSessionList, 1561 const std::unordered_set<std::string>& privacyWindowTags); 1562 WMError RemoveSessionBlackList(const std::vector<sptr<SceneSession>>& sceneSessionList, 1563 const std::unordered_set<std::string>& privacyWindowTags); 1564 void AddskipSurfaceNodeIdSet(int32_t windowId, std::unordered_set<uint64_t>& skipSurfaceNodeIdSet); 1565 WMError FlushSessionBlackListInfoMapWhenAdd(); 1566 WMError FlushSessionBlackListInfoMapWhenAdd(ScreenId screenId); 1567 WMError FlushSessionBlackListInfoMapWhenRemove(); 1568 WMError FlushSessionBlackListInfoMapWhenRemove(ScreenId screenId); 1569 void UpdateVirtualScreenBlackList(ScreenId screenId); 1570 void AddSkipSurfaceNodeWhenAttach(int32_t windowId, const std::string& bundleName, uint64_t surfaceNodeId); 1571 std::unordered_map<std::string, std::unordered_set<std::string>> bundleRSBlackListConfigMap_; 1572 inline static const std::string WMS_DEFAULT = "WMS_DEFAULT"; 1573 1574 struct SessionBlackListInfo { 1575 int32_t windowId = INVALID_SESSION_ID; 1576 std::string privacyWindowTag = WMS_DEFAULT; 1577 }; 1578 struct SessionBlackListEqual { operatorSessionBlackListEqual1579 bool operator()(const SessionBlackListInfo& left, const SessionBlackListInfo& right) const 1580 { 1581 return left.windowId == right.windowId && left.privacyWindowTag == right.privacyWindowTag; 1582 } 1583 }; 1584 struct SessionBlackListHasher { operatorSessionBlackListHasher1585 size_t operator()(const SessionBlackListInfo& info) const 1586 { 1587 return std::hash<int32_t>()(info.windowId) + std::hash<std::string>()(info.privacyWindowTag); 1588 } 1589 }; 1590 using SessionBlackListInfoSet = 1591 std::unordered_set<SessionBlackListInfo, SessionBlackListHasher, SessionBlackListEqual>; 1592 SessionBlackListInfoSet sessionRSBlackListConfigSet_; 1593 std::unordered_map<DisplayId, SessionBlackListInfoSet> sessionBlackListInfoMap_; 1594 1595 void RemoveSessionFromBlackListInfoSet( 1596 const sptr<SceneSession>& sceneSession, SessionBlackListInfoSet& sessionBlackListInfoSet); 1597 1598 struct ScreenBlackListInfo { 1599 std::string privacyWindowTag = ""; 1600 }; 1601 struct ScreenBlackListEqual { operatorScreenBlackListEqual1602 bool operator()(const ScreenBlackListInfo& left, const ScreenBlackListInfo& right) const 1603 { 1604 return left.privacyWindowTag == right.privacyWindowTag; 1605 } 1606 }; 1607 struct ScreenBlackListHasher { operatorScreenBlackListHasher1608 size_t operator()(const ScreenBlackListInfo& info) const 1609 { 1610 return std::hash<std::string>()(info.privacyWindowTag); 1611 } 1612 }; 1613 using ScreenBlackListInfoSet = 1614 std::unordered_set<ScreenBlackListInfo, ScreenBlackListHasher, ScreenBlackListEqual>; 1615 std::unordered_map<ScreenId, ScreenBlackListInfoSet> screenRSBlackListConfigMap_; 1616 1617 /* 1618 * Move Drag 1619 */ 1620 std::mutex dragResizeTypeMutex_; 1621 DragResizeType globalDragResizeType_ = DragResizeType::RESIZE_TYPE_UNDEFINED; 1622 std::unordered_map<std::string, DragResizeType> appDragResizeTypeMap_; 1623 void GetEffectiveDragResizeType(DragResizeType& dragResizeType); 1624 WMError GetAppDragResizeTypeInner(const std::string& bundleName, DragResizeType& dragResizeType); 1625 std::mutex keyFrameMutex_; 1626 std::unordered_map<std::string, KeyFramePolicy> appKeyFramePolicyMap_; 1627 1628 /* 1629 * Specific Window 1630 */ 1631 std::unordered_map<int32_t, NotifyCreateSubSessionFunc> createSubSessionFuncMap_; 1632 std::unordered_map<int32_t, std::vector<sptr<SceneSession>>> recoverSubSessionCacheMap_; 1633 std::unordered_map<int32_t, NotifyBindDialogSessionFunc> bindDialogTargetFuncMap_; 1634 std::unordered_map<int32_t, std::vector<sptr<SceneSession>>> recoverDialogSessionCacheMap_; 1635 1636 /* 1637 * PC Window 1638 */ 1639 //Whether to save window rect 1640 std::unordered_map<std::string, bool> isWindowRectAutoSaveMap_; 1641 //Whether to save rect according to specifiedFlag 1642 std::unordered_map<std::string, bool> isSaveBySpecifiedFlagMap_; 1643 std::shared_ptr<FoldScreenStatusChangeCallback> foldChangeCallback_; 1644 1645 /* 1646 * Window Lifecycle 1647 */ 1648 NotifyAppUseControlListFunc notifyAppUseControlListFunc_; 1649 std::unordered_map<int32_t, int32_t> visibleWindowCountMap_ GUARDED_BY(SCENE_GUARD); 1650 std::unordered_set<std::string> sessionLockedStateCacheSet_; 1651 std::shared_ptr<FfrtQueueHelper> ffrtQueueHelper_ = nullptr; 1652 std::vector<RecentSessionInfo> recentMainSessionInfoList_; 1653 UpdateKioskAppListFunc updateKioskAppListFunc_; 1654 KioskModeChangeFunc kioskModeChangeFunc_; 1655 std::vector<std::string> kioskAppListCache_; 1656 bool isKioskMode_ = false; 1657 int32_t kioskAppPersistentId_ = INVALID_SESSION_ID; 1658 1659 /* 1660 * Window Pattern 1661 */ 1662 std::unordered_set<std::string> emptyStartupResource_; 1663 std::atomic<bool> delayRemoveSnapshot_ = false; 1664 void InitStartingWindowRdb(const std::string& rdbPath); 1665 bool GetStartingWindowInfoFromCache(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo); 1666 uint32_t UpdateCachedColorToAppSet(const std::string& bundleName, const std::string& moduleName, 1667 const std::string& abilityName, StartingWindowInfo& startingWindowInfo); 1668 bool GetStartingWindowInfoFromRdb(const SessionInfo& sessionInfo, StartingWindowInfo& startingWindowInfo); 1669 bool GetPathInfoFromResource(const std::shared_ptr<Global::Resource::ResourceManager> resourceMgr, 1670 bool hapPathEmpty, uint32_t resourceId, std::string& path); 1671 bool GetStartupPageFromResource(const AppExecFwk::AbilityInfo& abilityInfo, StartingWindowInfo& startingWindowInfo); 1672 void GetBundleStartingWindowInfos(bool isDark, const AppExecFwk::BundleInfo& bundleInfo, 1673 std::vector<std::pair<StartingWindowRdbItemKey, StartingWindowInfo>>& outValues); 1674 void CacheStartingWindowInfo(const std::string& bundleName, const std::string& moduleName, 1675 const std::string& abilityName, const StartingWindowInfo& startingWindowInfo); 1676 void PreLoadStartingWindow(sptr<SceneSession> sceneSession); 1677 bool CheckAndGetPreLoadResourceId(const StartingWindowInfo& startingWindowInfo, uint32_t& resId); 1678 std::unique_ptr<StartingWindowRdbManager> startingWindowRdbMgr_; 1679 std::unique_ptr<LruCache> snapshotLruCache_; 1680 std::size_t snapshotCapacity_ = 0; 1681 bool GetIconFromDesk(const SessionInfo& sessionInfo, std::string& startupPagePath) const; 1682 bool GetIsDarkFromConfiguration(); 1683 bool needCloseSync_ = false; 1684 std::function<void()> closeSyncFunc_ = nullptr; 1685 WMError SetImageForRecent(uint32_t imgResourceId, ImageFit imageFit, int32_t persistentId) override; 1686 void UpdateAllStartingWindowRdb(); 1687 bool needUpdateRdb_ = true; 1688 }; 1689 } // namespace OHOS::Rosen 1690 1691 #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_MANAGER_H 1692