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 Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig, sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr, const std::string& identityToken = �)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 48 // scene session 49 /** 50 * @brief Receive session event from application. 51 * 52 * This function provides the ability for applications to move window.\n 53 * This interface will take effect after touch down event.\n 54 * 55 * @param event Indicates the {@link SessionEvent} 56 * @return Returns WSError::WS_OK if called success, otherwise failed. 57 */ OnSessionEvent(SessionEvent event)58 virtual WSError OnSessionEvent(SessionEvent event) { return WSError::WS_OK; } 59 60 /** 61 * @brief Receive session event from system application. 62 * 63 * This function provides the ability for system applications to move system window.\n 64 * This interface will take effect after touch down event.\n 65 * 66 * @return Returns WSError::WS_OK if called success, otherwise failed. 67 * @permission Make sure the caller has system permission. 68 */ OnSystemSessionEvent(SessionEvent event)69 virtual WSError OnSystemSessionEvent(SessionEvent event) { return WSError::WS_OK; } SetSystemWindowEnableDrag(bool enableDrag)70 virtual WMError SetSystemWindowEnableDrag(bool enableDrag) { return WMError::WM_OK; } 71 72 /** 73 * @brief Callback for processing full-screen layout changes. 74 * 75 * @param isLayoutFullScreen Indicates the {@link bool} 76 * @return Returns WSError::WS_OK if called success, otherwise failed. 77 */ OnLayoutFullScreenChange(bool isLayoutFullScreen)78 virtual WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) { return WSError::WS_OK; } 79 80 /** 81 * @brief Callback for processing restore main window. 82 * 83 * @return Returns WSError::WS_OK if called success, otherwise failed. 84 */ OnRestoreMainWindow()85 virtual WSError OnRestoreMainWindow() { return WSError::WS_OK; } 86 87 /** 88 * @brief Callback for processing title and dock hover show changes. 89 * 90 * @param isTitleHoverShown Indicates the {@link bool} 91 * @param isDockHoverShown Indicates the {@link bool} 92 * @return Returns WSError::WS_OK if called success, otherwise failed. 93 */ OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, bool isDockHoverShown = true)94 virtual WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, 95 bool isDockHoverShown = true) 96 { 97 return WSError::WS_OK; 98 } 99 100 /** 101 * @brief Raise the application subwindow to the top layer of the application. 102 * 103 * @return Returns WSError::WS_OK if called success, otherwise failed. 104 * @permission Make sure the caller has system permission. 105 */ RaiseToAppTop()106 virtual WSError RaiseToAppTop() { return WSError::WS_OK; } 107 108 /** 109 * @brief Update window size and position. 110 * 111 * @param rect Indicates the {@link WSRect} structure containing required size and position. 112 * @param reason Indicates the {@link SizeChangeReason} reason. 113 * @param isGlobal Indicates the {@link bool}. 114 * @return Returns WSError::WS_OK if called success, otherwise failed. 115 */ UpdateSessionRect( const WSRect& rect, const SizeChangeReason reason, bool isGlobal = false)116 virtual WSError UpdateSessionRect( 117 const WSRect& rect, const SizeChangeReason reason, bool isGlobal = false) { return WSError::WS_OK; } UpdateClientRect(const WSRect& rect)118 virtual WSError UpdateClientRect(const WSRect& rect) { return WSError::WS_OK; } OnNeedAvoid(bool status)119 virtual WSError OnNeedAvoid(bool status) { return WSError::WS_OK; } GetAvoidAreaByType(AvoidAreaType type)120 virtual AvoidArea GetAvoidAreaByType(AvoidAreaType type) { return {}; } GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas)121 virtual WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) { return WSError::WS_OK; } RequestSessionBack(bool needMoveToBackground)122 virtual WSError RequestSessionBack(bool needMoveToBackground) { return WSError::WS_OK; } MarkProcessed(int32_t eventId)123 virtual WSError MarkProcessed(int32_t eventId) { return WSError::WS_OK; } 124 125 /** 126 * @brief Sets the global maximization mode of window. 127 * 128 * @param mode Indicates the {@link MaximizeMode}. 129 * @return Returns WSError::WS_OK if called success, otherwise failed. 130 */ SetGlobalMaximizeMode(MaximizeMode mode)131 virtual WSError SetGlobalMaximizeMode(MaximizeMode mode) { return WSError::WS_OK; } 132 133 /** 134 * @brief Obtains the global maximization mode of window. 135 * 136 * @param mode Indicates the {@link MaximizeMode}. 137 * @return Returns WSError::WS_OK if called success, otherwise failed. 138 */ GetGlobalMaximizeMode(MaximizeMode& mode)139 virtual WSError GetGlobalMaximizeMode(MaximizeMode& mode) { return WSError::WS_OK; } 140 141 /** 142 * @brief Sets the aspect ratio of window. 143 * 144 * @param ratio Indicates the {@link float} 145 * @return Returns WSError::WS_OK if called success, otherwise failed. 146 */ SetAspectRatio(float ratio)147 virtual WSError SetAspectRatio(float ratio) { return WSError::WS_OK; } UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)148 virtual WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) { return WSError::WS_OK; } UpdateWindowSceneAfterCustomAnimation(bool isAdd)149 virtual WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) { return WSError::WS_OK; } 150 151 /** 152 * @brief Raise a subwindow above a target subwindow. 153 * 154 * @param subWindowId Indicates the {@link int32_t} id of the target subwindow. 155 * @return Returns WSError::WS_OK if called success, otherwise failed. 156 * @permission Make sure the caller has system permission. 157 */ RaiseAboveTarget(int32_t subWindowId)158 virtual WSError RaiseAboveTarget(int32_t subWindowId) { return WSError::WS_OK; } 159 160 /** 161 * @brief Raise the application main window to the top layer of the application. 162 * 163 * @return Returns WSError::WS_OK if called success, otherwise failed. 164 */ RaiseAppMainWindowToTop()165 virtual WSError RaiseAppMainWindowToTop() { return WSError::WS_OK; } PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo)166 virtual WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo) 167 { return WSError::WS_OK; } TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)168 virtual WSError TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo) { return WSError::WS_OK; } SetLandscapeMultiWindow(bool isLandscapeMultiWindow)169 virtual WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WSError::WS_OK; } NotifySessionException( const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needRemoveSession = false)170 virtual WSError NotifySessionException( 171 const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needRemoveSession = false) { return WSError::WS_OK; } 172 173 // extension session TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want)174 virtual WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) { return WSError::WS_OK; } TransferExtensionData(const AAFwk::WantParams& wantParams)175 virtual WSError TransferExtensionData(const AAFwk::WantParams& wantParams) { return WSError::WS_OK; } TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel)176 virtual WSError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 177 int64_t uiExtensionIdLevel) 178 { 179 return WSError::WS_OK; 180 } NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect)181 virtual WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect) 182 { 183 return WSError::WS_OK; 184 } NotifyExtensionDied()185 virtual void NotifyExtensionDied() {} NotifyExtensionTimeout(int32_t errorCode)186 virtual void NotifyExtensionTimeout(int32_t errorCode) {} TriggerBindModalUIExtension()187 virtual void TriggerBindModalUIExtension() {} NotifySyncOn()188 virtual void NotifySyncOn() {} NotifyAsyncOn()189 virtual void NotifyAsyncOn() {} NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t uiExtensionIdLevel)190 virtual void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 191 int64_t uiExtensionIdLevel) {} 192 193 /** 194 * @brief Close pip window while stopPip is called. 195 * 196 * Notify system that pip window is stopping and execute animation. 197 */ NotifyPiPWindowPrepareClose()198 virtual void NotifyPiPWindowPrepareClose() {} 199 200 /** 201 * @brief Update the required params to system. 202 * 203 * Update the required rect and reason to determine the final size of pip window. Called when start pip, 204 * show pip window, update pip size and pip restore.\n 205 * Make sure the caller's process is same with the process which created pip window.\n 206 * 207 * @param rect Indicates the {@link Rect} structure containing required size and position. 208 * @param reason Indicates the {@link SizeChangeReason} reason. 209 * @return Returns WSError::WS_OK if called success, otherwise failed. 210 */ UpdatePiPRect(const Rect& rect, SizeChangeReason reason)211 virtual WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { return WSError::WS_OK; } 212 213 /** 214 * @brief Update the pip control status to pip control panel. 215 * 216 * Called when the specified component's status needs to be updated.\n 217 * Make sure the caller's process is same with the process which created pip window.\n 218 * 219 * @param controlType Indicates the {@link WsPiPControlType} component in pip control panel. 220 * @param status Indicates the {@link WsPiPControlStatus} status of specified component. 221 * @return Returns WSError::WS_OK if called success, otherwise failed. 222 */ UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status)223 virtual WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status) 224 { 225 return WSError::WS_OK; 226 } 227 228 /** 229 * @brief Update the auto start pip window status. 230 * 231 * @param isAutoStart Indicates the {@link bool} 232 * @return Returns WSError::WS_OK if called success, otherwise failed. 233 */ SetAutoStartPiP(bool isAutoStart)234 virtual WSError SetAutoStartPiP(bool isAutoStart) { return WSError::WS_OK; } 235 ProcessPointDownSession(int32_t posX, int32_t posY)236 virtual WSError ProcessPointDownSession(int32_t posX, int32_t posY) { return WSError::WS_OK; } SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)237 virtual WSError SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) 238 { 239 return WSError::WS_OK; 240 } GetStartMoveFlag(bool& isMoving)241 virtual WSError GetStartMoveFlag(bool& isMoving) { return WSError::WS_OK; } ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool isShow)242 virtual WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo, 243 bool isShow) { return WSError::WS_OK; } 244 245 /** 246 * @brief Instruct the application to update the listening flag for registering rect changes. 247 * 248 * @param isRegister Indicates the {@link bool} 249 * @return Returns WSError::WS_OK if called success, otherwise failed. 250 */ UpdateRectChangeListenerRegistered(bool isRegister)251 virtual WSError UpdateRectChangeListenerRegistered(bool isRegister) 252 { 253 return WSError::WS_OK; 254 } SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent)255 virtual WSError SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent) 256 { 257 return WSError::WS_OK; 258 } SetCallingSessionId(uint32_t callingSessionId)259 virtual void SetCallingSessionId(uint32_t callingSessionId) {}; SetCustomDecorHeight(int32_t height)260 virtual void SetCustomDecorHeight(int32_t height) {}; UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property, WSPropertyChangeAction action)261 virtual WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property, 262 WSPropertyChangeAction action) { return WMError::WM_OK; } GetAppForceLandscapeConfig(AppForceLandscapeConfig& config)263 virtual WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) { return WMError::WM_OK; } AdjustKeyboardLayout(const KeyboardLayoutParams& params)264 virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; } GetStatusBarHeight()265 virtual int32_t GetStatusBarHeight() { return 0; } SetDialogSessionBackGestureEnabled(bool isEnabled)266 virtual WSError SetDialogSessionBackGestureEnabled(bool isEnabled) { return WSError::WS_OK; } 267 268 /** 269 * @brief Request to get focus or lose focus. 270 * 271 * @param isFocused True means window wants to get focus, false means the opposite. 272 * @return Returns WSError::WS_OK if called success, otherwise failed. 273 */ RequestFocus(bool isFocused)274 virtual WSError RequestFocus(bool isFocused) { return WSError::WS_OK; } 275 276 /** 277 * @brief Set focusable of window when show. 278 * 279 * @param isFocusableOnShow True means window can get focus when it shows to foreground, false means the opposite. 280 * @return Returns WSError::WS_OK if called success, otherwise failed. 281 */ SetFocusableOnShow(bool isFocusableOnShow)282 virtual WSError SetFocusableOnShow(bool isFocusableOnShow) { return WSError::WS_OK; } 283 NotifyExtensionEventAsync(uint32_t notifyEvent)284 virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {}; 285 /** 286 * @brief Callback for session modal type changes. 287 * 288 * @param subWindowModalType Indicates the {@link SubWindowModalType} 289 * @return Returns WSError::WS_OK if called success, otherwise failed. 290 */ OnSessionModalTypeChange(SubWindowModalType subWindowModalType)291 virtual WSError OnSessionModalTypeChange(SubWindowModalType subWindowModalType) { return WSError::WS_OK; } 292 293 /* 294 * Gesture Back 295 */ SetGestureBackEnabled(bool isEnabled)296 virtual WMError SetGestureBackEnabled(bool isEnabled) { return WMError::WM_OK; } 297 }; 298 } // namespace OHOS::Rosen 299 300 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_INTERFACE_H 301