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