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
16 #include "rs_surface_occlusion_change_callback_proxy.h"
17
18 #include "common/rs_common_def.h"
19 #include <message_option.h>
20 #include <message_parcel.h>
21
22 #include "platform/common/rs_log.h"
23 #include "ipc_callbacks/rs_ipc_callbacks_check.h"
24
25 namespace OHOS {
26 namespace Rosen {
RSSurfaceOcclusionChangeCallbackProxy(const sptr<IRemoteObject> & impl)27 RSSurfaceOcclusionChangeCallbackProxy::RSSurfaceOcclusionChangeCallbackProxy(const sptr<IRemoteObject>& impl)
28 : IRemoteProxy<RSISurfaceOcclusionChangeCallback>(impl)
29 {
30 }
31
OnSurfaceOcclusionVisibleChanged(float visibleAreaRatio)32 void RSSurfaceOcclusionChangeCallbackProxy::OnSurfaceOcclusionVisibleChanged(float visibleAreaRatio)
33 {
34 MessageParcel data;
35 MessageParcel reply;
36 MessageOption option;
37
38 if (!data.WriteInterfaceToken(RSISurfaceOcclusionChangeCallback::GetDescriptor())) {
39 ROSEN_LOGE("RSSurfaceOcclusionChangeCallbackProxy::OnSurfaceOcclusionVisibleChanged "
40 "WriteInterfaceToken failed");
41 return;
42 }
43
44 option.SetFlags(MessageOption::TF_ASYNC);
45 if (!data.WriteFloat(visibleAreaRatio)) {
46 ROSEN_LOGE("RSSurfaceOcclusionChangeCallbackProxy::OnSurfaceOcclusionVisibleChanged WriteFloat failed");
47 return;
48 }
49 uint32_t code = static_cast<uint32_t>(
50 RSISurfaceOcclusionChangeCallbackInterfaceCode::ON_SURFACE_OCCLUSION_VISIBLE_CHANGED);
51 int32_t err = SendRequestRemote::SendRequest(Remote(), code, data, reply, option);
52 if (err != NO_ERROR) {
53 ROSEN_LOGE("RSSurfaceOcclusionChangeCallbackProxy::OnSurfaceOcclusionVisibleChanged error = %d", err);
54 }
55 }
56
57 } // namespace Rosen
58 } // namespace OHOS
59