• 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 
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 
37 class ISessionStage : public IRemoteBroker {
38 public:
39     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISessionStage");
40 
41     // IPC interface
42     virtual WSError SetActive(bool active) = 0;
43 
44     /**
45      * @brief update the window rect.
46      *
47      * This function provides the ability for applications to update window rect.
48      *
49      * @param rect the position and size of the window.
50      * @param reason the update reason.
51      * @param config the animation parameter configuration.
52      * @return Returns WSError::WS_OK if called success, otherwise failed.
53      */
54     virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
55         const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION },
56         const std::map<AvoidAreaType, AvoidArea>& avoidAreas = {}) = 0;
57     virtual void UpdateDensity() = 0;
58     virtual WSError UpdateOrientation() = 0;
59 
60     /**
61      * @brief Update session viewport config.
62      *
63      * Called when viewport configuration parameters such as density or orientation changes, update to the UIExtension
64      * process.
65      *
66      * @param config Indicates the {@link SessionViewportConfig} viewport configuration parameters.
67      * @return Returns WSError::WS_OK if called success, otherwise failed .
68      */
UpdateSessionViewportConfig(const SessionViewportConfig & config)69     virtual WSError UpdateSessionViewportConfig(const SessionViewportConfig& config)
70     {
71         return WSError::WS_OK;
72     };
SendExtensionData(MessageParcel & data,MessageParcel & reply,MessageOption & option)73     virtual WSError SendExtensionData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
74     {
75         return WSError::WS_OK;
76     }
77     virtual WSError HandleBackEvent() = 0;
78     virtual WSError MarkProcessed(int32_t eventId) = 0;
79 
80     /**
81      * @brief update the focus
82      *
83      * Notify window session to update focus status.
84      *
85      * @param isFocused set isFocused.
86      * @return Returns WSError::WS_OK if called success, otherwise failed.
87      */
88     virtual WSError UpdateFocus(bool isFocused) = 0;
89     virtual WSError NotifyDestroy() = 0;
90     virtual WSError NotifyHighlightChange(bool isHighlight) = 0;
91 
92     /**
93      * @brief Notify client to close the existing pip window.
94      *
95      * Called when starting pip but there is already a pip window foreground. The previous one will be destroyed if
96      * the new starting request has a higher priority.
97      *
98      * @return Returns WSError::WS_OK if called success, otherwise failed.
99      */
100     virtual WSError NotifyCloseExistPipWindow() = 0;
101     virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) = 0;
102     virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams,
103         AAFwk::WantParams& reWantParams) = 0;
104     virtual void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,
105                                               const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) = 0;
106     virtual WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) = 0;
107     virtual void NotifyScreenshot() = 0;
108     virtual void DumpSessionElementInfo(const std::vector<std::string>& params) = 0;
109     virtual WSError NotifyTouchOutside() = 0;
110     virtual WSError NotifyWindowVisibility(bool isVisible) = 0;
111     virtual WSError UpdateWindowMode(WindowMode mode) = 0;
112     virtual void NotifyForegroundInteractiveStatus(bool interactive) = 0;
113     virtual WSError UpdateMaximizeMode(MaximizeMode mode) = 0;
114     virtual void NotifySessionForeground(uint32_t reason, bool withAnimation) = 0;
115     virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0;
116     virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0;
117 
118     /**
119      * @brief Notify transform.
120      *
121      * Notify transform when window changed.
122      *
123      * @param transform transform to change.
124      */
125     virtual void NotifyTransformChange(const Transform& transform) = 0;
126     virtual WSError NotifyDialogStateChange(bool isForeground) = 0;
127 
128     /**
129      * @brief Notify single hand transform.
130      *
131      * Notify singleHandTransform when single hand mode changed.
132      *
133      * @param singleHandTransform transform to change.
134      */
135     virtual void NotifySingleHandTransformChange(const SingleHandTransform& singleHandTransform) = 0;
136 
137     /**
138      * @brief Set pip event to client.
139      *
140      * Set the pip event to client. Such as close, restore, destroy events.
141      *
142      * @param action Indicates the action name.
143      * @param status Indicates the status num.
144      * @return Returns WSError::WS_OK if called success, otherwise failed.
145      */
146     virtual WSError SetPipActionEvent(const std::string& action, int32_t status) = 0;
147 
148     /**
149      * @brief notify pip size to client.
150      *
151      * Notify the pip size to client. including width, height and scale.
152      *
153      * @param width Indicates the size width.
154      * @param height Indicates the size height.
155      * @param scale Indicates the size scale.
156      * @return Returns WSError::WS_OK if called success, otherwise failed.
157      */
158     virtual WSError NotifyPipWindowSizeChange(double width, double height, double scale) = 0;
159 
160     /**
161      * @brief Set the media control event to client.
162      *
163      * Set the media control event to client. The event is from pip control panel operation.
164      *
165      * @param controlType Indicates the {@link WsPiPControlType} component in pip control panel.
166      * @param status Indicates the {@link WsPiPControlStatus} required state of specified component.
167      * @return Returns WSError::WS_OK if called success, otherwise failed.
168      */
169     virtual WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status) = 0;
170     virtual WSError UpdateDisplayId(uint64_t displayId) = 0;
171     virtual void NotifyDisplayMove(DisplayId from, DisplayId to) = 0;
172     virtual WSError SwitchFreeMultiWindow(bool enable) = 0;
173     virtual WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj) = 0;
CompatibleFullScreenRecover()174     virtual WSError CompatibleFullScreenRecover()
175     {
176         return WSError::WS_OK;
177     }
CompatibleFullScreenMinimize()178     virtual WSError CompatibleFullScreenMinimize()
179     {
180         return WSError::WS_OK;
181     }
CompatibleFullScreenClose()182     virtual WSError CompatibleFullScreenClose()
183     {
184         return WSError::WS_OK;
185     }
PcAppInPadNormalClose()186     virtual WSError PcAppInPadNormalClose()
187     {
188         return WSError::WS_OK;
189     }
NotifyCompatibleModeEnableInPad(bool enable)190     virtual WSError NotifyCompatibleModeEnableInPad(bool enable)
191     {
192         return WSError::WS_OK;
193     }
194     virtual void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) = 0;
NotifySessionFullScreen(bool fullScreen)195     virtual void NotifySessionFullScreen(bool fullScreen) {}
196 
197     // **Non** IPC interface
NotifyBackpressedEvent(bool & isConsumed)198     virtual void NotifyBackpressedEvent(bool& isConsumed) {}
NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)199     virtual void NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) {}
200     virtual void NotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
201         bool notifyInputMethod = true) {}
NotifyFocusActiveEvent(bool isFocusActive)202     virtual void NotifyFocusActiveEvent(bool isFocusActive) {}
NotifyFocusStateEvent(bool focusState)203     virtual void NotifyFocusStateEvent(bool focusState) {}
NotifyOnKeyPreImeEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent)204     virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) {return false;}
GetPersistentId()205     virtual int32_t GetPersistentId() const
206     {
207         return -1;
208     }
NotifyDensityFollowHost(bool isFollowHost,float densityValue)209     virtual WSError NotifyDensityFollowHost(bool isFollowHost, float densityValue)
210     {
211         return WSError::WS_OK;
212     }
NotifyAccessibilityHoverEvent(float pointX,float pointY,int32_t sourceType,int32_t eventType,int64_t timeMs)213     virtual WSError NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
214         int64_t timeMs)
215     {
216         return WSError::WS_OK;
217     }
NotifyAccessibilityChildTreeRegister(uint32_t windowId,int32_t treeId,int64_t accessibilityId)218     virtual WSError NotifyAccessibilityChildTreeRegister(
219         uint32_t windowId, int32_t treeId, int64_t accessibilityId)
220     {
221         return WSError::WS_OK;
222     }
NotifyAccessibilityChildTreeUnregister()223     virtual WSError NotifyAccessibilityChildTreeUnregister()
224     {
225         return WSError::WS_OK;
226     }
NotifyAccessibilityDumpChildInfo(const std::vector<std::string> & params,std::vector<std::string> & info)227     virtual WSError NotifyAccessibilityDumpChildInfo(
228         const std::vector<std::string>& params, std::vector<std::string>& info)
229     {
230         return WSError::WS_OK;
231     }
232 
NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo & keyboardPanelInfo)233     virtual void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) {}
234 
NotifyDumpInfo(const std::vector<std::string> & params,std::vector<std::string> & info)235     virtual WSError NotifyDumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
236     {
237         return WSError::WS_OK;
238     }
239     virtual WSError SetSplitButtonVisible(bool isVisible) = 0;
240 
241     virtual WSError SetEnableDragBySystem(bool dragEnable) = 0;
242 
243     virtual WSError SetDragActivated(bool dragActivated) = 0;
244 
SetFullScreenWaterfallMode(bool isWaterfallMode)245     virtual WSError SetFullScreenWaterfallMode(bool isWaterfallMode) { return WSError::WS_DO_NOTHING; }
SetSupportEnterWaterfallMode(bool isSupportEnter)246     virtual WSError SetSupportEnterWaterfallMode(bool isSupportEnter) { return WSError::WS_DO_NOTHING; }
247     virtual WSError SendContainerModalEvent(const std::string& eventName, const std::string& eventValue) = 0;
248     virtual void NotifyWindowCrossAxisChange(CrossAxisState state) = 0;
NotifyWindowAttachStateChange(bool isAttach)249     virtual WSError NotifyWindowAttachStateChange(bool isAttach) { return WSError::WS_DO_NOTHING; }
NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo & keyboardPanelInfo)250     virtual void NotifyKeyboardAnimationCompleted(const KeyboardPanelInfo& keyboardPanelInfo) {}
251 };
252 } // namespace OHOS::Rosen
253 #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
254