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 "acquire_data_callback_proxy.h"
17 #include "security_guard_define.h"
18 #include "security_guard_log.h"
19
20 namespace OHOS::Security::SecurityGuard {
OnNotify(const SecurityCollector::Event & event)21 int32_t AcquireDataCallbackProxy::OnNotify(const SecurityCollector::Event &event)
22 {
23 MessageParcel data;
24 MessageParcel reply;
25
26 if (!data.WriteInterfaceToken(GetDescriptor())) {
27 return ERR_INVALID_OPERATION;
28 }
29
30 data.WriteInt64(event.eventId);
31 data.WriteString(event.version);
32 data.WriteString(event.content);
33 data.WriteString(event.extra);
34 data.WriteString(event.timestamp);
35 sptr<IRemoteObject> remote = Remote();
36 if (remote == nullptr) {
37 SGLOGE("remote is nullptr, code = %{public}u", static_cast<uint32_t>(CMD_DATA_SUBSCRIBE_CALLBACK));
38 return NULL_OBJECT;
39 }
40
41 MessageOption option = { MessageOption::TF_SYNC };
42 return Remote()->SendRequest(CMD_DATA_SUBSCRIBE_CALLBACK, data, reply, option);
43 }
44 }