• 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 #include "mission_listener_stub.h"
17 
18 #include "hilog_tag_wrapper.h"
19 #ifdef SUPPORT_SCREEN
20 #include "pixel_map.h"
21 #endif //SUPPORT_SCREEN
22 
23 namespace OHOS {
24 namespace AAFwk {
MissionListenerStub()25 MissionListenerStub::MissionListenerStub() {}
26 
OnMissionCreatedInner(MessageParcel & data,MessageParcel & reply)27 int MissionListenerStub::OnMissionCreatedInner(MessageParcel &data, MessageParcel &reply)
28 {
29     auto missionId = data.ReadInt32();
30     OnMissionCreated(missionId);
31     return NO_ERROR;
32 }
33 
OnMissionDestroyedInner(MessageParcel & data,MessageParcel & reply)34 int MissionListenerStub::OnMissionDestroyedInner(MessageParcel &data, MessageParcel &reply)
35 {
36     auto missionId = data.ReadInt32();
37     OnMissionDestroyed(missionId);
38     return NO_ERROR;
39 }
40 
OnMissionSnapshotChangedInner(MessageParcel & data,MessageParcel & reply)41 int MissionListenerStub::OnMissionSnapshotChangedInner(MessageParcel &data, MessageParcel &reply)
42 {
43     auto missionId = data.ReadInt32();
44     OnMissionSnapshotChanged(missionId);
45     return NO_ERROR;
46 }
47 
OnMissionMovedToFrontInner(MessageParcel & data,MessageParcel & reply)48 int MissionListenerStub::OnMissionMovedToFrontInner(MessageParcel &data, MessageParcel &reply)
49 {
50     auto missionId = data.ReadInt32();
51     OnMissionMovedToFront(missionId);
52     return NO_ERROR;
53 }
54 
OnMissionMovedToBackgroundInner(MessageParcel & data,MessageParcel & reply)55 int MissionListenerStub::OnMissionMovedToBackgroundInner(MessageParcel &data, MessageParcel &reply)
56 {
57     auto missionId = data.ReadInt32();
58     OnMissionMovedToBackground(missionId);
59     return NO_ERROR;
60 }
61 
OnMissionFocusedInner(MessageParcel & data,MessageParcel & reply)62 int MissionListenerStub::OnMissionFocusedInner(MessageParcel &data, MessageParcel &reply)
63 {
64     auto missionId = data.ReadInt32();
65     OnMissionFocused(missionId);
66     return NO_ERROR;
67 }
68 
OnMissionUnfocusedInner(MessageParcel & data,MessageParcel & reply)69 int MissionListenerStub::OnMissionUnfocusedInner(MessageParcel &data, MessageParcel &reply)
70 {
71     auto missionId = data.ReadInt32();
72     OnMissionUnfocused(missionId);
73     return NO_ERROR;
74 }
75 
OnMissionIconUpdatedInner(MessageParcel & data,MessageParcel & reply)76 int MissionListenerStub::OnMissionIconUpdatedInner(MessageParcel &data, MessageParcel &reply)
77 {
78 #ifdef SUPPORT_SCREEN
79     auto missionId = data.ReadInt32();
80     std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
81     OnMissionIconUpdated(missionId, icon);
82     return NO_ERROR;
83 #else
84     TAG_LOGE(AAFwkTag::ABILITYMGR, "not support OnMissionIconUpdated");
85     return ERR_INVALID_STATE;
86 #endif
87 }
88 
OnMissionClosedInner(MessageParcel & data,MessageParcel & reply)89 int MissionListenerStub::OnMissionClosedInner(MessageParcel &data, MessageParcel &reply)
90 {
91     OnMissionClosed(data.ReadInt32());
92     return NO_ERROR;
93 }
94 
OnMissionLabelUpdatedInner(MessageParcel & data,MessageParcel & reply)95 int MissionListenerStub::OnMissionLabelUpdatedInner(MessageParcel &data, MessageParcel &reply)
96 {
97     OnMissionLabelUpdated(data.ReadInt32());
98     return NO_ERROR;
99 }
100 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)101 int MissionListenerStub::OnRemoteRequest(
102     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
103 {
104     std::u16string descriptor = MissionListenerStub::GetDescriptor();
105     std::u16string remoteDescriptor = data.ReadInterfaceToken();
106     if (descriptor != remoteDescriptor) {
107         TAG_LOGI(AAFwkTag::ABILITYMGR, "local descriptor not equal to remote");
108         return ERR_INVALID_STATE;
109     }
110     if (code < IMissionListener::MISSION_LINSTENER_CMD_MAX && code >= 0) {
111         switch (code) {
112             case ON_MISSION_CREATED:
113                 return OnMissionCreatedInner(data, reply);
114                 break;
115             case ON_MISSION_DESTROYED:
116                 return OnMissionDestroyedInner(data, reply);
117                 break;
118             case ON_MISSION_SNAPSHOT_CHANGED:
119                 return OnMissionSnapshotChangedInner(data, reply);
120                 break;
121             case ON_MISSION_MOVED_TO_FRONT:
122                 return OnMissionMovedToFrontInner(data, reply);
123                 break;
124             case ON_MISSION_ICON_UPDATED:
125                 return OnMissionIconUpdatedInner(data, reply);
126                 break;
127             case ON_MISSION_CLOSED:
128                 return OnMissionClosedInner(data, reply);
129                 break;
130             case ON_MISSION_LABEL_UPDATED:
131                 return OnMissionLabelUpdatedInner(data, reply);
132                 break;
133             case ON_MISSION_FOCUSED:
134                 return OnMissionFocusedInner(data, reply);
135                 break;
136             case ON_MISSION_UNFOCUSED:
137                 return OnMissionUnfocusedInner(data, reply);
138                 break;
139             case ON_MISSION_MOVED_TO_BACKGROUND:
140                 return OnMissionMovedToBackgroundInner(data, reply);
141         }
142     }
143     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
144 }
145 }  // namespace AAFwk
146 }  // namespace OHOS
147