1 /*
2 * Copyright (c) 2025 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 "screen_switching_notify_callback_proxy.h"
17
18 #include <message_option.h>
19 #include <message_parcel.h>
20
21 namespace OHOS {
22 namespace Rosen {
RSScreenSwitchingNotifyCallbackProxy(const sptr<IRemoteObject> & impl)23 RSScreenSwitchingNotifyCallbackProxy::RSScreenSwitchingNotifyCallbackProxy(const sptr<IRemoteObject>& impl)
24 : IRemoteProxy<RSIScreenSwitchingNotifyCallback>(impl)
25 {
26 }
27
OnScreenSwitchingNotify(bool status)28 void RSScreenSwitchingNotifyCallbackProxy::OnScreenSwitchingNotify(bool status)
29 {
30 MessageParcel data;
31 MessageParcel reply;
32 MessageOption option;
33
34 if (!data.WriteInterfaceToken(RSIScreenSwitchingNotifyCallback::GetDescriptor())) {
35 ROSEN_LOGE("RSScreenSwitchingNotifyCallbackProxy::OnScreenSwitchingNotify WriteInterfaceToken failed");
36 return;
37 }
38
39 if (!data.WriteBool(status)) {
40 ROSEN_LOGE("RSScreenSwitchingNotifyCallbackProxy::OnScreenSwitchingNotify WriteBool failed");
41 return;
42 }
43
44 option.SetFlags(MessageOption::TF_ASYNC);
45 uint32_t code = static_cast<uint32_t>(RSIScreenSwitchingNotifyCallbackInterfaceCode::ON_SCREEN_SWITCHING_NOTIFY);
46
47 int32_t err = SendRequestRemote::SendRequest(Remote(), code, data, reply, option);
48 if (err != NO_ERROR) {
49 ROSEN_LOGE("RSScreenSwitchingNotifyCallbackProxy::OnScreenSwitchingNotify error = %{public}d", err);
50 }
51 }
52 } // namespace Rosen
53 } // namespace OHOS