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