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 OnSessionEvent(SessionEvent event)50 virtual WSError OnSessionEvent(SessionEvent event) { return WSError::WS_OK; } 51 52 /** 53 * @brief Receive session event from application. 54 * 55 * This function provides the ability for applications to move window. 56 * This interface will take effect after touch down event. 57 * 58 * @return Returns WSError::WS_OK if called success, otherwise failed. 59 */ SyncSessionEvent(SessionEvent event)60 virtual WSError SyncSessionEvent(SessionEvent event) { return WSError::WS_OK; } 61 62 /** 63 * @brief Enables or disables system window dragging. 64 * 65 * This function provides the ability for system applications to make system window dragable. 66 * 67 * @return Returns WSError::WS_OK if called success, otherwise failed. 68 * @permission Make sure the caller has system permission. 69 */ SetSystemWindowEnableDrag(bool enableDrag)70 virtual WMError SetSystemWindowEnableDrag(bool enableDrag) { return WMError::WM_OK; } 71 OnLayoutFullScreenChange(bool isLayoutFullScreen)72 virtual WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) { return WSError::WS_OK; } 73 74 /** 75 * @brief Callback for processing set default density enabled. 76 * 77 * @param isDefaultDensityEnabled Indicates the {@link bool} 78 * @return Returns WSError::WS_OK if called success, otherwise failed. 79 */ OnDefaultDensityEnabled(bool isDefaultDensityEnabled)80 virtual WSError OnDefaultDensityEnabled(bool isDefaultDensityEnabled) { return WSError::WS_OK; } 81 82 /** 83 * @brief Callback for processing title and dock hover show changes. 84 * 85 * @param isTitleHoverShown Indicates the {@link bool} 86 * @param isDockHoverShown Indicates the {@link bool} 87 * @return Returns WSError::WS_OK if called success, otherwise failed. 88 */ 89 virtual WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true, 90 bool isDockHoverShown = true) { return WSError::WS_OK; } 91 92 /** 93 * @brief Callback for processing restore main window. 94 * 95 * @return Returns WSError::WS_OK if called success, otherwise failed. 96 */ OnRestoreMainWindow()97 virtual WSError OnRestoreMainWindow() { return WSError::WS_OK; } 98 RaiseToAppTop()99 virtual WSError RaiseToAppTop() { return WSError::WS_OK; } 100 virtual WSError UpdateSessionRect( 101 const WSRect& rect, const SizeChangeReason reason, bool isGlobal = false, bool isFromMoveToGlobal = false) 102 { 103 return WSError::WS_OK; 104 } UpdateClientRect(const WSRect & rect)105 virtual WSError UpdateClientRect(const WSRect& rect) { return WSError::WS_OK; } GetGlobalScaledRect(Rect & globalScaledRect)106 virtual WMError GetGlobalScaledRect(Rect& globalScaledRect) { return WMError::WM_OK; } OnNeedAvoid(bool status)107 virtual WSError OnNeedAvoid(bool status) { return WSError::WS_OK; } GetAvoidAreaByType(AvoidAreaType type)108 virtual AvoidArea GetAvoidAreaByType(AvoidAreaType type) { return {}; } GetAllAvoidAreas(std::map<AvoidAreaType,AvoidArea> & avoidAreas)109 virtual WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) { return WSError::WS_OK; } RequestSessionBack(bool needMoveToBackground)110 virtual WSError RequestSessionBack(bool needMoveToBackground) { return WSError::WS_OK; } MarkProcessed(int32_t eventId)111 virtual WSError MarkProcessed(int32_t eventId) { return WSError::WS_OK; } SetGlobalMaximizeMode(MaximizeMode mode)112 virtual WSError SetGlobalMaximizeMode(MaximizeMode mode) { return WSError::WS_OK; } GetGlobalMaximizeMode(MaximizeMode & mode)113 virtual WSError GetGlobalMaximizeMode(MaximizeMode& mode) { return WSError::WS_OK; } SetAspectRatio(float ratio)114 virtual WSError SetAspectRatio(float ratio) { return WSError::WS_OK; } UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)115 virtual WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) { return WSError::WS_OK; } UpdateWindowSceneAfterCustomAnimation(bool isAdd)116 virtual WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) { return WSError::WS_OK; } RaiseAboveTarget(int32_t subWindowId)117 virtual WSError RaiseAboveTarget(int32_t subWindowId) { return WSError::WS_OK; } RaiseAppMainWindowToTop()118 virtual WSError RaiseAppMainWindowToTop() { return WSError::WS_OK; } PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo)119 virtual WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo) 120 { return WSError::WS_OK; } TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)121 virtual WSError TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo) { return WSError::WS_OK; } SetLandscapeMultiWindow(bool isLandscapeMultiWindow)122 virtual WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WSError::WS_OK; } GetIsMidScene(bool & isMidScene)123 virtual WSError GetIsMidScene(bool& isMidScene) { return WSError::WS_OK; } 124 virtual WSError NotifySessionException( 125 const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needRemoveSession = false) { return WSError::WS_OK; } 126 127 // extension session TransferAbilityResult(uint32_t resultCode,const AAFwk::Want & want)128 virtual WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) { return WSError::WS_OK; } TransferExtensionData(const AAFwk::WantParams & wantParams)129 virtual WSError TransferExtensionData(const AAFwk::WantParams& wantParams) { return WSError::WS_OK; } TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)130 virtual WSError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 131 int64_t uiExtensionIdLevel) 132 { 133 return WSError::WS_OK; 134 } NotifyFrameLayoutFinishFromApp(bool notifyListener,const WSRect & rect)135 virtual WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect) 136 { 137 return WSError::WS_OK; 138 } NotifyExtensionDied()139 virtual void NotifyExtensionDied() {} NotifyExtensionTimeout(int32_t errorCode)140 virtual void NotifyExtensionTimeout(int32_t errorCode) {} TriggerBindModalUIExtension()141 virtual void TriggerBindModalUIExtension() {} NotifySyncOn()142 virtual void NotifySyncOn() {} NotifyAsyncOn()143 virtual void NotifyAsyncOn() {} NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)144 virtual void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, 145 int64_t uiExtensionIdLevel) {} NotifyExtensionEventAsync(uint32_t notifyEvent)146 virtual void NotifyExtensionEventAsync(uint32_t notifyEvent) {} SendExtensionData(MessageParcel & data,MessageParcel & reply,MessageOption & option)147 virtual WSError SendExtensionData(MessageParcel& data, MessageParcel& reply, MessageOption& option) 148 { 149 return WSError::WS_OK; 150 } 151 152 /** 153 * @brief Close pip window while stopPip is called. 154 * 155 * Notify system that pip window is stopping and execute animation. 156 */ NotifyPiPWindowPrepareClose()157 virtual void NotifyPiPWindowPrepareClose() {} 158 159 /** 160 * @brief Update the required params to system. 161 * 162 * Update the required rect and reason to determine the final size of pip window. Called when start pip, 163 * show pip window, update pip size and pip restore. 164 * Make sure the caller's process is same with the process which created pip window. 165 * 166 * @param rect Indicates the {@link Rect} structure containing required size and position. 167 * @param reason Indicates the {@link SizeChangeReason} reason. 168 * @return Returns WSError::WS_OK if called success, otherwise failed. 169 */ UpdatePiPRect(const Rect & rect,SizeChangeReason reason)170 virtual WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { return WSError::WS_OK; } 171 172 /** 173 * @brief Update the pip control status to pip control panel. 174 * 175 * Called when the specified component's status needs to be updated. 176 * Make sure the caller's process is same with the process which created pip window. 177 * 178 * @param controlType Indicates the {@link WsPiPControlType} component in pip control panel. 179 * @param status Indicates the {@link WsPiPControlStatus} status of specified component. 180 * @return Returns WSError::WS_OK if called success, otherwise failed. 181 */ UpdatePiPControlStatus(WsPiPControlType controlType,WsPiPControlStatus status)182 virtual WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status) 183 { 184 return WSError::WS_OK; 185 } 186 187 /** 188 * @brief Update the auto start pip window status. 189 * 190 * @param isAutoStart Indicates the {@link bool} 191 * @param priority Indicates the {@link uint32_t} priority of pip window 192 * @return Returns WSError::WS_OK if called success, otherwise failed. 193 */ SetAutoStartPiP(bool isAutoStart,uint32_t priority)194 virtual WSError SetAutoStartPiP(bool isAutoStart, uint32_t priority) { return WSError::WS_OK; } 195 ProcessPointDownSession(int32_t posX,int32_t posY)196 virtual WSError ProcessPointDownSession(int32_t posX, int32_t posY) { return WSError::WS_OK; } SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)197 virtual WSError SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) 198 { 199 return WSError::WS_OK; 200 } IsStartMoving()201 virtual bool IsStartMoving() { return false; } ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo,bool visible)202 virtual WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo, 203 bool visible) { return WSError::WS_OK; } UpdateRectChangeListenerRegistered(bool isRegister)204 virtual WSError UpdateRectChangeListenerRegistered(bool isRegister) 205 { 206 return WSError::WS_OK; 207 } SetCallingSessionId(uint32_t callingSessionId)208 virtual void SetCallingSessionId(uint32_t callingSessionId) {}; SetCustomDecorHeight(int32_t height)209 virtual void SetCustomDecorHeight(int32_t height) {}; UpdateSessionPropertyByAction(const sptr<WindowSessionProperty> & property,WSPropertyChangeAction action)210 virtual WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property, 211 WSPropertyChangeAction action) { return WMError::WM_OK; } GetAppForceLandscapeConfig(AppForceLandscapeConfig & config)212 virtual WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) { return WMError::WM_OK; } AdjustKeyboardLayout(const KeyboardLayoutParams & params)213 virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; } SetDialogSessionBackGestureEnabled(bool isEnabled)214 virtual WSError SetDialogSessionBackGestureEnabled(bool isEnabled) { return WSError::WS_OK; } NotifyExtensionDetachToDisplay()215 virtual void NotifyExtensionDetachToDisplay() {} 216 217 /** 218 * @brief Request to get focus or lose focus. 219 * 220 * @param isFocused True means window wants to get focus, false means the opposite. 221 * @return Returns WSError::WS_OK if called success, otherwise failed. 222 */ RequestFocus(bool isFocused)223 virtual WSError RequestFocus(bool isFocused) { return WSError::WS_OK; } 224 225 /** 226 * @brief Callback for session modal type changes. 227 * 228 * @param subWindowModalType Indicates the {@link SubWindowModalType} 229 * @return Returns WSError::WS_OK if called success, otherwise failed. 230 */ NotifySubModalTypeChange(SubWindowModalType subWindowModalType)231 virtual WSError NotifySubModalTypeChange(SubWindowModalType subWindowModalType) { return WSError::WS_OK; } 232 233 /** 234 * @brief Callback for main session modal type changes. 235 * 236 * @param isModal Indicates the {@link bool} 237 * @return Returns WSError::WS_OK if called success, otherwise failed. 238 */ NotifyMainModalTypeChange(bool isModal)239 virtual WSError NotifyMainModalTypeChange(bool isModal) { return WSError::WS_OK; } 240 241 /** 242 * @brief Callback for setting to automatically save the window rect. 243 * 244 * @param enabled Enable the window rect auto-save if true, otherwise means the opposite. 245 * @return Returns WSError::WS_OK if called success, otherwise failed. 246 */ OnSetWindowRectAutoSave(bool enabled)247 virtual WSError OnSetWindowRectAutoSave(bool enabled) { return WSError::WS_OK; } 248 249 /* 250 * Gesture Back 251 */ SetGestureBackEnabled(bool isEnabled)252 virtual WMError SetGestureBackEnabled(bool isEnabled) { return WMError::WM_OK; } 253 254 /** 255 * @brief set session label and icon 256 * 257 * @param label 258 * @param icon 259 * @return Returns WSError::WS_OK if called success, otherwise failed. 260 * @permission ohos.permission.SET_ABILITY_INSTANCE_INFO 261 * @scene 15 262 */ SetSessionLabelAndIcon(const std::string & label,const std::shared_ptr<Media::PixelMap> & icon)263 virtual WSError SetSessionLabelAndIcon(const std::string& label, 264 const std::shared_ptr<Media::PixelMap>& icon) { return WSError::WS_OK; } 265 ChangeKeyboardViewMode(KeyboardViewMode mode)266 virtual WSError ChangeKeyboardViewMode(KeyboardViewMode mode) { return WSError::WS_OK; }; 267 268 /** 269 * @brief Start Moving window with coordinate. 270 * 271 * @param offsetX expected pointer position x-axis offset in window when start moving. 272 * @param offsetY expected pointer position y-axis offset in window when start moving. 273 * @param pointerPosX current pointer position x-axis offset in screen. 274 * @param pointerPosY current pointer position y-axis offset in screen. 275 * @return Returns WSError::WS_OK if called success, otherwise failed. 276 */ StartMovingWithCoordinate(int32_t offsetX,int32_t offsetY,int32_t pointerPosX,int32_t pointerPosY)277 virtual WSError StartMovingWithCoordinate(int32_t offsetX, int32_t offsetY, 278 int32_t pointerPosX, int32_t pointerPosY) { return WSError::WS_OK; } 279 280 /** 281 * @brief Callback for setting the window support modes. 282 * 283 * @param supportedWindowModes Indicates the {@link AppExecFwk::SupportWindowMode}. 284 * @return Returns WSError::WS_OK if called success, otherwise failed. 285 */ NotifySupportWindowModesChange(const std::vector<AppExecFwk::SupportWindowMode> & supportedWindowModes)286 virtual WSError NotifySupportWindowModesChange( 287 const std::vector<AppExecFwk::SupportWindowMode>& supportedWindowModes) { return WSError::WS_OK; } 288 }; 289 } // namespace OHOS::Rosen 290 291 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_INTERFACE_H 292