1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ROSEN_WINDOW_SCENE_SESSION_INTERFACE_H 17 #define OHOS_ROSEN_WINDOW_SCENE_SESSION_INTERFACE_H 18 19 #include <iremote_broker.h> 20 #include <session_info.h> 21 22 #include "interfaces/include/ws_common.h" 23 #include "common/include/window_session_property.h" 24 #include "session/container/include/zidl/session_stage_interface.h" 25 #include "session/container/include/zidl/window_event_channel_interface.h" 26 27 namespace OHOS::Accessibility { 28 class AccessibilityEventInfo; 29 } 30 namespace OHOS::Rosen { 31 class RSSurfaceNode; 32 class ISession : public IRemoteBroker { 33 public: 34 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISession"); 35 36 virtual WSError Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel, 37 const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig, 38 sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr, 39 const std::string& identityToken = "") { return WSError::WS_OK; } 40 virtual WSError Foreground( 41 sptr<WindowSessionProperty> property, bool isFromClient = false, const std::string& identityToken = "") = 0; 42 virtual WSError Background(bool isFromClient = false, const std::string& identityToken = "") = 0; 43 virtual WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") = 0; 44 virtual WSError Show(sptr<WindowSessionProperty> property) = 0; 45 virtual WSError Hide() = 0; 46 virtual WSError DrawingCompleted() = 0; 47 virtual WSError RemoveStartingWindow() = 0; 48 49 // scene session 50 /** 51 * @brief Receive session event from application. 52 * 53 * This function provides the ability for applications to move window. 54 * This interface will take effect after touch down event. 55 * 56 * @param event Indicates the {@link SessionEvent} 57 * @return Returns WSError::WS_OK if called success, otherwise failed. 58 */ OnSessionEvent(SessionEvent event)59 virtual WSError OnSessionEvent(SessionEvent event) { return WSError::WS_OK; } 60 61 /** 62 * @brief Receive session event from application. 63 * 64 * This function provides the ability for applications to move window.\n 65 * This interface will take effect after touch down event.\n 66 * 67 * @return Returns WSError::WS_OK if called success, otherwise failed. 68 */ SyncSessionEvent(SessionEvent event)69 virtual WSError SyncSessionEvent(SessionEvent event) { return WSError::WS_OK; } 70 71 /** 72 * @brief Enables or disables system window dragging. 73 * 74 * This function provides the ability for system application to make system window dragable. 75 * 76 * @return Returns WSError::WS_OK if called success, otherwise failed. 77 * @permission Make sure the caller has system permission. 78 */ SetSystemWindowEnableDrag(bool enableDrag)79 virtual WMError SetSystemWindowEnableDrag(bool enableDrag) { return WMError::WM_OK; } 80 81 /** 82 * @brief Callback for processing full-screen layout changes. 83 * 84 * @param isLayoutFullScreen Indicates the {@link bool} 85 * @return Returns WSError::WS_OK if called success, otherwise failed. 86 */ OnLayoutFullScreenChange(bool isLayoutFullScreen)87 virtual WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) { return WSError::WS_OK; } 88 89 /** 90 * @brief Callback for processing set default density enabled. 91 * 92 * @param isDefaultDensityEnabled Indicates the {@link bool} 93 * @return Returns WSError::WS_OK if called success, otherwise failed. 94 */ OnDefaultDensityEnabled(bool isDefaultDensityEnabled)95 virtual WSError OnDefaultDensityEnabled(bool isDefaultDensityEnabled) { return WSError::WS_OK; } 96 97 /** 98 * @brief Callback for processing title and dock hover show changes. 99 * 100 * @param isTitleHoverShown Indicates the {@link bool} 101 * @param isDockHoverShown Indicates the {@link bool} 102 * @return Returns WSError::WS_OK if called success, otherwise failed. 103 */ 104 virtual WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, 105 bool isDockHoverShown = true) { return WSError::WS_OK; } 106 107 /** 108 * @brief Callback for processing restore main window. 109 * 110 * @return Returns WSError::WS_OK if called success, otherwise failed. 111 */ OnRestoreMainWindow()112 virtual WSError OnRestoreMainWindow() { return WSError::WS_OK; } 113 114 /** 115 * @brief Raise the application subwindow to the top layer of the application. 116 * 117 * @return Returns WSError::WS_OK if called success, otherwise failed. 118 * @permission Make sure the caller has system permission. 119 */ RaiseToAppTop()120 virtual WSError RaiseToAppTop() { return WSError::WS_OK; } 121 122 /** 123 * @brief Update window size and position. 124 * 125 * @param rect Indicates the {@link WSRect} structure containing required size and position. 126 * @param reason Indicates the {@link SizeChangeReason} reason. 127 * @param isGlobal Indicates the {@link bool}. 128 * @return Returns WSError::WS_OK if called success, otherwise failed. 129 */ 130 virtual WSError UpdateSessionRect( 131 const WSRect& rect, SizeChangeReason reason, bool isGlobal = false, 132 bool isFromMoveToGlobal = false, const MoveConfiguration& moveConfiguration = {}, 133 const RectAnimationConfig& rectAnimationConfig = {}) { return WSError::WS_OK; } UpdateClientRect(const WSRect & rect)134 virtual WSError UpdateClientRect(const WSRect& rect) { return WSError::WS_OK; } GetGlobalScaledRect(Rect & globalScaledRect)135 virtual WMError GetGlobalScaledRect(Rect& globalScaledRect) { return WMError::WM_OK; } OnNeedAvoid(bool status)136 virtual WSError OnNeedAvoid(bool status) { return WSError::WS_OK; } 137 virtual AvoidArea GetAvoidAreaByType(AvoidAreaType type, const WSRect& rect = WSRect::EMPTY_RECT, 138 int32_t apiVersion = API_VERSION_INVALID) { return {}; } GetAllAvoidAreas(std::map<AvoidAreaType,AvoidArea> & avoidAreas)139 virtual WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) { return WSError::WS_OK; } RequestSessionBack(bool needMoveToBackground)140 virtual WSError RequestSessionBack(bool needMoveToBackground) { return WSError::WS_OK; } MarkProcessed(int32_t eventId)141 virtual WSError MarkProcessed(int32_t eventId) { return WSError::WS_OK; } 142 143 /** 144 * @brief Sets the global maximization mode of window. 145 * 146 * @param mode Indicates the {@link MaximizeMode}. 147 * @return Returns WSError::WS_OK if called success, otherwise failed. 148 */ SetGlobalMaximizeMode(MaximizeMode mode)149 virtual WSError SetGlobalMaximizeMode(MaximizeMode mode) { return WSError::WS_OK; } 150 151 /** 152 * @brief this interface is invoked by the ACE to the native host. 153 * @param eventName invoking event name, which is used to distinguish different invoking types. 154 * @param eventValue used to transfer parameters. 155 * @return WM_OK means get success, others means get failed. 156 */ OnContainerModalEvent(const std::string & eventName,const std::string & eventValue)157 virtual WSError OnContainerModalEvent(const std::string& eventName, 158 const std::string& eventValue) { return WSError::WS_OK; } 159 160 /** 161 * @brief Obtains the global maximization mode of window. 162 * 163 * @param mode Indicates the {@link MaximizeMode}. 164 * @return Returns WSError::WS_OK if called success, otherwise failed. 165 */ GetGlobalMaximizeMode(MaximizeMode & mode)166 virtual WSError GetGlobalMaximizeMode(MaximizeMode& mode) { return WSError::WS_OK; } 167 168 /** 169 * @brief Sets the aspect ratio of window. 170 * 171 * @param ratio Indicates the {@link float} 172 * @return Returns WSError::WS_OK if called success, otherwise failed. 173 */ SetAspectRatio(float ratio)174 virtual WSError SetAspectRatio(float ratio) { return WSError::WS_OK; } UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)175 virtual WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) { return WSError::WS_OK; } UpdateWindowSceneAfterCustomAnimation(bool isAdd)176 virtual WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) { return WSError::WS_OK; } 177 178 /** 179 * @brief Raise a subwindow above a target subwindow. 180 * 181 * @param subWindowId Indicates the {@link int32_t} id of the target subwindow. 182 * @return Returns WSError::WS_OK if called success, otherwise failed. 183 * @permission Make sure the caller has system permission. 184 */ RaiseAboveTarget(int32_t subWindowId)185 virtual WSError RaiseAboveTarget(int32_t subWindowId) { return WSError::WS_OK; } 186 187 /** 188 * @brief Raise the application main window to the top layer of the application. 189 * 190 * @return Returns WSError::WS_OK if called success, otherwise failed. 191 */ RaiseAppMainWindowToTop()192 virtual WSError RaiseAppMainWindowToTop() { return WSError::WS_OK; } PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo)193 virtual WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo) 194 { return WSError::WS_OK; } TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)195 virtual WSError TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo) { return WSError::WS_OK; } SetLandscapeMultiWindow(bool isLandscapeMultiWindow)196 virtual WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WSError::WS_OK; } GetIsMidScene(bool & isMidScene)197 virtual WSError GetIsMidScene(bool& isMidScene) { return WSError::WS_OK; } NotifySessionException(const sptr<AAFwk::SessionInfo> abilitySessionInfo,const ExceptionInfo & exceptionInfo)198 virtual WSError NotifySessionException( 199 const sptr<AAFwk::SessionInfo> abilitySessionInfo, 200 const ExceptionInfo& exceptionInfo) { return WSError::WS_OK; } 201 202 // extension session TransferAbilityResult(uint32_t resultCode,const AAFwk::Want & want)203 virtual WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) { return WSError::WS_OK; } TransferExtensionData(const AAFwk::WantParams & wantParams)204 virtual WSError TransferExtensionData(const AAFwk::WantParams& wantParams) { return WSError::WS_OK; } TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)205 virtual WSError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 206 int64_t uiExtensionIdLevel) 207 { 208 return WSError::WS_OK; 209 } NotifyFrameLayoutFinishFromApp(bool notifyListener,const WSRect & rect)210 virtual WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect) 211 { 212 return WSError::WS_OK; 213 } NotifyExtensionDied()214 virtual void NotifyExtensionDied() {} NotifyExtensionTimeout(int32_t errorCode)215 virtual void NotifyExtensionTimeout(int32_t errorCode) {} TriggerBindModalUIExtension()216 virtual void TriggerBindModalUIExtension() {} NotifySyncOn()217 virtual void NotifySyncOn() {} NotifyAsyncOn()218 virtual void NotifyAsyncOn() {} NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)219 virtual void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 220 int64_t uiExtensionIdLevel) {} NotifyExtensionEventAsync(uint32_t notifyEvent)221 virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {} SendExtensionData(MessageParcel & data,MessageParcel & reply,MessageOption & option)222 virtual WSError SendExtensionData(MessageParcel& data, MessageParcel& reply, MessageOption& option) 223 { 224 return WSError::WS_OK; 225 } 226 227 /** 228 * @brief Close pip window while stopPip is called. 229 * 230 * Notify system that pip window is stopping and execute animation. 231 */ NotifyPiPWindowPrepareClose()232 virtual void NotifyPiPWindowPrepareClose() {} 233 234 /** 235 * @brief Update the required params to system. 236 * 237 * Update the required rect and reason to determine the final size of pip window. Called when start pip, 238 * show pip window, update pip size and pip restore. 239 * Make sure the caller's process is same with the process which created pip window. 240 * 241 * @param rect Indicates the {@link Rect} structure containing required size and position. 242 * @param reason Indicates the {@link SizeChangeReason} reason. 243 * @return Returns WSError::WS_OK if called success, otherwise failed. 244 */ UpdatePiPRect(const Rect & rect,SizeChangeReason reason)245 virtual WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { return WSError::WS_OK; } 246 247 /** 248 * @brief Update the pip control status to pip control panel. 249 * 250 * Called when the specified component's status needs to be updated. 251 * Make sure the caller's process is same with the process which created pip window. 252 * 253 * @param controlType Indicates the {@link WsPiPControlType} component in pip control panel. 254 * @param status Indicates the {@link WsPiPControlStatus} status of specified component. 255 * @return Returns WSError::WS_OK if called success, otherwise failed. 256 */ UpdatePiPControlStatus(WsPiPControlType controlType,WsPiPControlStatus status)257 virtual WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status) 258 { 259 return WSError::WS_OK; 260 } 261 262 /** 263 * @brief Update the auto start pip window status. 264 * 265 * @param isAutoStart Indicates the {@link bool} 266 * @param priority Indicates the {@link uint32_t} priority of pip window 267 * @param width Indicates the {@link uint32_t} width of the video content 268 * @param height Indicates the {@link uint32_t} height of the video content 269 * @return Returns WSError::WS_OK if called success, otherwise failed. 270 */ SetAutoStartPiP(bool isAutoStart,uint32_t priority,uint32_t width,uint32_t height)271 virtual WSError SetAutoStartPiP(bool isAutoStart, uint32_t priority, uint32_t width, uint32_t height) 272 { 273 return WSError::WS_OK; 274 } 275 ProcessPointDownSession(int32_t posX,int32_t posY)276 virtual WSError ProcessPointDownSession(int32_t posX, int32_t posY) { return WSError::WS_OK; } 277 virtual WSError SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, 278 bool isExecuteDelayRaise = false) { return WSError::WS_OK; } IsStartMoving()279 virtual bool IsStartMoving() { return false; } ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo,bool isShow)280 virtual WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo, 281 bool isShow) { return WSError::WS_OK; } 282 283 /** 284 * @brief Instruct the application to update the listening flag for registering rect changes. 285 * 286 * @param isRegister Indicates the {@link bool} 287 * @return Returns WSError::WS_OK if called success, otherwise failed. 288 */ UpdateRectChangeListenerRegistered(bool isRegister)289 virtual WSError UpdateRectChangeListenerRegistered(bool isRegister) 290 { 291 return WSError::WS_OK; 292 } SetCallingSessionId(uint32_t callingSessionId)293 virtual void SetCallingSessionId(uint32_t callingSessionId) {}; NotifyKeyboardDidShowRegistered(bool registered)294 virtual void NotifyKeyboardDidShowRegistered(bool registered) { }; NotifyKeyboardDidHideRegistered(bool registered)295 virtual void NotifyKeyboardDidHideRegistered(bool registered) { }; SetCustomDecorHeight(int32_t height)296 virtual void SetCustomDecorHeight(int32_t height) {}; UpdateSessionPropertyByAction(const sptr<WindowSessionProperty> & property,WSPropertyChangeAction action)297 virtual WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property, 298 WSPropertyChangeAction action) { return WMError::WM_OK; } GetAppForceLandscapeConfig(AppForceLandscapeConfig & config)299 virtual WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) { return WMError::WM_OK; } AdjustKeyboardLayout(const KeyboardLayoutParams & params)300 virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; } SetDialogSessionBackGestureEnabled(bool isEnabled)301 virtual WSError SetDialogSessionBackGestureEnabled(bool isEnabled) { return WSError::WS_OK; } NotifyExtensionDetachToDisplay()302 virtual void NotifyExtensionDetachToDisplay() {} GetStatusBarHeight()303 virtual int32_t GetStatusBarHeight() { return 0; } 304 /** 305 * @brief Request to get focus or lose focus. 306 * 307 * @param isFocused True means window wants to get focus, false means the opposite. 308 * @return Returns WSError::WS_OK if called success, otherwise failed. 309 */ RequestFocus(bool isFocused)310 virtual WSError RequestFocus(bool isFocused) { return WSError::WS_OK; } 311 312 /** 313 * @brief Callback for session modal type changes. 314 * 315 * @param subWindowModalType Indicates the {@link SubWindowModalType} 316 * @return Returns WSError::WS_OK if called success, otherwise failed. 317 */ NotifySubModalTypeChange(SubWindowModalType subWindowModalType)318 virtual WSError NotifySubModalTypeChange(SubWindowModalType subWindowModalType) { return WSError::WS_OK; } 319 320 /** 321 * @brief Callback for main session modal type changes. 322 * 323 * @param isModal Indicates the {@link bool} 324 * @return Returns WSError::WS_OK if called success, otherwise failed. 325 */ NotifyMainModalTypeChange(bool isModal)326 virtual WSError NotifyMainModalTypeChange(bool isModal) { return WSError::WS_OK; } 327 328 /** 329 * @brief Callback for setting whether the sub window supports simultaneous display on multiple screens 330 * when the parent window is dragged to move or dragged to zoom. 331 * @param enabled Indicates the {@link bool} 332 * @return Returns WSError::WS_OK if called success, otherwise failed. 333 */ NotifyFollowParentMultiScreenPolicy(bool enabled)334 virtual WSError NotifyFollowParentMultiScreenPolicy(bool enabled) { return WSError::WS_OK; } 335 336 /** 337 * @brief Callback for setting to automatically save the window rect. 338 * 339 * @param enabled Enable the window rect auto-save if true, otherwise means the opposite. 340 * @return Returns WSError::WS_OK if called success, otherwise failed. 341 */ OnSetWindowRectAutoSave(bool enabled,bool isSaveBySpecifiedFlag)342 virtual WSError OnSetWindowRectAutoSave(bool enabled, bool isSaveBySpecifiedFlag) { return WSError::WS_OK; } 343 344 /** 345 * @brief Callback for setting to radius of window. 346 * 347 * @param cornerRadius corner radius of window. 348 * @return Returns WSError::WS_OK if called success, otherwise failed. 349 */ SetWindowCornerRadius(float cornerRadius)350 virtual WSError SetWindowCornerRadius(float cornerRadius) { return WSError::WS_OK; } 351 352 /** 353 * Gesture Back 354 */ SetGestureBackEnabled(bool isEnabled)355 virtual WMError SetGestureBackEnabled(bool isEnabled) { return WMError::WM_OK; } 356 357 /** 358 * @brief Callback for setting the window support modes. 359 * 360 * @param supportedWindowModes Indicates the {@link AppExecFwk::SupportWindowMode}. 361 * @return Returns WSError::WS_OK if called success, otherwise failed. 362 */ NotifySupportWindowModesChange(const std::vector<AppExecFwk::SupportWindowMode> & supportedWindowModes)363 virtual WSError NotifySupportWindowModesChange( 364 const std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes) { return WSError::WS_OK; } 365 366 /** 367 * @brief set session label and icon 368 * 369 * @param label 370 * @param icon 371 * @return Returns WSError::WS_OK if called success, otherwise failed. 372 * @permission ohos.permission.SET_ABILITY_INSTANCE_INFO 373 * @scene 15 374 */ SetSessionLabelAndIcon(const std::string & label,const std::shared_ptr<Media::PixelMap> & icon)375 virtual WSError SetSessionLabelAndIcon(const std::string& label, 376 const std::shared_ptr<Media::PixelMap>& icon) { return WSError::WS_OK; } 377 ChangeKeyboardViewMode(KeyboardViewMode mode)378 virtual WSError ChangeKeyboardViewMode(KeyboardViewMode mode) { return WSError::WS_OK; }; 379 380 /** 381 * @brief Start Moving window with coordinate. 382 * 383 * @param offsetX expected pointer position x-axis offset in window when start moving. 384 * @param offsetY expected pointer position y-axis offset in window when start moving. 385 * @param pointerPosX current pointer position x-axis offset in screen. 386 * @param pointerPosY current pointer position y-axis offset in screen. 387 * @return Returns WSError::WS_OK if called success, otherwise failed. 388 */ StartMovingWithCoordinate(int32_t offsetX,int32_t offsetY,int32_t pointerPosX,int32_t pointerPosY)389 virtual WSError StartMovingWithCoordinate(int32_t offsetX, int32_t offsetY, 390 int32_t pointerPosX, int32_t pointerPosY) { return WSError::WS_OK; } GetCrossAxisState(CrossAxisState & state)391 virtual WSError GetCrossAxisState(CrossAxisState& state) { return WSError::WS_OK; }; 392 393 /** 394 * @brief Notify the window attach state listener is registered or not. 395 * 396 * @param registered true means register success. 397 */ NotifyWindowAttachStateListenerRegistered(bool registered)398 virtual void NotifyWindowAttachStateListenerRegistered(bool registered) { } SetFollowParentWindowLayoutEnabled(bool isFollow)399 virtual WSError SetFollowParentWindowLayoutEnabled(bool isFollow) { return WSError::WS_OK; }; UpdateFlag(const std::string & flag)400 virtual WSError UpdateFlag(const std::string& flag) { return WSError::WS_OK; }; GetIsHighlighted(bool & isHighlighted)401 virtual WSError GetIsHighlighted(bool& isHighlighted) { return WSError::WS_OK; } 402 }; 403 } // namespace OHOS::Rosen 404 405 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_INTERFACE_H 406