1 /*
2 * Copyright (c) 2021 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 "update_callback_proxy.h"
17
18 #include "event_info.h"
19 #include "message_parcel_helper.h"
20 #include "update_log.h"
21
22 namespace OHOS::UpdateEngine {
OnEvent(const EventInfo & eventInfo)23 void UpdateCallbackProxy::OnEvent(const EventInfo &eventInfo)
24 {
25 ENGINE_LOGI("UpdateCallbackProxy::OnEvent");
26 MessageParcel data;
27 MessageParcel reply;
28 MessageOption option { MessageOption::TF_SYNC };
29
30 if (!data.WriteInterfaceToken(GetDescriptor())) {
31 ENGINE_LOGE("UpdateCallbackProxy WriteInterfaceToken fail");
32 return;
33 }
34
35 auto remote = Remote();
36 ENGINE_CHECK(remote != nullptr, return, "Can not get remote");
37
38 int32_t result = MessageParcelHelper::WriteEventInfo(data, eventInfo);
39 ENGINE_CHECK(result == 0, return, "Can not WriteEventInfo");
40
41 result = remote->SendRequest(ON_EVENT, data, reply, option);
42 ENGINE_CHECK(result == ERR_OK, return, "Can not SendRequest");
43 return;
44 }
45 } // namespace OHOS::UpdateEngine
46
47