1 /*
2 * Copyright (c) 2023-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 "child_scheduler_stub.h"
17
18 #include "hilog_tag_wrapper.h"
19 #include "ipc_types.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
ChildSchedulerStub()23 ChildSchedulerStub::ChildSchedulerStub() {}
24
~ChildSchedulerStub()25 ChildSchedulerStub::~ChildSchedulerStub() {}
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int32_t ChildSchedulerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
28 MessageParcel &reply, MessageOption &option)
29 {
30 TAG_LOGI(AAFwkTag::APPMGR, "ChildSchedulerStub::OnReceived, code = %{public}u, flags= %{public}d.", code,
31 option.GetFlags());
32 std::u16string descriptor = ChildSchedulerStub::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 switch (code) {
40 case static_cast<uint32_t>(IChildScheduler::Message::SCHEDULE_LOAD_JS):
41 return HandleScheduleLoadChild(data, reply);
42 case static_cast<uint32_t>(IChildScheduler::Message::SCHEDULE_EXIT_PROCESS_SAFELY):
43 return HandleScheduleExitProcessSafely(data, reply);
44 case static_cast<uint32_t>(IChildScheduler::Message::SCHEDULE_RUN_NATIVE_PROC):
45 return HandleScheduleRunNativeProc(data, reply);
46 }
47 TAG_LOGI(AAFwkTag::APPMGR, "ChildSchedulerStub::OnRemoteRequest end");
48 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
49 }
50
HandleScheduleLoadChild(MessageParcel & data,MessageParcel & reply)51 int32_t ChildSchedulerStub::HandleScheduleLoadChild(MessageParcel &data, MessageParcel &reply)
52 {
53 ScheduleLoadChild();
54 return ERR_NONE;
55 }
56
HandleScheduleExitProcessSafely(MessageParcel & data,MessageParcel & reply)57 int32_t ChildSchedulerStub::HandleScheduleExitProcessSafely(MessageParcel &data, MessageParcel &reply)
58 {
59 ScheduleExitProcessSafely();
60 return ERR_NONE;
61 }
62
HandleScheduleRunNativeProc(MessageParcel & data,MessageParcel & reply)63 int32_t ChildSchedulerStub::HandleScheduleRunNativeProc(MessageParcel &data, MessageParcel &reply)
64 {
65 sptr<IRemoteObject> cb = data.ReadRemoteObject();
66 ScheduleRunNativeProc(cb);
67 return ERR_NONE;
68 }
69
70 } // namespace AppExecFwk
71 } // namespace OHOS