1 /*
2 * Copyright (c) 2023-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 "insight_intent_execute_callback_proxy.h"
17
18 #include "hilog_tag_wrapper.h"
19
20 namespace OHOS {
21 namespace AAFwk {
OnExecuteDone(uint64_t key,int32_t resultCode,const AppExecFwk::InsightIntentExecuteResult & executeResult)22 void InsightIntentExecuteCallbackProxy::OnExecuteDone(uint64_t key, int32_t resultCode,
23 const AppExecFwk::InsightIntentExecuteResult &executeResult)
24 {
25 TAG_LOGD(AAFwkTag::INTENT, "called");
26 MessageParcel data;
27 if (!data.WriteInterfaceToken(IInsightIntentExecuteCallback::GetDescriptor())) {
28 TAG_LOGE(AAFwkTag::INTENT, "interface token write failed");
29 return;
30 }
31 if (!data.WriteUint64(key)) {
32 TAG_LOGE(AAFwkTag::INTENT, "key write failed");
33 return;
34 }
35 if (!data.WriteInt32(resultCode)) {
36 TAG_LOGE(AAFwkTag::INTENT, "resultCode Int32 write failed");
37 return;
38 }
39 if (!data.WriteParcelable(&executeResult)) {
40 TAG_LOGE(AAFwkTag::INTENT, "executeResult Parcelable write failed");
41 return;
42 }
43 sptr<IRemoteObject> remote = Remote();
44 if (remote == nullptr) {
45 TAG_LOGE(AAFwkTag::INTENT, "null remote");
46 return;
47 }
48
49 MessageParcel reply;
50 MessageOption option(MessageOption::TF_ASYNC);
51 int error = remote->SendRequest(ON_INSIGHT_INTENT_EXECUTE_DONE, data, reply, option);
52 if (error != ERR_OK) {
53 TAG_LOGE(AAFwkTag::INTENT, "SendRequest fail, error: %{public}d", error);
54 }
55 }
56 } // namespace AAFwk
57 } // namespace OHOS
58