1 
2 /*
3  * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "remote_mission_listener_stub.h"
18 
19 #include "hilog_tag_wrapper.h"
20 
21 namespace OHOS {
22 namespace AAFwk {
RemoteMissionListenerStub()23 RemoteMissionListenerStub::RemoteMissionListenerStub()
24 {}
25 
~RemoteMissionListenerStub()26 RemoteMissionListenerStub::~RemoteMissionListenerStub()
27 {}
28 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)29 int RemoteMissionListenerStub::OnRemoteRequest(
30     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
31 {
32     std::u16string descriptor = RemoteMissionListenerStub::GetDescriptor();
33     std::u16string remoteDescriptor = data.ReadInterfaceToken();
34     if (descriptor != remoteDescriptor) {
35         TAG_LOGI(AAFwkTag::ABILITYMGR, "RemoteMissionListenerStub Local descriptor is not equal to remote");
36         return ERR_INVALID_STATE;
37     }
38 
39     switch (code) {
40         case IRemoteMissionListener::NOTIFY_MISSION_CHANGED: {
41             return NotifyMissionsChangedInner(data, reply);
42         }
43         case IRemoteMissionListener::NOTIFY_SNAPSHOT: {
44             return NotifySnapshotInner(data, reply);
45         }
46         case IRemoteMissionListener::NOTIFY_NET_DISCONNECT: {
47             return NotifyNetDisconnectInner(data, reply);
48         }
49         default: {
50             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
51         }
52     }
53 }
54 
NotifyMissionsChangedInner(MessageParcel & data,MessageParcel & reply)55 int32_t RemoteMissionListenerStub::NotifyMissionsChangedInner(MessageParcel &data, MessageParcel &reply)
56 {
57     std::string deviceId = data.ReadString();
58     NotifyMissionsChanged(deviceId);
59     return NO_ERROR;
60 }
61 
NotifySnapshotInner(MessageParcel & data,MessageParcel & reply)62 int32_t RemoteMissionListenerStub::NotifySnapshotInner(MessageParcel &data, MessageParcel &reply)
63 {
64     std::string deviceId = data.ReadString();
65     int32_t missionId = data.ReadInt32();
66     NotifySnapshot(deviceId, missionId);
67     return NO_ERROR;
68 }
69 
NotifyNetDisconnectInner(MessageParcel & data,MessageParcel & reply)70 int32_t RemoteMissionListenerStub::NotifyNetDisconnectInner(MessageParcel &data, MessageParcel &reply)
71 {
72     std::string deviceId = data.ReadString();
73     int32_t state = data.ReadInt32();
74     NotifyNetDisconnect(deviceId, state);
75     return NO_ERROR;
76 }
77 }  // namespace AAFwk
78 }  // namespace OHOS
79