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_MANAGER_LITE_INTERFACE_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H
18 
19 #include <iremote_broker.h>
20 #include "common/include/window_session_property.h"
21 #include "iability_manager_collaborator.h"
22 #include "interfaces/include/ws_common.h"
23 #include "interfaces/include/ws_common_inner.h"
24 #include "mission_info.h"
25 #include "mission_listener_interface.h"
26 #include "mission_snapshot.h"
27 #include "session_info.h"
28 #include "zidl/window_manager_lite_interface.h"
29 namespace OHOS::Media {
30 class PixelMap;
31 } // namespace OHOS::Media
32 
33 namespace OHOS::Rosen {
34 using ISessionListener = AAFwk::IMissionListener;
35 using SessionInfoBean = AAFwk::MissionInfo;
36 using SessionSnapshot = AAFwk::MissionSnapshot;
37 class ISceneSessionManagerLite : public OHOS::Rosen::IWindowManagerLite {
38 public:
39     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISceneSessionManagerLite");
40 
41     enum class SceneSessionManagerLiteMessage : uint32_t {
42         TRANS_ID_SET_SESSION_LABEL,
43         TRANS_ID_SET_SESSION_ICON,
44         TRANS_ID_IS_VALID_SESSION_IDS,
45         TRANS_ID_PENDING_SESSION_TO_FOREGROUND,
46         TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR,
47         TRANS_ID_GET_FOCUS_SESSION_TOKEN,
48         TRANS_ID_GET_FOCUS_SESSION_ELEMENT,
49         TRANS_ID_REGISTER_SESSION_LISTENER,
50         TRANS_ID_UNREGISTER_SESSION_LISTENER,
51         TRANS_ID_GET_MISSION_INFOS,
52         TRANS_ID_GET_MISSION_INFO_BY_ID,
53         TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID,
54         TRANS_ID_TERMINATE_SESSION_NEW,
55         TRANS_ID_GET_SESSION_SNAPSHOT,
56         TRANS_ID_SET_SESSION_CONTINUE_STATE,
57         TRANS_ID_CLEAR_SESSION,
58         TRANS_ID_CLEAR_ALL_SESSIONS,
59         TRANS_ID_LOCK_SESSION,
60         TRANS_ID_UNLOCK_SESSION,
61         TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND,
62         TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND,
63         //window manager message
64         TRANS_ID_GET_FOCUS_SESSION_INFO,
65         TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT = 22,
66         TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT,
67         TRANS_ID_GET_WINDOW_INFO,
68         TRANS_ID_CHECK_WINDOW_ID,
69         TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
70         TRANS_ID_GET_WINDOW_MODE_TYPE,
71         TRANS_ID_RAISE_WINDOW_TO_TOP,
72         TRANS_ID_GET_TOPN_MAIN_WINDOW_INFO,
73         TRANS_ID_REGISTER_COLLABORATOR,
74         TRANS_ID_UNREGISTER_COLLABORATOR,
75         TRANS_ID_GET_ALL_MAIN_WINDOW_INFO,
76         TRANS_ID_CLEAR_MAIN_SESSIONS,
77         TRANS_ID_GET_WINDOW_STYLE_TYPE,
78         TRANS_ID_TERMINATE_SESSION_BY_PERSISTENT_ID,
79         TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID,
80         TRANS_ID_CLOSE_TARGET_FLOAT_WINDOW,
81         TRANS_ID_CLOSE_TARGET_PIP_WINDOW,
82         TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO,
83         TRANS_ID_NOTIFY_APP_USE_CONTROL_LIST,
84         TRANS_ID_GET_ROOT_MAIN_WINDOW_ID,
85         TRANS_ID_UI_EXTENSION_CREATION_CHECK,
86     };
87 
88     virtual WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) = 0;
89     virtual WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) = 0;
90     virtual WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) = 0;
91     virtual WSError PendingSessionToForeground(const sptr<IRemoteObject>& token) = 0;
92     virtual WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
93         bool shouldBackToCaller = true) = 0;
94     virtual WSError GetFocusSessionToken(sptr<IRemoteObject>& token) = 0;
95     virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element) = 0;
96     virtual WSError RegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
97     virtual WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
98     virtual WSError GetSessionInfos(const std::string& deviceId,
99                                     int32_t numMax, std::vector<SessionInfoBean>& sessionInfos) = 0;
100     virtual WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) = 0;
101     virtual WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
102         SessionInfoBean& sessionInfo) = 0;
103     virtual WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) = 0;
104     virtual WSError TerminateSessionNew(
105         const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) = 0;
106     virtual WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
107                                        SessionSnapshot& snapshot, bool isLowResolution) = 0;
108     virtual WSError ClearSession(int32_t persistentId) = 0;
109     virtual WSError ClearAllSessions() = 0;
110     virtual WSError LockSession(int32_t sessionId) = 0;
111     virtual WSError UnlockSession(int32_t sessionId) = 0;
112     virtual WSError MoveSessionsToForeground(const std::vector<std::int32_t>& sessionIds, int32_t topSessionId) = 0;
113     virtual WSError MoveSessionsToBackground(const std::vector<std::int32_t>& sessionIds,
114         std::vector<std::int32_t>& result) = 0;
115     virtual WSError RaiseWindowToTop(int32_t persistentId) = 0;
116     virtual WSError RegisterIAbilityManagerCollaborator(int32_t type,
117         const sptr<AAFwk::IAbilityManagerCollaborator>& impl) = 0;
118     virtual WSError UnregisterIAbilityManagerCollaborator(int32_t type) = 0;
119     virtual WMError GetWindowStyleType(WindowStyleType& windowStyleType) = 0;
120 
121     /**
122      * @brief Application Control SA Notification Window Control Application Information
123      *
124      * The application control SA notifies whether the window application is controlled or not.
125      * When the window main program starts, the application control information is fully notified,
126      * and only incremental information is notified after full notification.
127      *
128      * @param type controls the application type (caller), such as application lock
129      * @param userId User ID
130      * @param controlList Control Application Information List
131      * @return Successful call returns WSError: WS-OK, otherwise it indicates failure
132      * @permission application requires SA permission and ohos.permission.WRITE_APP_LOCK permission
133      */
134     virtual WSError NotifyAppUseControlList(
135         ControlAppType type, int32_t userId, const std::vector<AppUseControlInfo>& controlList) = 0;
136 
137     /**
138      * @brief Obtains main window state list by pid
139      * @caller SA
140      * @permission SA permission
141      *
142      * @param pid Target pid
143      * @param windowStates Window state list
144      */
145     virtual WSError GetMainWindowStatesByPid(int32_t pid, std::vector<MainWindowState>& windowStates) = 0;
146 };
147 } // namespace OHOS::Rosen
148 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H
149