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