• 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 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         TRANS_ID_MINIMIZE_MAIN_SESSION,
87         TRANS_ID_HAS_FLOAT_FOREGROUND,
88         TRANS_ID_LOCK_SESSION_BY_ABILITY_INFO,
89     };
90 
91     virtual WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) = 0;
92     virtual WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) = 0;
93     virtual WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) = 0;
94     virtual WSError PendingSessionToForeground(const sptr<IRemoteObject>& token) = 0;
95     virtual WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
96         bool shouldBackToCaller = true) = 0;
97     virtual WSError GetFocusSessionToken(sptr<IRemoteObject>& token) = 0;
98     virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element) = 0;
99     virtual WSError RegisterSessionListener(const sptr<ISessionListener>& listener, bool isRecover = false) = 0;
100     virtual WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) = 0;
101     virtual WSError GetSessionInfos(const std::string& deviceId,
102                                     int32_t numMax, std::vector<SessionInfoBean>& sessionInfos) = 0;
103     virtual WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) = 0;
104     virtual WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
105         SessionInfoBean& sessionInfo) = 0;
106     virtual WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) = 0;
107     virtual WSError TerminateSessionNew(
108         const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) = 0;
109     virtual WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
110                                        SessionSnapshot& snapshot, bool isLowResolution) = 0;
111     virtual WSError ClearSession(int32_t persistentId) = 0;
112     virtual WSError ClearAllSessions() = 0;
113     virtual WSError LockSession(int32_t sessionId) = 0;
114     virtual WSError UnlockSession(int32_t sessionId) = 0;
115     virtual WSError MoveSessionsToForeground(const std::vector<std::int32_t>& sessionIds, int32_t topSessionId) = 0;
116     virtual WSError MoveSessionsToBackground(const std::vector<std::int32_t>& sessionIds,
117         std::vector<std::int32_t>& result) = 0;
118     virtual WSError RaiseWindowToTop(int32_t persistentId) = 0;
119     virtual WSError RegisterIAbilityManagerCollaborator(int32_t type,
120         const sptr<AAFwk::IAbilityManagerCollaborator>& impl) = 0;
121     virtual WSError UnregisterIAbilityManagerCollaborator(int32_t type) = 0;
122     virtual WMError GetWindowStyleType(WindowStyleType& windowStyleType) = 0;
123 
124     /**
125      * @brief Application Control SA Notification Window Control Application Information
126      *
127      * The application control SA notifies whether the window application is controlled or not.
128      * When the window main program starts, the application control information is fully notified,
129      * and only incremental information is notified after full notification.
130      *
131      * @param type controls the application type (caller), such as application lock
132      * @param userId User ID
133      * @param controlList Control Application Information List
134      * @return Successful call returns WSError: WS-OK, otherwise it indicates failure
135      * @permission application requires SA permission and ohos.permission.WRITE_APP_LOCK permission
136      */
137     virtual WSError NotifyAppUseControlList(
138         ControlAppType type, int32_t userId, const std::vector<AppUseControlInfo>& controlList) = 0;
139 
140     /**
141      * @brief Obtains main window state list by pid
142      * @caller SA
143      * @permission SA permission
144      *
145      * @param pid Target pid
146      * @param windowStates Window state list
147      */
148     virtual WSError GetMainWindowStatesByPid(int32_t pid, std::vector<MainWindowState>& windowStates) = 0;
149 
150     /**
151      * @brief Minimize All Main Sessions of An Application.
152      *
153      * This function is used to minimize the main sessions of the application with the same bundleName and appIndex.
154      * The invoker must be an SA or SystemApp and have the related permission.
155      *
156      * @param bundleName bundle name of the application that need to be minimized.
157      * @param appIndex appIndex of the target application
158      * @param userId User ID
159      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
160      * @permission application requires SA permission or SystemApp permission
161      */
162     virtual WMError MinimizeMainSession(const std::string& bundleName, int32_t appIndex, int32_t userId) = 0;
163 
164     /**
165      * @brief Query if there is float type window foreground of an abilityToken
166      *
167      * This function is used to query if there is float type window foreground of an ability
168      *
169      * @caller SA
170      * @permission SA permission
171      *
172      * @param abilityToken token of ability
173      * @param hasOrNot result for output
174      */
175     virtual WMError HasFloatingWindowForeground(const sptr<IRemoteObject>& abilityToken,
176         bool& hasOrNot) = 0;
177 
178     /**
179      * @brief Lock or unlock a session in recent tasks.
180      *
181      * This function lock or unlock the session in recent tasks.
182      * The invoker must be an SA or SystemApp and have the ohos.permission.MANAGE_MISSIONS permission.
183      *
184      * @param AbilityInfoBase abilityInfo of the session that needed to be locked or locked.
185      * @param isLock isLock of the session that needed to be locked or unlocked.
186      * @return Successful call returns WMError: WS-OK, otherwise it indicates failure
187      * @permission application requires ohos.permission.MANAGE_MISSIONS permission and
188      * SA permission or SystemApp permission
189      */
190     virtual WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, bool isLock) = 0;
191 };
192 } // namespace OHOS::Rosen
193 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_INTERFACE_H
194