1 /*
2 * Copyright (c) 2023 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 "session_manager_service_proxy.h"
17
18 #include "window_manager_hilog.h"
19
20 namespace OHOS::Rosen {
21 namespace {
22 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionManagerServiceProxy" };
23 }
24
GetSceneSessionManager()25 sptr<IRemoteObject> SessionManagerServiceProxy::GetSceneSessionManager()
26 {
27 MessageParcel data;
28 MessageParcel reply;
29 MessageOption option(MessageOption::TF_SYNC);
30
31 if (!data.WriteInterfaceToken(GetDescriptor())) {
32 WLOGFE("WriteInterfaceToken failed");
33 return nullptr;
34 }
35
36 sptr<IRemoteObject> remote = Remote();
37 if (remote == nullptr) {
38 WLOGFE("remote is null");
39 return nullptr;
40 }
41 auto ret = remote->SendRequest(
42 static_cast<uint32_t>(SessionManagerServiceMessage::TRANS_ID_GET_SCENE_SESSION_MANAGER),
43 data, reply, option);
44 if (ret != ERR_NONE) {
45 WLOGFE("SendRequest failed, errorCode %{public}d", ret);
46 return nullptr;
47 }
48
49 return reply.ReadRemoteObject();
50 }
51
GetSceneSessionManagerLite()52 sptr<IRemoteObject> SessionManagerServiceProxy::GetSceneSessionManagerLite()
53 {
54 MessageParcel data;
55 MessageParcel reply;
56 MessageOption option(MessageOption::TF_SYNC);
57
58 if (!data.WriteInterfaceToken(GetDescriptor())) {
59 WLOGFE("WriteInterfaceToken failed");
60 return nullptr;
61 }
62
63 sptr<IRemoteObject> remote = Remote();
64 if (remote == nullptr) {
65 WLOGFE("remote is null");
66 return nullptr;
67 }
68 auto ret = remote->SendRequest(
69 static_cast<uint32_t>(SessionManagerServiceMessage::TRANS_ID_GET_SCENE_SESSION_MANAGER_LITE),
70 data, reply, option);
71 if (ret != ERR_NONE) {
72 WLOGFE("SendRequest failed, errorCode %{public}d", ret);
73 return nullptr;
74 }
75
76 return reply.ReadRemoteObject();
77 }
78 } // namespace OHOS::Rosen
79