• 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 #include "session_router_stack_listener.h"
31 
32 namespace OHOS::Media {
33 class PixelMap;
34 } // namespace OHOS::Media
35 
36 namespace OHOS::Rosen {
37 using ISessionListener = AAFwk::IMissionListener;
38 using SessionInfoBean = AAFwk::MissionInfo;
39 using SessionSnapshot = AAFwk::MissionSnapshot;
40 class ISceneSessionManagerLite : public OHOS::Rosen::IWindowManagerLite {
41 public:
42     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISceneSessionManagerLite");
43 
44     enum class SceneSessionManagerLiteMessage : uint32_t {
45         TRANS_ID_SET_SESSION_LABEL,
46         TRANS_ID_SET_SESSION_ICON,
47         TRANS_ID_IS_VALID_SESSION_IDS,
48         TRANS_ID_PENDING_SESSION_TO_FOREGROUND,
49         TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR,
50         TRANS_ID_GET_FOCUS_SESSION_TOKEN,
51         TRANS_ID_GET_FOCUS_SESSION_ELEMENT,
52         TRANS_ID_REGISTER_SESSION_LISTENER,
53         TRANS_ID_UNREGISTER_SESSION_LISTENER,
54         TRANS_ID_GET_MISSION_INFOS,
55         TRANS_ID_GET_MISSION_INFO_BY_ID,
56         TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID,
57         TRANS_ID_TERMINATE_SESSION_NEW,
58         TRANS_ID_GET_SESSION_SNAPSHOT,
59         TRANS_ID_SET_SESSION_CONTINUE_STATE,
60         TRANS_ID_CLEAR_SESSION,
61         TRANS_ID_CLEAR_ALL_SESSIONS,
62         TRANS_ID_LOCK_SESSION,
63         TRANS_ID_UNLOCK_SESSION,
64         TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND,
65         TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND,
66         //window manager message
67         TRANS_ID_GET_FOCUS_SESSION_INFO,
68         TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT = 22,
69         TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT,
70         TRANS_ID_GET_WINDOW_INFO,
71         TRANS_ID_CHECK_WINDOW_ID,
72         TRANS_ID_LIST_WINDOW_INFO,
73         TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID,
74         TRANS_ID_GET_WINDOW_MODE_TYPE,
75         TRANS_ID_GET_TOPN_MAIN_WINDOW_INFO,
76         TRANS_ID_GET_ALL_MAIN_WINDOW_INFO,
77         TRANS_ID_CLEAR_MAIN_SESSIONS,
78         TRANS_ID_RAISE_WINDOW_TO_TOP,
79         TRANS_ID_REGISTER_COLLABORATOR,
80         TRANS_ID_UNREGISTER_COLLABORATOR,
81         TRANS_ID_GET_WINDOW_STYLE_TYPE,
82         TRANS_ID_TERMINATE_SESSION_BY_PERSISTENT_ID,
83         TRANS_ID_CLOSE_TARGET_FLOAT_WINDOW,
84         TRANS_ID_CLOSE_TARGET_PIP_WINDOW,
85         TRANS_ID_GET_CURRENT_PIP_WINDOW_INFO,
86         TRANS_ID_GET_MAIN_WINDOW_STATES_BY_PID,
87         TRANS_ID_GET_ROOT_MAIN_WINDOW_ID,
88         TRANS_ID_UI_EXTENSION_CREATION_CHECK,
89         TRANS_ID_NOTIFY_APP_USE_CONTROL_LIST,
90         TRANS_ID_MINIMIZE_MAIN_SESSION,
91         TRANS_ID_LOCK_SESSION_BY_ABILITY_INFO,
92         TRANS_ID_HAS_FLOAT_FOREGROUND,
93         TRANS_ID_GET_CALLING_WINDOW_INFO,
94         TRANS_ID_REGISTER_SESSION_LIFECYCLE_LISTENER_BY_IDS,
95         TRANS_ID_REGISTER_SESSION_LIFECYCLE_LISTENER_BY_BUNDLES,
96         TRANS_ID_UNREGISTER_SESSION_LIFECYCLE_LISTENER,
97         TRANS_ID_GET_RECENT_MAIN_SESSION_INFO_LIST,
98         TRANS_ID_PENDING_SESSION_TO_BACKGROUND_BY_PERSISTENTID,
99         TRANS_ID_CREATE_NEW_INSTANCE_KEY,
100         TRANS_ID_GET_ROUTER_STACK_INFO,
101         TRANS_ID_REMOVE_INSTANCE_KEY,
102         TRANS_ID_TRANSFER_SESSION_TO_TARGET_SCREEN,
103         TRANS_ID_PENDING_SESSION_TO_BACKGROUND,
104         TRANS_ID_UPDATE_KIOSK_APP_LIST,
105         TRANS_ID_ENTER_KIOSK_MODE,
106         TRANS_ID_EXIT_KIOSK_MODE,
107         TRANS_ID_UPDATE_WINDOW_MODE_BY_ID_FOR_UI_TEST,
108         TRANS_ID_SEND_POINTER_EVENT_FOR_HOVER,
109         TRANS_ID_SET_START_WINDOW_BACKGROUND_COLOR,
110         TRANS_IS_SET_IMAGE_FOR_RECENT,
111         TRANS_ID_IS_FOCUS_WINDOW_PARENT,
112     };
113 
114     /*
115      * Window Layout
116      */
UpdateWindowModeByIdForUITest(int32_t windowId,int32_t updateMode)117     virtual WMError UpdateWindowModeByIdForUITest(int32_t windowId, int32_t updateMode) { return WMError::WM_OK; }
118 
119     /*
120      * Window Lifecycle
121      */
122     virtual WSError PendingSessionToForeground(const sptr<IRemoteObject>& token) = 0;
123     virtual WSError PendingSessionToBackground(const sptr<IRemoteObject>& token, const BackgroundParams& params) = 0;
124     virtual WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
125         bool shouldBackToCaller = true) = 0;
126     virtual WSError MoveSessionsToForeground(const std::vector<std::int32_t>& sessionIds, int32_t topSessionId) = 0;
127     virtual WSError MoveSessionsToBackground(const std::vector<std::int32_t>& sessionIds,
128         std::vector<std::int32_t>& result) = 0;
129     virtual WSError TerminateSessionNew(
130         const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) = 0;
131     virtual WSError ClearSession(int32_t persistentId) = 0;
132     virtual WSError ClearAllSessions() = 0;
133     virtual WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) = 0;
134     virtual WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) = 0;
135     virtual WSError RegisterIAbilityManagerCollaborator(int32_t type,
136         const sptr<AAFwk::IAbilityManagerCollaborator>& impl) = 0;
137     virtual WSError UnregisterIAbilityManagerCollaborator(int32_t type) = 0;
138     virtual WSError RegisterSessionListener(const sptr<ISessionListener>& listener, bool isRecover = false) = 0;
139     virtual WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
140     virtual WSError GetSessionInfos(const std::string& deviceId,
141                                     int32_t numMax, std::vector<SessionInfoBean>& sessionInfos) = 0;
142     virtual WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) = 0;
143     virtual WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
144         SessionInfoBean& sessionInfo) = 0;
145     virtual WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) = 0;
146     virtual WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) = 0;
147     virtual WSError GetFocusSessionToken(sptr<IRemoteObject>& token, DisplayId displayId = DEFAULT_DISPLAY_ID) = 0;
148     virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element,
149         DisplayId displayId = DEFAULT_DISPLAY_ID) = 0;
IsFocusWindowParent(const sptr<IRemoteObject> & token,bool & isParent)150     virtual WSError IsFocusWindowParent(const sptr<IRemoteObject>& token, bool& isParent) { return WSError::WS_OK; }
151     virtual WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
152                                        SessionSnapshot& snapshot, bool isLowResolution) = 0;
153     virtual WSError LockSession(int32_t sessionId) = 0;
154     virtual WSError UnlockSession(int32_t sessionId) = 0;
155     virtual WSError RaiseWindowToTop(int32_t persistentId) = 0;
156     virtual WMError GetWindowStyleType(WindowStyleType& windowStyleType) = 0;
157     virtual WMError ListWindowInfo(const WindowInfoOption& windowInfoOption,
158         std::vector<sptr<WindowInfo>>& infos) = 0;
159 
160     /**
161      * @brief Application Control SA Notification Window Control Application Information
162      *
163      * The application control SA notifies whether the window application is controlled or not.
164      * When the window main program starts, the application control information is fully notified,
165      * and only incremental information is notified after full notification.
166      *
167      * @param type controls the application type (caller), such as application lock
168      * @param userId User ID
169      * @param controlList Control Application Information List
170      * @return Successful call returns WSError: WS-OK, otherwise it indicates failure
171      * @permission application requires SA permission and ohos.permission.WRITE_APP_LOCK permission
172      */
173     virtual WSError NotifyAppUseControlList(
174         ControlAppType type, int32_t userId, const std::vector<AppUseControlInfo>& controlList) = 0;
175 
176     /**
177      * @brief Obtains main window state list by pid
178      * @caller SA
179      * @permission SA permission
180      *
181      * @param pid Target pid
182      * @param windowStates Window state list
183      */
184     virtual WSError GetMainWindowStatesByPid(int32_t pid, std::vector<MainWindowState>& windowStates) = 0;
185 
186     /**
187      * @brief Minimize All Main Sessions of An Application.
188      *
189      * This function is used to minimize the main sessions of the application with the same bundleName and appIndex.
190      * The invoker must be an SA or SystemApp and have the related permission.
191      *
192      * @param bundleName bundle name of the application that need to be minimized.
193      * @param appIndex appIndex of the target application
194      * @param userId User ID
195      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
196      * @permission application requires SA permission or SystemApp permission
197      */
198     virtual WMError MinimizeMainSession(const std::string& bundleName, int32_t appIndex, int32_t userId) = 0;
199 
200     /**
201      * @brief Lock or unlock a session in recent tasks.
202      *
203      * This function lock or unlock the session in recent tasks.
204      * The invoker must be an SA or SystemApp and have the ohos.permission.MANAGE_MISSIONS permission.
205      *
206      * @param AbilityInfoBase abilityInfo of the session that needed to be locked or locked.
207      * @param isLock isLock of the session that needed to be locked or unlocked.
208      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
209      * @permission application requires ohos.permission.MANAGE_MISSIONS permission and
210      * SA permission or SystemApp permission
211      */
212     virtual WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, bool isLock) = 0;
213 
214     /**
215      * @brief Query if there is float type window foreground of an abilityToken
216      *
217      * This function is used to query if there is float type window foreground of an ability
218      *
219      * @caller SA
220      * @permission SA permission
221      *
222      * @param abilityToken token of ability
223      * @param hasOrNot result for output
224      */
225     virtual WMError HasFloatingWindowForeground(const sptr<IRemoteObject>& abilityToken,
226         bool& hasOrNot) = 0;
227 
228     /**
229      * @brief Register a main session lifecycle listener for specific persistentIds
230      *
231      * This function is used to register a main session lifecycle listener for a list of specific persistentIds.
232      * The listener will be notified when lifecycle events occur for the specified persistentId
233      *
234      * @caller SA
235      * @permission SA permission
236      *
237      * @param listener The session lifecycle listener to be registered
238      * @param persistentIdList The list of persistentId for which the listener should be registered
239      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
240      */
241     virtual WMError RegisterSessionLifecycleListenerByIds(const sptr<ISessionLifecycleListener>& listener,
242         const std::vector<int32_t>& persistentIdList) = 0;
243 
244     /**
245      * @brief Register a session lifecycle listener for specific bundles
246      *
247      * This function is used to register a session lifecycle listener for a list of specific bundles.
248      * The listener will be notified when lifecycle events occur for the specified bundles
249      *
250      * @caller SA
251      * @permission SA permission
252      *
253      * @param listener The session lifecycle listener to be registered
254      * @param bundleNameList The list of bundle for which the listener should be registered
255      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
256      */
257     virtual WMError RegisterSessionLifecycleListenerByBundles(const sptr<ISessionLifecycleListener>& listener,
258         const std::vector<std::string>& bundleNameList) = 0;
259 
260     /**
261      * @brief Unregister a session lifecycle listener
262      *
263      * This function is used to unregister a session lifecycle listener.
264      * The unregistered listener will no longer receive notifications about session lifecycle events.
265      *
266      * @caller SA
267      * @permission SA permission
268      *
269      * @param listener The session lifecycle listener to be unregistered
270      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
271      */
272     virtual WMError UnregisterSessionLifecycleListener(const sptr<ISessionLifecycleListener>& listener) = 0;
273 
274     /**
275      * @brief Get an ordered recent main session info list
276      *
277      * This function is used to get an ordered recent main session info list
278      *
279      * @caller SA or SystemApp
280      * @permission SA permission or SystemApp permission
281      *
282      * @param recentSessionInfoList the sessionInfo list of recent main sessions
283      * @return Successful call returns WSError: WS-OK, otherwise it indicates failure
284      */
285     virtual WSError GetRecentMainSessionInfoList(std::vector<RecentSessionInfo>& recentSessionInfoList) = 0;
286 
287     /**
288      * @brief pending session to background
289      *
290      * This function is used to request session to background by persistentid
291      *
292      * @caller SA or SystemApp
293      * @permission application requires ohos.permission.MANAGE_MISSIONS permission and
294      * SA permission or SystemApp permission
295      *
296      * @param persistentId the session of persistentId
297      * @param shouldBackToCaller should back to caller
298      * @return Successful call returns WSError: WS-OK, otherwise it indicates failure
299      */
300     virtual WSError PendingSessionToBackgroundByPersistentId(const int32_t persistentId,
301         bool shouldBackToCaller = true) { return WSError::WS_OK; };
302 
303     /**
304      * @brief Create a new instanceKey of a specific bundle
305      *
306      * This function is used to create a new instanceKey
307      * If the number of instanceKey reaches max limit, then return the last created instanceKey
308      *
309      * @caller SA or SystemApp
310      * @permission SA permission or SystemApp permission
311      *
312      * @param bundleName the bundleName of the new instanceKey needs to be created
313      * @param instanceKey will be assigned the instanceKey just created
314      * @return Successful call returns WSError: WM-OK, otherwise it indicates failure
315      */
316     virtual WMError CreateNewInstanceKey(const std::string& bundleName, std::string& instanceKey) = 0;
317 
318     /**
319      * @brief Get the router stack by persistentId
320      *
321      * This function is used to get the router stack by persistentId from arkui
322      *
323      * @caller SA or SystemApp
324      * @permission SA permission or SystemApp permission
325      *
326      * @param persistentId the id of session
327      * @param listener the callback when get router stack from arkui
328      * @return Successful call returns WSError: WM-OK, otherwise it indicates failure
329      */
330     virtual WMError GetRouterStackInfo(int32_t persistentId, const sptr<ISessionRouterStackListener>& listener) = 0;
331 
332     /**
333      * @brief Remove a instanceKey of a specific bundle
334      *
335      * This function is used to remove a instanceKey of a specific bundle
336      *
337      * @caller SA or SystemApp
338      * @permission SA permission or SystemApp permission
339      *
340      * @param bundleName the bundleName of the instanceKey to be removed
341      * @param instanceKey the instanceKey that needs to be removed
342      * @return Successful call returns WSError: WM-OK, otherwise it indicates failure
343      */
344     virtual WMError RemoveInstanceKey(const std::string& bundleName, const std::string& instanceKey) = 0;
345 
346     /**
347      * @brief Transfer a session to the target screen
348      *
349      * This function is used to transfer a session to the target screen
350      *
351      * @caller SA or SystemApp
352      * @permission SA permission or SystemApp permission
353      *
354      * @param info The session infomation to be transferred
355      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
356      */
357     virtual WMError TransferSessionToTargetScreen(const TransferSessionInfo& info) = 0;
358 
359     /**
360      * @brief Update the list of apps which can be used in kiosk mode
361      *
362      * This function is used to update the list of apps which can be used in kiosk mode
363      *
364      * @caller SA or SystemApp
365      * @permission SA permission or SystemApp permission
366      *
367      * @param kioskAppList the list of apps which can be used in kiosk mode
368      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
369      */
UpdateKioskAppList(const std::vector<std::string> & kioskAppList)370     virtual WMError UpdateKioskAppList(const std::vector<std::string>& kioskAppList) { return WMError::WM_OK; }
371 
372     /**
373      * @brief Notify that mission enters kiosk mode
374      *
375      * This function is used to notify that mission enters kiosk mode
376      *
377      * @caller SA or SystemApp
378      * @permission SA permission or SystemApp permission
379      *
380      * @param token the abilitytoken of the mission entered kiosk mode
381      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
382      */
EnterKioskMode(const sptr<IRemoteObject> & token)383     virtual WMError EnterKioskMode(const sptr<IRemoteObject>& token) { return WMError::WM_OK; }
384 
385     /**
386      * @brief Notify exit kiosk mode
387      *
388      * This function is used to notify exit kiosk mode
389      *
390      * @caller SA or SystemApp
391      * @permission SA permission or SystemApp permission
392      *
393      * @return Successful call returns WMError: WM-OK, otherwise it indicates failure
394      */
ExitKioskMode(const sptr<IRemoteObject> & token)395     virtual WMError ExitKioskMode(const sptr<IRemoteObject>& token) { return WMError::WM_OK; }
396 
397     /**
398      * @brief Send pointer event for hover.
399      *
400      * This function is used to send pointer event for hover
401      *
402      * @caller SA
403      * @permission SA permission
404      *
405      * @param pointerEvent The pointer event for hover
406      * @return Successful call returns WSError: WS-OK, otherwise it indicates failure
407      */
SendPointerEventForHover(const std::shared_ptr<MMI::PointerEvent> & pointerEvent)408     virtual WSError SendPointerEventForHover(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
409         { return WSError::WS_OK; }
410 };
411 } // namespace OHOS::Rosen
412 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H
413