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
16 #include "screenlock_system_ability_stub.h"
17
18 #include "sclock_log.h"
19 #include "screenlock_common.h"
20
21 namespace OHOS {
22 namespace ScreenLock {
OnCallBack(const std::string & event,bool result)23 void ScreenLockSystemAbilityStub::OnCallBack(const std::string &event, bool result)
24 {
25 }
26
OnCallBack(const std::string & event)27 void ScreenLockSystemAbilityStub::OnCallBack(const std::string &event)
28 {
29 }
30
OnCallBack(const std::string & event,int result)31 void ScreenLockSystemAbilityStub::OnCallBack(const std::string &event, int result)
32 {
33 }
34
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)35 int32_t ScreenLockSystemAbilityStub::OnRemoteRequest(
36 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
37 {
38 auto descriptorToken = data.ReadInterfaceToken();
39 if (descriptorToken != GetDescriptor()) {
40 SCLOCK_HILOGE("Remote descriptor not the same as local descriptor.");
41 return E_SCREENLOCK_TRANSACT_ERROR;
42 }
43 SCLOCK_HILOGD("ScreenLockSystemAbilityStub code----》%{public}u", code);
44 switch (code) {
45 case ONCALLBACK_BOOL: {
46 std::string type = data.ReadString();
47 bool result = data.ReadBool();
48 SCLOCK_HILOGD("ONCALLBACK_BOOL type----》%{public}s, result----》%{public}d", type.c_str(), result);
49 OnCallBack(type, result);
50 break;
51 }
52 case ONCALLBACK_VOID: {
53 std::string type = data.ReadString();
54 SCLOCK_HILOGD("ScreenLockSystemAbilityStub ONCALLBACK_VOID type----》%{public}s", type.c_str());
55 OnCallBack(type);
56 break;
57 }
58 case ONCALLBACK_INT: {
59 std::string type = data.ReadString();
60 int result = data.ReadInt32();
61 SCLOCK_HILOGD("ONCALLBACK_INT type----》%{public}s,result----》%{public}d", type.c_str(), result);
62 OnCallBack(type, result);
63 break;
64 }
65 default: {
66 return OHOS::UNKNOWN_TRANSACTION;
67 }
68 }
69 return OHOS::NO_ERROR;
70 }
71 } // namespace ScreenLock
72 } // namespace OHOS
73