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