• 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_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
17 #define OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
18 
19 #include <iremote_broker.h>
20 #include <list>
21 #include <map>
22 #include "common/include/window_session_property.h"
23 #include "interfaces/include/ws_common.h"
24 #include "occupied_area_change_info.h"
25 
26 namespace OHOS::MMI {
27 class PointerEvent;
28 class KeyEvent;
29 class AxisEvent;
30 } // namespace MMI
31 namespace OHOS::Accessibility {
32 class AccessibilityElementInfo;
33 }
34 namespace OHOS::Rosen {
35 class RSTransaction;
36 class RSCanvasNode;
37 
38 class ISessionStage : public IRemoteBroker {
39 public:
40     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISessionStage");
41 
42     // IPC interface
43     virtual WSError SetActive(bool active) = 0;
44 
45     /**
46      * @brief update the window rect.
47      *
48      * This function provides the ability for applications to update window rect.
49      *
50      * @param rect the position and size of the window.
51      * @param reason the update reason.
52      * @param config the animation parameter configuration.
53      * @return Returns WSError::WS_OK if called success, otherwise failed.
54      */
55     virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
56         const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION },
57         const std::map<AvoidAreaType, AvoidArea>& avoidAreas = {}) = 0;
58 
59     /**
60      * @brief Update the window's rectangle in global coordinates from server-side state.
61      *
62      * This method is invoked internally by the server to synchronize the window's
63      * position and size in global coordinates after layout or state changes.
64      *
65      * @param rect The updated rectangle (position and size) in global coordinates.
66      * @param reason The reason for the size or position change.
67      * @return WSError::WS_OK if the update succeeds; otherwise, returns the corresponding error code.
68      */
UpdateGlobalDisplayRectFromServer(const WSRect & rect,SizeChangeReason reason)69     virtual WSError UpdateGlobalDisplayRectFromServer(const WSRect& rect, SizeChangeReason reason)
70     {
71         return WSError::WS_DO_NOTHING;
72     }
73 
74     virtual void UpdateDensity() = 0;
75     virtual WSError UpdateOrientation() = 0;
76 
77     /**
78      * @brief Update session viewport config.
79      *
80      * Called when viewport configuration parameters such as density or orientation changes, update to the UIExtension
81      * process.
82      *
83      * @param config Indicates the {@link SessionViewportConfig} viewport configuration parameters.
84      * @return Returns WSError::WS_OK if called success, otherwise failed .
85      */
UpdateSessionViewportConfig(const SessionViewportConfig & config)86     virtual WSError UpdateSessionViewportConfig(const SessionViewportConfig& config)
87     {
88         return WSError::WS_OK;
89     };
SendExtensionData(MessageParcel & data,MessageParcel & reply,MessageOption & option)90     virtual WSError SendExtensionData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
91     {
92         return WSError::WS_OK;
93     }
94     virtual WSError HandleBackEvent() = 0;
95     virtual WSError MarkProcessed(int32_t eventId) = 0;
96 
97     /**
98      * @brief update the focus
99      *
100      * Notify window session to update focus status.
101      *
102      * @param isFocused set isFocused.
103      * @return Returns WSError::WS_OK if called success, otherwise failed.
104      */
105     virtual WSError UpdateFocus(bool isFocused) = 0;
106     virtual WSError NotifyDestroy() = 0;
107     virtual WSError NotifyExtensionSecureLimitChange(bool isLimit) = 0;
108     virtual WSError NotifyHighlightChange(bool isHighlight) = 0;
109 
110     /**
111      * @brief Notify client to close the existing pip window.
112      *
113      * Called when starting pip but there is already a pip window foreground. The previous one will be destroyed if
114      * the new starting request has a higher priority.
115      *
116      * @return Returns WSError::WS_OK if called success, otherwise failed.
117      */
118     virtual WSError NotifyCloseExistPipWindow() = 0;
119     virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) = 0;
120     virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams,
121         AAFwk::WantParams& reWantParams) = 0;
122     virtual void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,
123         const std::shared_ptr<RSTransaction>& rsTransaction, const Rect& callingSessionRect,
124         const std::map<AvoidAreaType, AvoidArea>& avoidAreas) = 0;
125     virtual WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) = 0;
126     virtual void NotifyScreenshot() = 0;
127     virtual WSError NotifyScreenshotAppEvent(ScreenshotEventType type) = 0;
128     virtual void DumpSessionElementInfo(const std::vector<std::string>& params) = 0;
129     virtual WSError NotifyTouchOutside() = 0;
130     virtual WSError NotifyWindowVisibility(bool isVisible) = 0;
131     virtual WSError UpdateWindowMode(WindowMode mode) = 0;
132     virtual WSError GetTopNavDestinationName(std::string& topNavDestName) = 0;
133     virtual WSError NotifyLayoutFinishAfterWindowModeChange(WindowMode mode) = 0;
UpdateWindowModeForUITest(int32_t updateMode)134     virtual WMError UpdateWindowModeForUITest(int32_t updateMode) { return WMError::WM_OK; }
135     virtual void NotifyForegroundInteractiveStatus(bool interactive) = 0;
136     virtual void NotifyLifecyclePausedStatus() = 0;
137     virtual void NotifyAppUseControlStatus(bool isUseControl) = 0;
138     virtual WSError UpdateMaximizeMode(MaximizeMode mode) = 0;
139     virtual void NotifySessionForeground(uint32_t reason, bool withAnimation) = 0;
140     virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0;
141     virtual WMError GetRouterStackInfo(std::string& routerStackInfo) = 0;
142     virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0;
143 
144     /**
145      * @brief Notify transform.
146      *
147      * Notify transform when window changed.
148      *
149      * @param transform transform to change.
150      */
151     virtual void NotifyTransformChange(const Transform& transform) = 0;
152     virtual WSError NotifyDialogStateChange(bool isForeground) = 0;
153 
154     /**
155      * @brief Notify single hand transform.
156      *
157      * Notify singleHandTransform when single hand mode changed.
158      *
159      * @param singleHandTransform transform to change.
160      */
161     virtual void NotifySingleHandTransformChange(const SingleHandTransform& singleHandTransform) = 0;
162 
163     /**
164      * @brief Set pip event to client.
165      *
166      * Set the pip event to client. Such as close, restore, destroy events.
167      *
168      * @param action Indicates the action name.
169      * @param status Indicates the status num.
170      * @return Returns WSError::WS_OK if called success, otherwise failed.
171      */
172     virtual WSError SetPipActionEvent(const std::string& action, int32_t status) = 0;
173 
174     /**
175      * @brief notify pip size to client.
176      *
177      * Notify the pip size to client. including width, height and scale.
178      *
179      * @param width Indicates the size width.
180      * @param height Indicates the size height.
181      * @param scale Indicates the size scale.
182      * @return Returns WSError::WS_OK if called success, otherwise failed.
183      */
184     virtual WSError NotifyPipWindowSizeChange(double width, double height, double scale) = 0;
185 
186     /**
187      * @brief Set the media control event to client.
188      *
189      * Set the media control event to client. The event is from pip control panel operation.
190      *
191      * @param controlType Indicates the {@link WsPiPControlType} component in pip control panel.
192      * @param status Indicates the {@link WsPiPControlStatus} required state of specified component.
193      * @return Returns WSError::WS_OK if called success, otherwise failed.
194      */
195     virtual WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status) = 0;
196     virtual WSError UpdateDisplayId(uint64_t displayId) = 0;
197     virtual void NotifyDisplayMove(DisplayId from, DisplayId to) = 0;
198     virtual WSError SwitchFreeMultiWindow(bool enable) = 0;
199     virtual WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj) = 0;
PcAppInPadNormalClose()200     virtual WSError PcAppInPadNormalClose()
201     {
202         return WSError::WS_OK;
203     }
NotifyCompatibleModePropertyChange(const sptr<CompatibleModeProperty> property)204     virtual WSError NotifyCompatibleModePropertyChange(const sptr<CompatibleModeProperty> property)
205     {
206         return WSError::WS_OK;
207     }
208     virtual void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) = 0;
NotifySessionFullScreen(bool fullScreen)209     virtual void NotifySessionFullScreen(bool fullScreen) {}
210 
211     // **Non** IPC interface
NotifyBackpressedEvent(bool & isConsumed)212     virtual void NotifyBackpressedEvent(bool& isConsumed) {}
NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)213     virtual void NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) {}
214     virtual void NotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
215         bool notifyInputMethod = true) {}
NotifyFocusActiveEvent(bool isFocusActive)216     virtual void NotifyFocusActiveEvent(bool isFocusActive) {}
NotifyFocusStateEvent(bool focusState)217     virtual void NotifyFocusStateEvent(bool focusState) {}
NotifyOnKeyPreImeEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent)218     virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) {return false;}
GetPersistentId()219     virtual int32_t GetPersistentId() const
220     {
221         return -1;
222     }
NotifyDensityFollowHost(bool isFollowHost,float densityValue)223     virtual WSError NotifyDensityFollowHost(bool isFollowHost, float densityValue)
224     {
225         return WSError::WS_OK;
226     }
NotifyAccessibilityHoverEvent(float pointX,float pointY,int32_t sourceType,int32_t eventType,int64_t timeMs)227     virtual WSError NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
228         int64_t timeMs)
229     {
230         return WSError::WS_OK;
231     }
NotifyAccessibilityChildTreeRegister(uint32_t windowId,int32_t treeId,int64_t accessibilityId)232     virtual WSError NotifyAccessibilityChildTreeRegister(
233         uint32_t windowId, int32_t treeId, int64_t accessibilityId)
234     {
235         return WSError::WS_OK;
236     }
NotifyAccessibilityChildTreeUnregister()237     virtual WSError NotifyAccessibilityChildTreeUnregister()
238     {
239         return WSError::WS_OK;
240     }
NotifyAccessibilityDumpChildInfo(const std::vector<std::string> & params,std::vector<std::string> & info)241     virtual WSError NotifyAccessibilityDumpChildInfo(
242         const std::vector<std::string>& params, std::vector<std::string>& info)
243     {
244         return WSError::WS_OK;
245     }
246 
NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo & keyboardPanelInfo)247     virtual void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) {}
248 
NotifyDumpInfo(const std::vector<std::string> & params,std::vector<std::string> & info)249     virtual WSError NotifyDumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
250     {
251         return WSError::WS_OK;
252     }
253 
254     virtual WSError LinkKeyFrameCanvasNode(std::shared_ptr<RSCanvasNode>& rsCanvasNode) = 0;
255     virtual WSError SetKeyFramePolicy(KeyFramePolicy& keyFramePolicy) = 0;
256 
257     virtual WSError SetSplitButtonVisible(bool isVisible) = 0;
258 
259     virtual WSError SetEnableDragBySystem(bool dragEnable) = 0;
260 
261     virtual WSError SetDragActivated(bool dragActivated) = 0;
262 
SetFullScreenWaterfallMode(bool isWaterfallMode)263     virtual WSError SetFullScreenWaterfallMode(bool isWaterfallMode) { return WSError::WS_DO_NOTHING; }
SetSupportEnterWaterfallMode(bool isSupportEnter)264     virtual WSError SetSupportEnterWaterfallMode(bool isSupportEnter) { return WSError::WS_DO_NOTHING; }
265     virtual WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) = 0;
266     virtual void NotifyWindowCrossAxisChange(CrossAxisState state) = 0;
NotifyWindowAttachStateChange(bool isAttach)267     virtual WSError NotifyWindowAttachStateChange(bool isAttach) { return WSError::WS_DO_NOTHING; }
NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo & keyboardPanelInfo)268     virtual void NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo& keyboardPanelInfo) {}
NotifyKeyboardAnimationWillBegin(const KeyboardAnimationInfo & keyboardAnimationInfo,const std::shared_ptr<RSTransaction> & rsTransaction)269     virtual void NotifyKeyboardAnimationWillBegin(const KeyboardAnimationInfo& keyboardAnimationInfo,
270         const std::shared_ptr<RSTransaction>& rsTransaction) {};
NotifyTargetRotationInfo(OrientationInfo & info)271     virtual WSError NotifyTargetRotationInfo(OrientationInfo& info) { return WSError::WS_DO_NOTHING; }
NotifyRotationChange(const RotationChangeInfo & rotationChangeInfo)272     virtual RotationChangeResult NotifyRotationChange(const RotationChangeInfo& rotationChangeInfo)
273     {
274         return { RectType::RELATIVE_TO_SCREEN, { 0, 0, 0, 0, } };
275     }
276     virtual WSError SetCurrentRotation(int32_t currentRotation) = 0;
277     virtual WSError NotifyAppForceLandscapeConfigUpdated() = 0;
278     virtual WSError NotifyAppHookWindowInfoUpdated() = 0;
CloseSpecificScene()279     virtual WSError CloseSpecificScene() { return WSError::WS_DO_NOTHING; }
280 
281     /**
282      * @brief Send fb event to client.
283      *
284      * Send the fb event to client. Such as close, click events.
285      *
286      * @param action Indicates the action name.
287      * @return Returns WSError::WS_OK if called success, otherwise failed.
288      */
289     virtual WSError SendFbActionEvent(const std::string& action) = 0;
290 };
291 } // namespace OHOS::Rosen
292 #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
293