• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
48     // scene session
OnSessionEvent(SessionEvent event)49     virtual WSError OnSessionEvent(SessionEvent event) { return WSError::WS_OK; }
OnLayoutFullScreenChange(bool isLayoutFullScreen)50     virtual WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) { return WSError::WS_OK; }
51 
52     /**
53      * @brief Callback for processing set default density enabled.
54      *
55      * @param isDefaultDensityEnabled Indicates the {@link bool}
56      * @return Returns WSError::WS_OK if called success, otherwise failed.
57      */
OnDefaultDensityEnabled(bool isDefaultDensityEnabled)58     virtual WSError OnDefaultDensityEnabled(bool isDefaultDensityEnabled) { return WSError::WS_OK; }
59 
RaiseToAppTop()60     virtual WSError RaiseToAppTop() { return WSError::WS_OK; }
61     virtual WSError UpdateSessionRect(
62         const WSRect &rect, const SizeChangeReason reason, bool isGlobal = false, bool isFromMoveToGlobal = false)
63     {
64         return WSError::WS_OK;
65     }
UpdateClientRect(const WSRect & rect)66     virtual WSError UpdateClientRect(const WSRect& rect) { return WSError::WS_OK; }
GetGlobalScaledRect(Rect & globalScaledRect)67     virtual WMError GetGlobalScaledRect(Rect& globalScaledRect) { return WMError::WM_OK; }
OnNeedAvoid(bool status)68     virtual WSError OnNeedAvoid(bool status) { return WSError::WS_OK; }
GetAvoidAreaByType(AvoidAreaType type)69     virtual AvoidArea GetAvoidAreaByType(AvoidAreaType type) { return {}; }
GetAllAvoidAreas(std::map<AvoidAreaType,AvoidArea> & avoidAreas)70     virtual WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) { return WSError::WS_OK; }
RequestSessionBack(bool needMoveToBackground)71     virtual WSError RequestSessionBack(bool needMoveToBackground) { return WSError::WS_OK; }
MarkProcessed(int32_t eventId)72     virtual WSError MarkProcessed(int32_t eventId) { return WSError::WS_OK; }
SetGlobalMaximizeMode(MaximizeMode mode)73     virtual WSError SetGlobalMaximizeMode(MaximizeMode mode) { return WSError::WS_OK; }
GetGlobalMaximizeMode(MaximizeMode & mode)74     virtual WSError GetGlobalMaximizeMode(MaximizeMode& mode) { return WSError::WS_OK; }
SetAspectRatio(float ratio)75     virtual WSError SetAspectRatio(float ratio) { return WSError::WS_OK; }
UpdateWindowAnimationFlag(bool needDefaultAnimationFlag)76     virtual WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) { return WSError::WS_OK; }
UpdateWindowSceneAfterCustomAnimation(bool isAdd)77     virtual WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) { return WSError::WS_OK; }
RaiseAboveTarget(int32_t subWindowId)78     virtual WSError RaiseAboveTarget(int32_t subWindowId) { return WSError::WS_OK; }
RaiseAppMainWindowToTop()79     virtual WSError RaiseAppMainWindowToTop() { return WSError::WS_OK; }
PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo)80     virtual WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo)
81         { return WSError::WS_OK; }
TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo)82     virtual WSError TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo) { return WSError::WS_OK; }
SetLandscapeMultiWindow(bool isLandscapeMultiWindow)83     virtual WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) { return WSError::WS_OK; }
84     virtual WSError NotifySessionException(
85         const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needRemoveSession = false) { return WSError::WS_OK; }
86 
87     // extension session
TransferAbilityResult(uint32_t resultCode,const AAFwk::Want & want)88     virtual WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) { return WSError::WS_OK; }
TransferExtensionData(const AAFwk::WantParams & wantParams)89     virtual WSError TransferExtensionData(const AAFwk::WantParams& wantParams) { return WSError::WS_OK; }
TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)90     virtual WSError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
91         int64_t uiExtensionIdLevel)
92     {
93         return WSError::WS_OK;
94     }
NotifyFrameLayoutFinishFromApp(bool notifyListener,const WSRect & rect)95     virtual WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect)
96     {
97         return WSError::WS_OK;
98     }
NotifyExtensionDied()99     virtual void NotifyExtensionDied() {}
NotifyExtensionTimeout(int32_t errorCode)100     virtual void NotifyExtensionTimeout(int32_t errorCode) {}
TriggerBindModalUIExtension()101     virtual void TriggerBindModalUIExtension() {}
NotifySyncOn()102     virtual void NotifySyncOn() {}
NotifyAsyncOn()103     virtual void NotifyAsyncOn() {}
NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)104     virtual void NotifyTransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
105         int64_t uiExtensionIdLevel) {}
106 
107     /**
108      * @brief Close pip window while stopPip is called.
109      *
110      * Notify system that pip window is stopping and execute animation.
111      */
NotifyPiPWindowPrepareClose()112     virtual void NotifyPiPWindowPrepareClose() {}
113 
114     /**
115      * @brief Update the required params to system.
116      *
117      * Update the required rect and reason to determine the final size of pip window. Called when start pip,
118      * show pip window, update pip size and pip restore.\n
119      * Make sure the caller's process is same with the process which created pip window.\n
120      *
121      * @param rect Indicates the {@link Rect} structure containing required size and position.
122      * @param reason Indicates the {@link SizeChangeReason} reason.
123      * @return Returns WSError::WS_OK if called success, otherwise failed.
124      */
UpdatePiPRect(const Rect & rect,SizeChangeReason reason)125     virtual WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { return WSError::WS_OK; }
126 
127     /**
128      * @brief Update the pip control status to pip control panel.
129      *
130      * Called when the specified component's status needs to be updated.\n
131      * Make sure the caller's process is same with the process which created pip window.\n
132      *
133      * @param controlType Indicates the {@link WsPiPControlType} component in pip control panel.
134      * @param status Indicates the {@link WsPiPControlStatus} status of specified component.
135      * @return Returns WSError::WS_OK if called success, otherwise failed.
136      */
UpdatePiPControlStatus(WsPiPControlType controlType,WsPiPControlStatus status)137     virtual WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status)
138     {
139         return WSError::WS_OK;
140     }
141 
142     /**
143      * @brief Update the auto start pip window status.
144      *
145      * @param isAutoStart Indicates the {@link bool}
146      * @param priority Indicates the {@link uint32_t} priority of pip window
147      * @return Returns WSError::WS_OK if called success, otherwise failed.
148      */
SetAutoStartPiP(bool isAutoStart,uint32_t priority)149     virtual WSError SetAutoStartPiP(bool isAutoStart, uint32_t priority) { return WSError::WS_OK; }
150 
ProcessPointDownSession(int32_t posX,int32_t posY)151     virtual WSError ProcessPointDownSession(int32_t posX, int32_t posY) { return WSError::WS_OK; }
SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)152     virtual WSError SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
153     {
154         return WSError::WS_OK;
155     }
ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo,bool visible)156     virtual WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
157         bool visible) { return WSError::WS_OK; }
UpdateRectChangeListenerRegistered(bool isRegister)158     virtual WSError UpdateRectChangeListenerRegistered(bool isRegister)
159     {
160         return WSError::WS_OK;
161     }
SetKeyboardSessionGravity(SessionGravity gravity,uint32_t percent)162     virtual WSError SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent)
163     {
164         return WSError::WS_OK;
165     }
SetCallingSessionId(uint32_t callingSessionId)166     virtual void SetCallingSessionId(uint32_t callingSessionId) {};
SetCustomDecorHeight(int32_t height)167     virtual void SetCustomDecorHeight(int32_t height) {};
UpdateSessionPropertyByAction(const sptr<WindowSessionProperty> & property,WSPropertyChangeAction action)168     virtual WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
169         WSPropertyChangeAction action) { return WMError::WM_OK; }
GetAppForceLandscapeConfig(AppForceLandscapeConfig & config)170     virtual WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) { return WMError::WM_OK; }
AdjustKeyboardLayout(const KeyboardLayoutParams & params)171     virtual WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) { return WSError::WS_OK; }
SetDialogSessionBackGestureEnabled(bool isEnabled)172     virtual WSError SetDialogSessionBackGestureEnabled(bool isEnabled) { return WSError::WS_OK; }
173 
174     /**
175      * @brief Request to get focus or lose focus.
176      *
177      * @param isFocused True means window wants to get focus, false means the opposite.
178      * @return Returns WSError::WS_OK if called success, otherwise failed.
179      */
RequestFocus(bool isFocused)180     virtual WSError RequestFocus(bool isFocused) { return WSError::WS_OK; }
181 
182     /*
183      *  Gesture Back
184      */
SetGestureBackEnabled(bool isEnabled)185     virtual WMError SetGestureBackEnabled(bool isEnabled) { return WMError::WM_OK; }
186 };
187 } // namespace OHOS::Rosen
188 
189 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_INTERFACE_H
190