• 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_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 #include "session_lifecycle_listener_interface.h"
30 namespace OHOS::Media {
31 class PixelMap;
32 } // namespace OHOS::Media
33 
34 namespace OHOS::Rosen {
35 using ISessionListener = AAFwk::IMissionListener;
36 using SessionInfoBean = AAFwk::MissionInfo;
37 using SessionSnapshot = AAFwk::MissionSnapshot;
38 class ISceneSessionManagerLite : public OHOS::Rosen::IWindowManagerLite {
39 public:
40     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISceneSessionManagerLite");
41 
42     enum class SceneSessionManagerLiteMessage : uint32_t {
43         TRANS_ID_SET_SESSION_LABEL,
44         TRANS_ID_SET_SESSION_ICON,
45         TRANS_ID_IS_VALID_SESSION_IDS,
46         TRANS_ID_PENDING_SESSION_TO_FOREGROUND,
47         TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR,
48         TRANS_ID_GET_FOCUS_SESSION_TOKEN,
49         TRANS_ID_GET_FOCUS_SESSION_ELEMENT,
50         TRANS_ID_REGISTER_SESSION_LISTENER,
51         TRANS_ID_UNREGISTER_SESSION_LISTENER,
52         TRANS_ID_GET_MISSION_INFOS,
53         TRANS_ID_GET_MISSION_INFO_BY_ID,
54         TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID,
55         TRANS_ID_TERMINATE_SESSION_NEW,
56         TRANS_ID_GET_SESSION_SNAPSHOT,
57         TRANS_ID_SET_SESSION_CONTINUE_STATE,
58         TRANS_ID_CLEAR_SESSION,
59         TRANS_ID_CLEAR_ALL_SESSIONS,
60         TRANS_ID_LOCK_SESSION,
61         TRANS_ID_UNLOCK_SESSION,
62         TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND,
63         TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND,
64         //window manager message
65         TRANS_ID_GET_FOCUS_SESSION_INFO,
66         TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT = 22,
67         TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT,
68         TRANS_ID_GET_WINDOW_INFO,
69         TRANS_ID_CHECK_WINDOW_ID,
70         TRANS_ID_LIST_WINDOW_INFO,
71         TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
72         TRANS_ID_GET_WINDOW_MODE_TYPE,
73         TRANS_ID_GET_TOPN_MAIN_WINDOW_INFO,
74         TRANS_ID_GET_ALL_MAIN_WINDOW_INFO,
75         TRANS_ID_CLEAR_MAIN_SESSIONS,
76         TRANS_ID_RAISE_WINDOW_TO_TOP,
77         TRANS_ID_REGISTER_COLLABORATOR,
78         TRANS_ID_UNREGISTER_COLLABORATOR,
79         TRANS_ID_GET_WINDOW_STYLE_TYPE,
80         TRANS_ID_TERMINATE_SESSION_BY_PERSISTENT_ID,
81         TRANS_ID_CLOSE_TARGET_FLOAT_WINDOW,
82         TRANS_ID_CLOSE_TARGET_PIP_WINDOW,
83         TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO,
84         TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID,
85         TRANS_ID_GET_ROOT_MAIN_WINDOW_ID,
86         TRANS_ID_UI_EXTENSION_CREATION_CHECK,
87         TRANS_ID_NOTIFY_APP_USE_CONTROL_LIST,
88         TRANS_ID_MINIMIZE_MAIN_SESSION,
89         TRANS_ID_LOCK_SESSION_BY_ABILITY_INFO,
90         TRANS_ID_HAS_FLOAT_FOREGROUND,
91         TRANS_ID_GET_CALLING_WINDOW_INFO,
92         TRANS_ID_REGISTER_SESSION_LIFECYCLE_LISTENER_BY_IDS,
93         TRANS_ID_REGISTER_SESSION_LIFECYCLE_LISTENER_BY_BUNDLES,
94         TRANS_ID_UNREGISTER_SESSION_LIFECYCLE_LISTENER,
95     };
96 
97     /*
98      * Window Lifecycle
99      */
100     virtual WSError PendingSessionToForeground(const sptr<IRemoteObject>& token) = 0;
101     virtual WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
102         bool shouldBackToCaller = true) = 0;
103     virtual WSError MoveSessionsToForeground(const std::vector<std::int32_t>& sessionIds, int32_t topSessionId) = 0;
104     virtual WSError MoveSessionsToBackground(const std::vector<std::int32_t>& sessionIds,
105         std::vector<std::int32_t>& result) = 0;
106     virtual WSError TerminateSessionNew(
107         const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) = 0;
108     virtual WSError ClearSession(int32_t persistentId) = 0;
109     virtual WSError ClearAllSessions() = 0;
110     virtual WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) = 0;
111     virtual WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) = 0;
112     virtual WSError RegisterIAbilityManagerCollaborator(int32_t type,
113         const sptr<AAFwk::IAbilityManagerCollaborator>& impl) = 0;
114     virtual WSError UnregisterIAbilityManagerCollaborator(int32_t type) = 0;
115     virtual WSError RegisterSessionListener(const sptr<ISessionListener>& listener, bool isRecover = false) = 0;
116     virtual WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
117     virtual WSError GetSessionInfos(const std::string& deviceId,
118                                     int32_t numMax, std::vector<SessionInfoBean>& sessionInfos) = 0;
119     virtual WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) = 0;
120     virtual WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
121         SessionInfoBean& sessionInfo) = 0;
122     virtual WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) = 0;
123     virtual WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) = 0;
124     virtual WSError GetFocusSessionToken(sptr<IRemoteObject>& token, DisplayId displayId = DEFAULT_DISPLAY_ID) = 0;
125     virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element,
126         DisplayId displayId = DEFAULT_DISPLAY_ID) = 0;
127     virtual WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
128                                        SessionSnapshot& snapshot, bool isLowResolution) = 0;
129     virtual WSError LockSession(int32_t sessionId) = 0;
130     virtual WSError UnlockSession(int32_t sessionId) = 0;
131     virtual WSError RaiseWindowToTop(int32_t persistentId) = 0;
132     virtual WMError GetWindowStyleType(WindowStyleType& windowStyleType) = 0;
133     virtual WMError ListWindowInfo(const WindowInfoOption& windowInfoOption,
134         std::vector<sptr<WindowInfo>>& infos) = 0;
135 
136     /**
137      * @brief Application Control SA Notification Window Control Application Information
138      *
139      * The application control SA notifies whether the window application is controlled or not.
140      * When the window main program starts, the application control information is fully notified,
141      * and only incremental information is notified after full notification.
142      *
143      * @param type controls the application type (caller), such as application lock
144      * @param userId User ID
145      * @param controlList Control Application Information List
146      * @return Successful call returns WSError: WS-OK, otherwise it indicates failure
147      * @permission application requires SA permission and ohos.permission.WRITE_APP_LOCK permission
148      */
149     virtual WSError NotifyAppUseControlList(
150         ControlAppType type, int32_t userId, const std::vector<AppUseControlInfo>& controlList) = 0;
151 
152     /**
153      * @brief Obtains main window state list by pid
154      * @caller SA
155      * @permission SA permission
156      *
157      * @param pid Target pid
158      * @param windowStates Window state list
159      */
160     virtual WSError GetMainWindowStatesByPid(int32_t pid, std::vector<MainWindowState>& windowStates) = 0;
161 
162     /**
163      * @brief Minimize All Main Sessions of An Application.
164      *
165      * This function is used to minimize the main sessions of the application with the same bundleName and appIndex.
166      * The invoker must be an SA or SystemApp and have the related permission.
167      *
168      * @param bundleName bundle name of the application that need to be minimized.
169      * @param appIndex appIndex of the target application
170      * @param userId User ID
171      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
172      * @permission application requires SA permission or SystemApp permission
173      */
174     virtual WMError MinimizeMainSession(const std::string& bundleName, int32_t appIndex, int32_t userId) = 0;
175 
176     /**
177      * @brief Lock or unlock a session in recent tasks.
178      *
179      * This function lock or unlock the session in recent tasks.
180      * The invoker must be an SA or SystemApp and have the ohos.permission.MANAGE_MISSIONS permission.
181      *
182      * @param AbilityInfoBase abilityInfo of the session that needed to be locked or locked.
183      * @param isLock isLock of the session that needed to be locked or unlocked.
184      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
185      * @permission application requires ohos.permission.MANAGE_MISSIONS permission and
186      * SA permission or SystemApp permission
187      */
188     virtual WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, bool isLock) = 0;
189 
190     /**
191      * @brief Query if there is float type window foreground of an abilityToken
192      *
193      * This function is used to query if there is float type window foreground of an ability
194      *
195      * @caller SA
196      * @permission SA permission
197      *
198      * @param abilityToken token of ability
199      * @param hasOrNot result for output
200      */
201     virtual WMError HasFloatingWindowForeground(const sptr<IRemoteObject>& abilityToken,
202         bool& hasOrNot) = 0;
203 
204     /**
205      * @brief Register a main session lifecycle listener for specific persistentIds
206      *
207      * This function is used to register a main session lifecycle listener for a list of specific persistentIds.
208      * The listener will be notified when lifecycle events occur for the specified persistentId
209      *
210      * @caller SA
211      * @permission SA permission
212      *
213      * @param listener The session lifecycle listener to be registered
214      * @param persistentIdList The list of persistentId for which the listener should be registered
215      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
216      */
217     virtual WMError RegisterSessionLifecycleListenerByIds(const sptr<ISessionLifecycleListener>& listener,
218         const std::vector<int32_t>& persistentIdList) = 0;
219 
220     /**
221      * @brief Register a session lifecycle listener for specific bundles
222      *
223      * This function is used to register a session lifecycle listener for a list of specific bundles.
224      * The listener will be notified when lifecycle events occur for the specified bundles
225      *
226      * @caller SA
227      * @permission SA permission
228      *
229      * @param listener The session lifecycle listener to be registered
230      * @param bundleNameList The list of bundle for which the listener should be registered
231      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
232      */
233     virtual WMError RegisterSessionLifecycleListenerByBundles(const sptr<ISessionLifecycleListener>& listener,
234         const std::vector<std::string>& bundleNameList) = 0;
235 
236     /**
237      * @brief Unregister a session lifecycle listener
238      *
239      * This function is used to unregister a session lifecycle listener.
240      * The unregistered listener will no longer receive notifications about session lifecycle events.
241      *
242      * @caller SA
243      * @permission SA permission
244      *
245      * @param listener The session lifecycle listener to be unregistered
246      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
247      */
248     virtual WMError UnregisterSessionLifecycleListener(const sptr<ISessionLifecycleListener>& listener) = 0;
249 };
250 } // namespace OHOS::Rosen
251 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H
252