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_PROXY_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SESSION_PROXY_H
18 
19 #include <iremote_proxy.h>
20 
21 #include "session/host/include/zidl/session_interface.h"
22 #include "ws_common.h"
23 
24 namespace OHOS::Rosen {
25 enum class SessionInterfaceCode;
26 class SessionProxy : public IRemoteProxy<ISession> {
27 public:
SessionProxy(const sptr<IRemoteObject>& impl)28     explicit SessionProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<ISession>(impl) {}
29     virtual ~SessionProxy() = default;
30 
31     WSError Foreground(sptr<WindowSessionProperty> property, bool isFromClient = false,
32         const std::string& identityToken = "") override;
33     WSError Background(bool isFromClient = false, const std::string& identityToken = "") override;
34     WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override;
35     WSError Show(sptr<WindowSessionProperty> property) override;
36     WSError Hide() override;
37     WSError Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
38         const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
39         sptr<WindowSessionProperty> property = nullptr, sptr<IRemoteObject> token = nullptr,
40         const std::string& identityToken = "") override;
41     WSError DrawingCompleted() override;
42     WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
43         bool visible) override;
44     WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo) override;
45     WSError TerminateSession(const sptr<AAFwk::SessionInfo> abilitySessionInfo) override;
46     WSError NotifySessionException(
47         const sptr<AAFwk::SessionInfo> abilitySessionInfo, bool needRemoveSession = false) override;
48     WSError OnSessionEvent(SessionEvent event) override;
49     WSError OnSystemSessionEvent(SessionEvent event) override;
50     WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) override;
51     WSError OnRestoreMainWindow() override;
52     WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true,
53         bool isDockHoverShown = true) override;
54     WSError RaiseToAppTop() override;
55     WSError UpdateSessionRect(const WSRect& rect, const SizeChangeReason reason, bool isGlobal = false) override;
56     WSError UpdateClientRect(const WSRect& rect) override;
57     WSError OnNeedAvoid(bool status) override;
58     AvoidArea GetAvoidAreaByType(AvoidAreaType type) override;
59     WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) override;
60     WSError RequestSessionBack(bool needMoveToBackground) override;
61     WSError MarkProcessed(int32_t eventId) override;
62     WSError SetGlobalMaximizeMode(MaximizeMode mode) override;
63     WSError GetGlobalMaximizeMode(MaximizeMode& mode) override;
64     WSError SetAspectRatio(float ratio) override;
65     WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override;
66     WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override;
67     WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override;
68     WSError RaiseAboveTarget(int32_t subWindowId) override;
69     WSError RaiseAppMainWindowToTop() override;
70 
71     WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override;
72     WSError TransferExtensionData(const AAFwk::WantParams& wantParams) override;
73     WSError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
74         int64_t uiExtensionIdLevel) override;
75     void NotifySyncOn() override;
76     void NotifyAsyncOn() override;
77     void NotifyExtensionDied() override;
78     void NotifyExtensionTimeout(int32_t errorCode) override;
79     void TriggerBindModalUIExtension() override;
80 
81     void NotifyPiPWindowPrepareClose() override;
82     WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override;
83     WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status) override;
84     WSError SetAutoStartPiP(bool isAutoStart) override;
85     WSError ProcessPointDownSession(int32_t posX, int32_t posY) override;
86     WSError SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
87     WSError GetStartMoveFlag(bool& isMoving) override;
88     WSError UpdateRectChangeListenerRegistered(bool isRegister) override;
89     WSError SetKeyboardSessionGravity(SessionGravity gravity, uint32_t percent) override;
90     void SetCallingSessionId(uint32_t callingSessionId) override;
91     void SetCustomDecorHeight(int32_t height) override;
92     WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) override;
93     WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
94         WSPropertyChangeAction action) override;
95     WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) override;
96     int32_t GetStatusBarHeight() override;
97     WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect) override;
98     WSError SetDialogSessionBackGestureEnabled(bool isEnabled) override;
99     WMError SetSystemWindowEnableDrag(bool enableDrag) override;
100     WSError RequestFocus(bool isFocused) override;
101     WSError SetFocusableOnShow(bool isFocusableOnShow) override;
102     void NotifyExtensionEventAsync(uint32_t notifyEvent) override;
103     WSError OnSessionModalTypeChange(SubWindowModalType subWindowModalType) override;
104 
105     /*
106      * Gesture Back
107      */
108     WMError SetGestureBackEnabled(bool isEnabled) override;
109 
110 private:
111     static inline BrokerDelegator<SessionProxy> delegator_;
112 };
113 } // namespace OHOS::Rosen
114 
115 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_PROXY_H
116