1 /*
2 * Copyright (c) 2022-2024 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_tag_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 TAG_LOGE(AAFwkTag::APPMGR, "write interface token failed");
32 return false;
33 }
34 return true;
35 }
36
NotifyBrowserFd(int32_t ipcFd,int32_t sharedFd,int32_t crashFd,sptr<IRemoteObject> browser)37 void RenderSchedulerProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd,
38 int32_t crashFd, sptr<IRemoteObject> browser)
39 {
40 TAG_LOGD(AAFwkTag::APPMGR, "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 TAG_LOGE(AAFwkTag::APPMGR, "want fd failed, ipcFd:%{public}d, sharedFd:%{public}d, "
51 "crashFd:%{public}d", ipcFd, sharedFd, crashFd);
52 return;
53 }
54
55 if (!data.WriteRemoteObject(browser)) {
56 TAG_LOGE(AAFwkTag::APPMGR, "write browser failed!");
57 }
58
59 sptr<IRemoteObject> remote = Remote();
60 if (remote == nullptr) {
61 TAG_LOGE(AAFwkTag::APPMGR, "Remote() is NULL");
62 return;
63 }
64 int32_t ret = remote->SendRequest(
65 static_cast<uint32_t>(IRenderScheduler::Message::NOTIFY_BROWSER_FD), data,
66 reply, option);
67 if (ret != NO_ERROR) {
68 TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
69 }
70 TAG_LOGD(AAFwkTag::APPMGR, "NotifyBrowserFd end");
71 }
72 } // namespace AppExecFwk
73 } // namespace OHOS
74