1 /*
2  * Copyright (c) 2021-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_ABILITY_RUNTIME_MISSION_LISTENER_INTERFACE_H
17 #define OHOS_ABILITY_RUNTIME_MISSION_LISTENER_INTERFACE_H
18 
19 #include "iremote_broker.h"
20 #ifdef SUPPORT_GRAPHICS
21 #include "pixel_map.h"
22 #endif
23 
24 namespace OHOS {
25 namespace AAFwk {
26 /**
27  * @class IMissionListener
28  * IMissionListener is used to notify caller ability that connect or disconnect is complete.
29  */
30 class IMissionListener : public OHOS::IRemoteBroker {
31 public:
32     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.MissionListener");
33 
34     /**
35      * @brief When a mission is created, AbilityMs notifies the listener of the mission id
36      *
37      * @param missionId, mission Id.
38      */
39     virtual void OnMissionCreated(int32_t missionId) = 0;
40 
41     /**
42      * @brief When a mission is destroyed, AbilityMs notifies the listener of the mission id
43      *
44      * @param missionId, mission Id.
45      */
46     virtual void OnMissionDestroyed(int32_t missionId) = 0;
47 
48     /**
49      * @brief When the snapshot of a mission changes, AbilityMs notifies the listener of the mission id
50      *
51      * @param missionId, mission Id.
52      */
53     virtual void OnMissionSnapshotChanged(int32_t missionId) = 0;
54 
55     /**
56      * @brief When a mission is moved to front, AbilityMs notifies the listener of the mission id
57      *
58      * @param missionId, mission Id.
59      */
60     virtual void OnMissionMovedToFront(int32_t missionId) = 0;
61 
62     /**
63      * @brief When the ability focused, AbilityMs notifies the listener of the mission id
64      *
65      * @param missionId, mission Id.
66      */
OnMissionFocused(int32_t missionId)67     virtual void OnMissionFocused(int32_t missionId) {};
68 
69     /**
70      * @brief hen the ability unfocused, AbilityMs notifies the listener of the mission id
71      *
72      * @param missionId, mission Id.
73      */
OnMissionUnfocused(int32_t missionId)74     virtual void OnMissionUnfocused(int32_t missionId) {};
75 
76 #ifdef SUPPORT_GRAPHICS
77     /**
78      * @brief Called when a mission has changed it's icon.
79      *
80      * @param missionId, mission Id.
81      * @param icon, mission icon.
82      */
83     virtual void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0;
84 #endif
85 
86     /**
87      * @brief When a mission is closed, AbilityMs notifies the listener of the mission id
88      *
89      * @param missionId, mission Id.
90      */
91     virtual void OnMissionClosed(int32_t missionId) = 0;
92 
93     /**
94      * @brief When a mission's label was changed, AbilityMs notifies the listener of the mission id
95      *
96      * @param missionId, mission Id.
97      */
98     virtual void OnMissionLabelUpdated(int32_t missionId) = 0;
99 
100     enum MissionListenerCmd {
101         // ipc id for OnMissionCreated
102         ON_MISSION_CREATED = 0,
103 
104         // ipc id for OnMissionDestroyed
105         ON_MISSION_DESTROYED,
106 
107         // ipc id for OnMissionSnapshotChanged
108         ON_MISSION_SNAPSHOT_CHANGED,
109 
110         // ipc id for OnMissionMovedToFront
111         ON_MISSION_MOVED_TO_FRONT,
112 
113         // ipc id for OnMissionIconUpdated
114         ON_MISSION_ICON_UPDATED,
115 
116         // ipc id for OnMissionClosed
117         ON_MISSION_CLOSED,
118 
119         // ipc id for OnMissionLabelUpdated
120         ON_MISSION_LABEL_UPDATED,
121 
122         // ipc id for OnMissionFocused
123         ON_MISSION_FOCUSED,
124 
125         // ipc id for OnMissionUnfocused
126         ON_MISSION_UNFOCUSED,
127 
128         // maximum of enum
129         MISSION_LINSTENER_CMD_MAX
130     };
131 };
132 }  // namespace AAFwk
133 }  // namespace OHOS
134 #endif  // OHOS_ABILITY_RUNTIME_MISSION_LISTENER_INTERFACE_H
135