1/*
2 * Copyright (C) 2022 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#include "screenlock_system_ability_proxy.h"
16
17#include "message_parcel.h"
18#include "sclock_log.h"
19
20namespace OHOS {
21namespace ScreenLock {
22ScreenLockSystemAbilityProxy::ScreenLockSystemAbilityProxy(const sptr<IRemoteObject> &impl)
23    : IRemoteProxy<ScreenLockSystemAbilityInterface>(impl)
24{
25}
26
27void ScreenLockSystemAbilityProxy::OnCallBack(const SystemEvent &systemEvent)
28{
29    SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start");
30    MessageParcel data;
31    MessageParcel reply;
32    MessageOption option;
33    if (!data.WriteInterfaceToken(ScreenLockSystemAbilityProxy::GetDescriptor())) {
34        SCLOCK_HILOGE("write descriptor failed");
35        return;
36    }
37    if (!data.WriteString(systemEvent.eventType_)) {
38        SCLOCK_HILOGE("write string failed");
39        return;
40    }
41    if (!data.WriteString(systemEvent.params_)) {
42        SCLOCK_HILOGE("write string failed");
43        return;
44    }
45    int32_t error = Remote()->SendRequest(ON_CALLBACK, data, reply, option);
46    if (error != 0) {
47        SCLOCK_HILOGE("SendRequest failed, error %{public}d", error);
48    }
49    SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack End");
50}
51} // namespace ScreenLock
52} // namespace OHOS
53