• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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,int32_t crashFd)37 void RenderSchedulerProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd,
38                                            int32_t crashFd)
39 {
40     HILOG_DEBUG("NotifyBrowserFd start");
41     MessageParcel data;
42     MessageParcel reply;
43     MessageOption option(MessageOption::TF_ASYNC);
44     if (!WriteInterfaceToken(data)) {
45         return;
46     }
47 
48     if (!data.WriteFileDescriptor(ipcFd) || !data.WriteFileDescriptor(sharedFd) ||
49         !data.WriteFileDescriptor(crashFd)) {
50         HILOG_ERROR("want fd failed, ipcFd:%{public}d, sharedFd:%{public}d, "
51                     "crashFd:%{public}d",
52                     ipcFd, sharedFd, crashFd);
53         return;
54     }
55 
56     sptr<IRemoteObject> remote = Remote();
57     if (remote == nullptr) {
58         HILOG_ERROR("Remote() is NULL");
59         return;
60     }
61     int32_t ret = remote->SendRequest(
62         static_cast<uint32_t>(IRenderScheduler::Message::NOTIFY_BROWSER_FD), data,
63         reply, option);
64     if (ret != NO_ERROR) {
65         HILOG_WARN("SendRequest is failed, error code: %{public}d", ret);
66     }
67     HILOG_DEBUG("NotifyBrowserFd end");
68 }
69 }  // namespace AppExecFwk
70 }  // namespace OHOS
71