• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     auto ret = Remote()->SendRequest(
37         static_cast<uint32_t>(SessionManagerServiceMessage::TRANS_ID_GET_SCENE_SESSION_MANAGER),
38         data, reply, option);
39     if (ret != ERR_NONE) {
40         WLOGFE("SendRequest failed, errorCode %{public}d", ret);
41         return nullptr;
42     }
43 
44     return reply.ReadRemoteObject();
45 }
46 
GetScreenSessionManagerService()47 sptr<IRemoteObject> SessionManagerServiceProxy::GetScreenSessionManagerService()
48 {
49     MessageParcel data;
50     MessageParcel reply;
51     MessageOption option(MessageOption::TF_SYNC);
52 
53     if (!data.WriteInterfaceToken(GetDescriptor())) {
54         WLOGFE("WriteInterfaceToken failed");
55         return nullptr;
56     }
57 
58     auto ret = Remote()->SendRequest(
59         static_cast<uint32_t>(SessionManagerServiceMessage::TRANS_ID_GET_SCREEN_SESSION_MANAGER_SERVICE),
60         data, reply, option);
61     if (ret != ERR_NONE) {
62         WLOGFE("SendRequest failed, errorCode %{public}d", ret);
63         return nullptr;
64     }
65 
66     return reply.ReadRemoteObject();
67 }
68 
GetScreenLockManagerService()69 sptr<IRemoteObject> SessionManagerServiceProxy::GetScreenLockManagerService()
70 {
71     MessageParcel data;
72     MessageParcel reply;
73     MessageOption option(MessageOption::TF_SYNC);
74 
75     if (!data.WriteInterfaceToken(GetDescriptor())) {
76         WLOGFE("WriteInterfaceToken failed");
77         return nullptr;
78     }
79 
80     auto ret = Remote()->SendRequest(
81         static_cast<uint32_t>(SessionManagerServiceMessage::TRANS_ID_GET_SCREEN_LOCK_MANAGER_SERVICE),
82         data, reply, option);
83     if (ret != ERR_NONE) {
84         WLOGFE("SendRequest failed, errorCode %{public}d", ret);
85         return nullptr;
86     }
87 
88     return reply.ReadRemoteObject();
89 }
90 } // namespace OHOS::Rosen
91