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#include "screenlock_callback_proxy.h" 16 17#include "message_parcel.h" 18#include "sclock_log.h" 19 20namespace OHOS { 21namespace ScreenLock { 22ScreenLockCallbackProxy::ScreenLockCallbackProxy(const sptr<IRemoteObject> &impl) 23 : IRemoteProxy<ScreenLockCallbackInterface>(impl) 24{ 25} 26 27void ScreenLockCallbackProxy::OnCallBack(int32_t screenLockResult) 28{ 29 SCLOCK_HILOGD("ScreenLockCallbackProxy::OnCallBack screenLockResult Start"); 30 MessageParcel data; 31 MessageParcel reply; 32 MessageOption option; 33 if (!data.WriteInterfaceToken(GetDescriptor())) { 34 SCLOCK_HILOGE("write descriptor failed"); 35 return; 36 } 37 if (!data.WriteInt32(screenLockResult)) { 38 SCLOCK_HILOGE("write screenLockResult failed"); 39 return; 40 } 41 int32_t errorCode = Remote()->SendRequest(ON_CALLBACK, data, reply, option); 42 if (errorCode != 0) { 43 SCLOCK_HILOGE("SendRequest failed, errorCode: %{public}d", errorCode); 44 } 45} 46} // namespace ScreenLock 47} // namespace OHOS 48