• 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 
19 #include "sclock_log.h"
20 
21 namespace OHOS {
22 namespace ScreenLock {
ScreenLockSystemAbilityProxy(const sptr<IRemoteObject> & impl)23 ScreenLockSystemAbilityProxy::ScreenLockSystemAbilityProxy(const sptr<IRemoteObject> &impl)
24     : IRemoteProxy<ScreenLockSystemAbilityInterface>(impl)
25 {
26 }
27 
OnCallBack(const std::string & event,bool result)28 void ScreenLockSystemAbilityProxy::OnCallBack(const std::string &event, bool result)
29 {
30     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start");
31     SCLOCK_HILOGD("event----》%{public}s,result----》%{public}d", event.c_str(), result);
32     MessageParcel data;
33     MessageParcel reply;
34     MessageOption option;
35     if (!data.WriteInterfaceToken(ScreenLockSystemAbilityProxy::GetDescriptor())) {
36         SCLOCK_HILOGE("write descriptor failed");
37         return;
38     }
39     if (!data.WriteString(event)) {
40         SCLOCK_HILOGE("write string failed");
41         return;
42     }
43     if (!data.WriteBool(result)) {
44         SCLOCK_HILOGE("write bool failed");
45         return;
46     }
47     int error = Remote()->SendRequest(ONCALLBACK_BOOL, data, reply, option);
48     if (error != 0) {
49         SCLOCK_HILOGE("SendRequest failed, error %{public}d", error);
50     }
51     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack End");
52 }
53 
OnCallBack(const std::string & event)54 void ScreenLockSystemAbilityProxy::OnCallBack(const std::string &event)
55 {
56     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start");
57     MessageParcel data;
58     MessageParcel reply;
59     MessageOption option;
60     if (!data.WriteInterfaceToken(ScreenLockSystemAbilityProxy::GetDescriptor())) {
61         SCLOCK_HILOGE("write descriptor failed");
62         return;
63     }
64     if (!data.WriteString(event)) {
65         SCLOCK_HILOGE("write string failed");
66         return;
67     }
68     int error = Remote()->SendRequest(ONCALLBACK_VOID, data, reply, option);
69     if (error != 0) {
70         SCLOCK_HILOGE("SendRequest failed, error %{public}d", error);
71     }
72     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack End");
73 }
74 
OnCallBack(const std::string & event,int result)75 void ScreenLockSystemAbilityProxy::OnCallBack(const std::string &event, int result)
76 {
77     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start");
78     SCLOCK_HILOGD("event =%{public}s, result = %{public}d", event.c_str(), result);
79     MessageParcel data;
80     MessageParcel reply;
81     MessageOption option;
82     if (!data.WriteInterfaceToken(ScreenLockSystemAbilityProxy::GetDescriptor())) {
83         SCLOCK_HILOGE("write descriptor failed");
84         return;
85     }
86     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start1");
87     if (!data.WriteString(event)) {
88         SCLOCK_HILOGE("write string failed");
89         return;
90     }
91     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start2");
92     if (!data.WriteInt32(result)) {
93         SCLOCK_HILOGE("write bool failed");
94         return;
95     }
96     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack Start3");
97     int error = Remote()->SendRequest(ONCALLBACK_INT, data, reply, option);
98     if (error != 0) {
99         SCLOCK_HILOGE("SendRequest failed, error %{public}d", error);
100     }
101     SCLOCK_HILOGD("ScreenLockSystemAbilityProxy::OnCallBack End");
102 }
103 } // namespace ScreenLock
104 } // namespace OHOS
105