• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 namespace OHOS {
21 namespace ScreenLock {
ScreenLockSystemAbilityProxy(const sptr<IRemoteObject> & impl)22 ScreenLockSystemAbilityProxy::ScreenLockSystemAbilityProxy(const sptr<IRemoteObject> &impl)
23     : IRemoteProxy<ScreenLockSystemAbilityInterface>(impl)
24 {
25 }
26 
OnCallBack(const SystemEvent & systemEvent)27 void ScreenLockSystemAbilityProxy::OnCallBack(const SystemEvent &systemEvent)
28 {
29     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start");
30     MessageParcel data;
31     MessageParcel reply;
32     MessageOption option;
33     option.SetFlags(static_cast<int>(MessageOption::TF_ASYNC));
34     if (!data.WriteInterfaceToken(ScreenLockSystemAbilityProxy::GetDescriptor())) {
35         SCLOCK_HILOGE("write descriptor failed");
36         return;
37     }
38     if (!data.WriteString(systemEvent.eventType_)) {
39         SCLOCK_HILOGE("write string failed");
40         return;
41     }
42     if (!data.WriteString(systemEvent.params_)) {
43         SCLOCK_HILOGE("write string failed");
44         return;
45     }
46     int32_t error = Remote()->SendRequest(ON_CALLBACK, data, reply, option);
47     if (error != 0) {
48         SCLOCK_HILOGE("SendRequest failed, error %{public}d", error);
49     }
50     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack End");
51 }
52 } // namespace ScreenLock
53 } // namespace OHOS
54