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_proxy.h"
18 
19 #include "hilog_tag_wrapper.h"
20 
21 namespace OHOS {
22 namespace AAFwk {
OnCallback(const uint32_t continueState,const std::string & srcDeviceId,const std::string & bundleName,const std::string & continueType,const std::string & srcBundleName)23 void RemoteOnListenerProxy::OnCallback(const uint32_t continueState, const std::string &srcDeviceId,
24     const std::string &bundleName, const std::string &continueType, const std::string &srcBundleName)
25 {
26     MessageParcel data;
27     MessageParcel reply;
28     MessageOption option;
29     if (!data.WriteInterfaceToken(RemoteOnListenerProxy::GetDescriptor())) {
30         TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyMissionsChanged Write interface token failed.");
31         return;
32     }
33     if (!data.WriteUint32(continueState)) {
34         TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyOnsChanged Write ContinueState failed.");
35         return;
36     }
37     if (!data.WriteString(srcDeviceId)) {
38         TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyOnsChanged Write srcDeviceId failed.");
39         return;
40     }
41     if (!data.WriteString(bundleName)) {
42         TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyOnsChanged Write bundleName failed.");
43         return;
44     }
45     if (!data.WriteString(continueType)) {
46         TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyOnsChanged Write continueType failed.");
47         return;
48     }
49     if (!data.WriteString(srcBundleName)) {
50         TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyOnsChanged Write srcBundleName failed.");
51         return;
52     }
53     sptr<IRemoteObject> remote = Remote();
54     if (remote == nullptr) {
55         TAG_LOGE(AAFwkTag::ABILITYMGR, "remote object is nullptr.");
56         return;
57     }
58     int result = remote->SendRequest(IRemoteOnListener::ON_CALLBACK, data, reply, option);
59     if (result != NO_ERROR) {
60         TAG_LOGE(AAFwkTag::ABILITYMGR, "NotifyMissionsChanged SendRequest fail, error: %{public}d", result);
61         return;
62     }
63 }
64 }  // namespace AAFwk
65 }  // namespace OHOS
66