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     virtual WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
44         const SceneAnimationConfig& config = { nullptr, ROTATE_ANIMATION_DURATION }) = 0;
45     virtual void UpdateDensity() = 0;
46     virtual WSError UpdateOrientation() = 0;
47     virtual WSError HandleBackEvent() = 0;
48     virtual WSError MarkProcessed(int32_t eventId) = 0;
49     virtual WSError UpdateFocus(bool isFocused) = 0;
50     virtual WSError NotifyDestroy() = 0;
51 
52     /**
53      * @brief Notify client to close the existing pip window.
54      *
55      * Called when starting pip but there is already a pip window foreground. The previous one will be destroyed if
56      * the new starting request has a higher priority.
57      *
58      * @return Returns WSError::WS_OK if called success, otherwise failed.
59      */
60     virtual WSError NotifyCloseExistPipWindow() = 0;
61     virtual WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) = 0;
62     virtual WSErrorCode NotifyTransferComponentDataSync(const AAFwk::WantParams& wantParams,
63         AAFwk::WantParams& reWantParams) = 0;
64     virtual void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info,
65                                               const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) = 0;
66     virtual WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) = 0;
67     virtual void NotifyScreenshot() = 0;
68     virtual void DumpSessionElementInfo(const std::vector<std::string>& params) = 0;
69     virtual WSError NotifyTouchOutside() = 0;
70     virtual WSError NotifyWindowVisibility(bool isVisible) = 0;
71     virtual WSError UpdateWindowMode(WindowMode mode) = 0;
72     virtual void NotifyForegroundInteractiveStatus(bool interactive) = 0;
73     virtual WSError UpdateMaximizeMode(MaximizeMode mode) = 0;
74     virtual void NotifySessionForeground(uint32_t reason, bool withAnimation) = 0;
75     virtual void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) = 0;
76     virtual WSError UpdateTitleInTargetPos(bool isShow, int32_t height) = 0;
77     virtual void NotifyTransformChange(const Transform& transform) = 0;
78     virtual WSError NotifyDialogStateChange(bool isForeground) = 0;
79 
80     /**
81      * @brief Set pip event to client.
82      *
83      * Set the pip event to client. Such as close, restore, destroy events.
84      *
85      * @param action Indicates the action name.
86      * @param status Indicates the status num.
87      * @return Returns WSError::WS_OK if called success, otherwise failed.
88      */
89     virtual WSError SetPipActionEvent(const std::string& action, int32_t status) = 0;
90 
91     /**
92      * @brief Set the media control event to client.
93      *
94      * Set the media control event to client. The event is from pip control panel operation.
95      *
96      * @param controlType Indicates the {@link WsPiPControlType} component in pip control panel.
97      * @param status Indicates the {@link WsPiPControlStatus} required state of specified component.
98      * @return Returns WSError::WS_OK if called success, otherwise failed.
99      */
100     virtual WSError SetPiPControlEvent(WsPiPControlType controlType, WsPiPControlStatus status) = 0;
101     virtual WSError UpdateDisplayId(uint64_t displayId) = 0;
102     virtual void NotifyDisplayMove(DisplayId from, DisplayId to) = 0;
103     virtual WSError SwitchFreeMultiWindow(bool enable) = 0;
NotifyCompatibleModeEnableInPad(bool enable)104     virtual WSError NotifyCompatibleModeEnableInPad(bool enable)
105     {
106         return WSError::WS_OK;
107     }
108     virtual void SetUniqueVirtualPixelRatio(bool useUniqueDensity, float virtualPixelRatio) = 0;
NotifySessionFullScreen(bool fullScreen)109     virtual void NotifySessionFullScreen(bool fullScreen) {}
110     virtual WSError GetUIContentRemoteObj(sptr<IRemoteObject>& uiContentRemoteObj) = 0;
111 
112     // **Non** IPC interface
NotifyBackpressedEvent(bool & isConsumed)113     virtual void NotifyBackpressedEvent(bool& isConsumed) {}
NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)114     virtual void NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) {}
115     virtual void NotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
116         bool notifyInputMethod = true) {}
NotifyFocusActiveEvent(bool isFocusActive)117     virtual void NotifyFocusActiveEvent(bool isFocusActive) {}
NotifyFocusStateEvent(bool focusState)118     virtual void NotifyFocusStateEvent(bool focusState) {}
NotifyOnKeyPreImeEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent)119     virtual bool NotifyOnKeyPreImeEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) {return false;}
GetPersistentId()120     virtual int32_t GetPersistentId() const
121     {
122         return -1;
123     }
NotifyDensityFollowHost(bool isFollowHost,float densityValue)124     virtual WSError NotifyDensityFollowHost(bool isFollowHost, float densityValue)
125     {
126         return WSError::WS_OK;
127     }
NotifyAccessibilityHoverEvent(float pointX,float pointY,int32_t sourceType,int32_t eventType,int64_t timeMs)128     virtual WSError NotifyAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
129         int64_t timeMs)
130     {
131         return WSError::WS_OK;
132     }
NotifyAccessibilityChildTreeRegister(uint32_t windowId,int32_t treeId,int64_t accessibilityId)133     virtual WSError NotifyAccessibilityChildTreeRegister(
134         uint32_t windowId, int32_t treeId, int64_t accessibilityId)
135     {
136         return WSError::WS_OK;
137     }
NotifyAccessibilityChildTreeUnregister()138     virtual WSError NotifyAccessibilityChildTreeUnregister()
139     {
140         return WSError::WS_OK;
141     }
NotifyAccessibilityDumpChildInfo(const std::vector<std::string> & params,std::vector<std::string> & info)142     virtual WSError NotifyAccessibilityDumpChildInfo(
143         const std::vector<std::string>& params, std::vector<std::string>& info)
144     {
145         return WSError::WS_OK;
146     }
147 
NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo & keyboardPanelInfo)148     virtual void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) {}
NotifyDumpInfo(const std::vector<std::string> & params,std::vector<std::string> & info)149     virtual WSError NotifyDumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info)
150     {
151         return WSError::WS_OK;
152     }
153     virtual WSError SetEnableDragBySystem(bool dragEnable) = 0;
154 };
155 } // namespace OHOS::Rosen
156 #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H
157