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_host.h"
17
18 #include "hilog_tag_wrapper.h"
19 #include "ipc_types.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
RenderSchedulerHost()23 RenderSchedulerHost::RenderSchedulerHost() {}
24
~RenderSchedulerHost()25 RenderSchedulerHost::~RenderSchedulerHost() {}
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int RenderSchedulerHost::OnRemoteRequest(uint32_t code, MessageParcel &data,
28 MessageParcel &reply, MessageOption &option)
29 {
30 TAG_LOGI(AAFwkTag::APPMGR, "RenderSchedulerHost::OnReceived, code = %{public}u, flags= %{public}d.", code,
31 option.GetFlags());
32 std::u16string descriptor = RenderSchedulerHost::GetDescriptor();
33 std::u16string remoteDescriptor = data.ReadInterfaceToken();
34 if (descriptor != remoteDescriptor) {
35 TAG_LOGE(AAFwkTag::APPMGR, "A local descriptor is not equivalent to a remote");
36 return ERR_INVALID_STATE;
37 }
38
39 if (code == static_cast<uint32_t>(IRenderScheduler::Message::NOTIFY_BROWSER_FD)) {
40 return HandleNotifyBrowserFd(data, reply);
41 }
42
43 TAG_LOGI(AAFwkTag::APPMGR, "RenderSchedulerHost::OnRemoteRequest end");
44 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
45 }
46
HandleNotifyBrowserFd(MessageParcel & data,MessageParcel & reply)47 int RenderSchedulerHost::HandleNotifyBrowserFd(MessageParcel &data, MessageParcel &reply)
48 {
49 int32_t ipcFd = data.ReadFileDescriptor();
50 int32_t sharedFd = data.ReadFileDescriptor();
51 int32_t crashFd = data.ReadFileDescriptor();
52 sptr<IRemoteObject> browser = data.ReadRemoteObject();
53 NotifyBrowserFd(ipcFd, sharedFd, crashFd, browser);
54 return 0;
55 }
56 } // namespace AppExecFwk
57 } // namespace OHOS
58