• 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 "zidl/session_manager_service_recover_proxy.h"
17 #include "window_manager_hilog.h"
18 
19 namespace OHOS {
20 namespace Rosen {
21 namespace {
22     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionManagerServiceRecoverProxy"};
23 }
24 
OnSessionManagerServiceRecover(const sptr<IRemoteObject> & sessionManagerService)25 void SessionManagerServiceRecoverProxy::OnSessionManagerServiceRecover(
26     const sptr<IRemoteObject>& sessionManagerService)
27 {
28     MessageParcel data;
29     MessageParcel reply;
30     MessageOption option = { MessageOption::TF_ASYNC };
31     if (!data.WriteInterfaceToken(GetDescriptor())) {
32         WLOGFE("[WMSRecover] WriteInterfaceToken failed");
33         return;
34     }
35 
36     if (!data.WriteRemoteObject(sessionManagerService)) {
37         WLOGFE("[WMSRecover] WriteRemoteObject failed");
38         return;
39     }
40 
41     if (Remote()->SendRequest(static_cast<uint32_t>(
42         SessionManagerServiceRecoverMessage::TRANS_ID_ON_SESSION_MANAGER_SERVICE_RECOVER),
43         data, reply, option) != ERR_NONE) {
44         WLOGFE("[WMSRecover] SendRequest failed");
45         return;
46     }
47 }
48 
OnWMSConnectionChanged(int32_t userId,int32_t screenId,bool isConnected)49 void SessionManagerServiceRecoverProxy::OnWMSConnectionChanged(
50     int32_t userId, int32_t screenId, bool isConnected)
51 {
52     MessageParcel data;
53     MessageParcel reply;
54     MessageOption option = { MessageOption::TF_ASYNC };
55     if (!data.WriteInterfaceToken(GetDescriptor())) {
56         WLOGFE("WriteInterfaceToken failed");
57         return;
58     }
59     if (!data.WriteInt32(userId)) {
60         WLOGFE("Write userId failed");
61         return;
62     }
63     if (!data.WriteInt32(screenId)) {
64         WLOGFE("Write screenId failed");
65         return;
66     }
67     if (!data.WriteBool(isConnected)) {
68         WLOGFE("Write isConnected failed");
69         return;
70     }
71 
72     if (Remote()->SendRequest(static_cast<uint32_t>(
73         SessionManagerServiceRecoverMessage::TRANS_ID_ON_WMS_CONNECTION_CHANGED), data, reply,
74         option) != ERR_NONE) {
75         WLOGFE("SendRequest failed");
76         return;
77     }
78 }
79 } // namespace Rosen
80 } // namespace OHOS