1 
2 /*
3  * Copyright (c) 2023-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_on_listener_stub.h"
18 
19 #include "hilog_tag_wrapper.h"
20 
21 namespace OHOS {
22 namespace AAFwk {
RemoteOnListenerStub()23 RemoteOnListenerStub::RemoteOnListenerStub()
24 {}
25 
~RemoteOnListenerStub()26 RemoteOnListenerStub::~RemoteOnListenerStub()
27 {}
28 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)29 int RemoteOnListenerStub::OnRemoteRequest(
30     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
31 {
32     std::u16string descriptor = RemoteOnListenerStub::GetDescriptor();
33     std::u16string remoteDescriptor = data.ReadInterfaceToken();
34     if (descriptor != remoteDescriptor) {
35         TAG_LOGI(AAFwkTag::ABILITYMGR, "RemoteOnListenerStub Local descriptor is not equal to remote");
36         return ERR_INVALID_STATE;
37     }
38 
39     switch (code) {
40         case IRemoteOnListener::ON_CALLBACK: {
41             return OnCallbackInner(data, reply);
42         }
43         default: {
44             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
45         }
46     }
47 }
48 
OnCallbackInner(MessageParcel & data,MessageParcel & reply)49 int32_t RemoteOnListenerStub::OnCallbackInner(MessageParcel &data, MessageParcel &reply)
50 {
51     uint32_t continueState = data.ReadUint32();
52     std::string srcDeviceId = data.ReadString();
53     std::string bundleName = data.ReadString();
54     std::string continueType = data.ReadString();
55     std::string srcBundleName = data.ReadString();
56     OnCallback(continueState, srcDeviceId, bundleName, continueType, srcBundleName);
57     return NO_ERROR;
58 }
59 }  // namespace AAFwk
60 }  // namespace OHOS
61