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 class SessionProxy : public IRemoteProxy<ISession> {
26 public:
SessionProxy(const sptr<IRemoteObject> & impl)27     explicit SessionProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<ISession>(impl) {}
28     virtual ~SessionProxy() = default;
29 
30     WSError Foreground(sptr<WindowSessionProperty> property, bool isFromClient = false,
31         const std::string& identityToken = "") override;
32     WSError Background(bool isFromClient = false, const std::string& identityToken = "") override;
33     WSError Disconnect(bool isFromClient = false, const std::string& identityToken = "") override;
34     WSError Show(sptr<WindowSessionProperty> property) override;
35     WSError Hide() override;
36     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 = "") override;
40     WSError DrawingCompleted() override;
41     WSError ChangeSessionVisibilityWithStatusBar(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
42         bool visible) override;
43     WSError PendingSessionActivation(const sptr<AAFwk::SessionInfo> abilitySessionInfo) override;
44     bool WriteAbilitySessionInfoBasic(MessageParcel& data, const sptr<AAFwk::SessionInfo> abilitySessionInfo);
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 SyncSessionEvent(SessionEvent event) override;
50     WSError OnLayoutFullScreenChange(bool isLayoutFullScreen) override;
51     WSError OnDefaultDensityEnabled(bool isDefaultDensityEnabled) override;
52     WSError OnTitleAndDockHoverShowChange(bool isTitleHoverShown = true,
53         bool isDockHoverShown = true) override;
54     WSError OnRestoreMainWindow() override;
55     WSError OnSetWindowRectAutoSave(bool enabled) override;
56     WSError RaiseToAppTop() override;
57     WSError UpdateSessionRect(const WSRect& rect, const SizeChangeReason reason, bool isGlobal = false,
58         bool isFromMoveToGlobal = false) override;
59     WMError GetGlobalScaledRect(Rect& globalScaledRect) override;
60     WSError UpdateClientRect(const WSRect& rect) override;
61     WSError OnNeedAvoid(bool status) override;
62     AvoidArea GetAvoidAreaByType(AvoidAreaType type) override;
63     WSError GetAllAvoidAreas(std::map<AvoidAreaType, AvoidArea>& avoidAreas) override;
64     WSError RequestSessionBack(bool needMoveToBackground) override;
65     WSError MarkProcessed(int32_t eventId) override;
66     WSError SetGlobalMaximizeMode(MaximizeMode mode) override;
67     WSError GetGlobalMaximizeMode(MaximizeMode& mode) override;
68     WSError SetAspectRatio(float ratio) override;
69     WSError UpdateWindowAnimationFlag(bool needDefaultAnimationFlag) override;
70     WSError SetLandscapeMultiWindow(bool isLandscapeMultiWindow) override;
71     WSError UpdateWindowSceneAfterCustomAnimation(bool isAdd) override;
72     WSError RaiseAboveTarget(int32_t subWindowId) override;
73     WSError RaiseAppMainWindowToTop() override;
74 
75     WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override;
76     WSError TransferExtensionData(const AAFwk::WantParams& wantParams) override;
77     WSError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
78         int64_t uiExtensionIdLevel) override;
79     void NotifySyncOn() override;
80     void NotifyAsyncOn() override;
81     void NotifyExtensionDied() override;
82     void NotifyExtensionTimeout(int32_t errorCode) override;
83     void TriggerBindModalUIExtension() override;
84     void NotifyExtensionEventAsync(uint32_t notifyEvent) override;
85 
86     void NotifyPiPWindowPrepareClose() override;
87     WSError UpdatePiPRect(const Rect& rect, SizeChangeReason reason) override;
88     WSError UpdatePiPControlStatus(WsPiPControlType controlType, WsPiPControlStatus status) override;
89     WSError SetAutoStartPiP(bool isAutoStart, uint32_t priority) override;
90 
91     WSError ProcessPointDownSession(int32_t posX, int32_t posY) override;
92     WSError SendPointEventForMoveDrag(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
93     bool IsStartMoving() override;
94     WSError UpdateRectChangeListenerRegistered(bool isRegister) override;
95     void SetCallingSessionId(uint32_t callingSessionId) override;
96     void SetCustomDecorHeight(int32_t height) override;
97     WSError AdjustKeyboardLayout(const KeyboardLayoutParams& params) override;
98     WMError UpdateSessionPropertyByAction(const sptr<WindowSessionProperty>& property,
99         WSPropertyChangeAction action) override;
100     WMError GetAppForceLandscapeConfig(AppForceLandscapeConfig& config) override;
101     WSError NotifyFrameLayoutFinishFromApp(bool notifyListener, const WSRect& rect) override;
102     WSError SetDialogSessionBackGestureEnabled(bool isEnabled) override;
103     WMError SetSystemWindowEnableDrag(bool enableDrag) override;
104     void NotifyExtensionDetachToDisplay() override;
105     WSError RequestFocus(bool isFocused) override;
106 
107     /*
108      * Gesture Back
109      */
110     WMError SetGestureBackEnabled(bool isEnabled) override;
111 
112     WSError NotifySubModalTypeChange(SubWindowModalType subWindowModalType) override;
113     WSError NotifyMainModalTypeChange(bool isModal) override;
114 
115     /*
116      * Starting Window
117      */
118     WSError RemoveStartingWindow() override;
119 
120 private:
121     static inline BrokerDelegator<SessionProxy> delegator_;
122 };
123 } // namespace OHOS::Rosen
124 
125 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_PROXY_H
126