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 "render_scheduler_proxy.h"
17
18 #include "hilog_wrapper.h"
19 #include "ipc_types.h"
20
21
22 namespace OHOS {
23 namespace AppExecFwk {
RenderSchedulerProxy(const sptr<IRemoteObject> & impl)24 RenderSchedulerProxy::RenderSchedulerProxy(
25 const sptr<IRemoteObject> &impl) : IRemoteProxy<IRenderScheduler>(impl)
26 {}
27
WriteInterfaceToken(MessageParcel & data)28 bool RenderSchedulerProxy::WriteInterfaceToken(MessageParcel &data)
29 {
30 if (!data.WriteInterfaceToken(RenderSchedulerProxy::GetDescriptor())) {
31 HILOG_ERROR("write interface token failed");
32 return false;
33 }
34 return true;
35 }
36
NotifyBrowserFd(int32_t ipcFd,int32_t sharedFd)37 void RenderSchedulerProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd)
38 {
39 HILOG_DEBUG("NotifyBrowserFd start");
40 MessageParcel data;
41 MessageParcel reply;
42 MessageOption option(MessageOption::TF_ASYNC);
43 if (!WriteInterfaceToken(data)) {
44 return;
45 }
46
47 if (!data.WriteFileDescriptor(ipcFd) || !data.WriteFileDescriptor(sharedFd)) {
48 HILOG_ERROR("want fd failed, ipcFd:%{public}d, sharedFd:%{public}d", ipcFd, sharedFd);
49 return;
50 }
51
52 sptr<IRemoteObject> remote = Remote();
53 if (remote == nullptr) {
54 HILOG_ERROR("Remote() is NULL");
55 return;
56 }
57 int32_t ret = remote->SendRequest(
58 static_cast<uint32_t>(IRenderScheduler::Message::NOTIFY_BROWSER_FD),
59 data, reply, option);
60 if (ret != NO_ERROR) {
61 HILOG_WARN("SendRequest is failed, error code: %{public}d", ret);
62 }
63 HILOG_DEBUG("NotifyBrowserFd end");
64 }
65 } // namespace AppExecFwk
66 } // namespace OHOS
67