• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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/window_manager_agent_proxy.h"
17 #include <ipc_types.h>
18 #include "marshalling_helper.h"
19 #include "window_manager_hilog.h"
20 #include "wm_common.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 namespace {
25     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowManagerAgentProxy"};
26 }
27 
UpdateFocusChangeInfo(const sptr<FocusChangeInfo> & focusChangeInfo,bool focused)28 void WindowManagerAgentProxy::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused)
29 {
30     MessageParcel data;
31     if (focusChangeInfo == nullptr) {
32         WLOGFE("Invalid focus change info");
33         return;
34     }
35 
36     if (!data.WriteInterfaceToken(GetDescriptor())) {
37         WLOGFE("WriteInterfaceToken failed");
38         return;
39     }
40 
41     if (!data.WriteParcelable(focusChangeInfo)) {
42         WLOGFE("Write displayId failed");
43         return;
44     }
45 
46     if (!data.WriteBool(focused)) {
47         WLOGFE("Write Focus failed");
48         return;
49     }
50     MessageParcel reply;
51     MessageOption option(MessageOption::TF_ASYNC);
52     if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS),
53         data, reply, option) != ERR_NONE) {
54         WLOGFE("SendRequest failed");
55     }
56 }
57 
UpdateSystemBarRegionTints(DisplayId displayId,const SystemBarRegionTints & tints)58 void WindowManagerAgentProxy::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints)
59 {
60     MessageParcel data;
61     if (!data.WriteInterfaceToken(GetDescriptor())) {
62         WLOGFE("WriteInterfaceToken failed");
63         return;
64     }
65 
66     if (!data.WriteUint64(displayId)) {
67         WLOGFE("Write displayId failed");
68         return;
69     }
70     bool res = MarshallingHelper::MarshallingVectorObj<SystemBarRegionTint>(data, tints,
71         [](Parcel& parcel, const SystemBarRegionTint& tint) {
72             return parcel.WriteUint32(static_cast<uint32_t>(tint.type_)) && parcel.WriteBool(tint.prop_.enable_) &&
73                 parcel.WriteUint32(tint.prop_.backgroundColor_) && parcel.WriteUint32(tint.prop_.contentColor_) &&
74                 parcel.WriteInt32(tint.region_.posX_) && parcel.WriteInt32(tint.region_.posY_) &&
75                 parcel.WriteInt32(tint.region_.width_) && parcel.WriteInt32(tint.region_.height_);
76         }
77     );
78     if (!res) {
79         WLOGFE("Write SystemBarRegionTint failed");
80         return;
81     }
82     MessageParcel reply;
83     MessageOption option(MessageOption::TF_ASYNC);
84     if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS),
85         data, reply, option) != ERR_NONE) {
86         WLOGFE("SendRequest failed");
87     }
88 }
89 
NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>> & infos,WindowUpdateType type)90 void WindowManagerAgentProxy::NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>>& infos,
91     WindowUpdateType type)
92 {
93     MessageParcel data;
94     if (!data.WriteInterfaceToken(GetDescriptor())) {
95         WLOGFE("WriteInterfaceToken failed");
96         return;
97     }
98 
99     if (!MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(data, infos)) {
100         WLOGFE("Write accessibility window infos failed");
101         return;
102     }
103 
104     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
105         WLOGFE("Write windowUpdateType failed");
106         return;
107     }
108     MessageParcel reply;
109     MessageOption option(MessageOption::TF_ASYNC);
110     if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STATUS),
111         data, reply, option) != ERR_NONE) {
112         WLOGFE("SendRequest failed");
113     }
114 }
115 
UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>> & visibilityInfos)116 void WindowManagerAgentProxy::UpdateWindowVisibilityInfo(
117     const std::vector<sptr<WindowVisibilityInfo>>& visibilityInfos)
118 {
119     MessageParcel data;
120     if (!data.WriteInterfaceToken(GetDescriptor())) {
121         WLOGFE("WriteInterfaceToken failed");
122         return;
123     }
124     if (!data.WriteUint32(static_cast<uint32_t>(visibilityInfos.size()))) {
125         WLOGFE("write windowVisibilityInfos size failed");
126         return;
127     }
128     for (auto& info : visibilityInfos) {
129         if (!data.WriteParcelable(info)) {
130             WLOGFE("Write windowVisibilityInfo failed");
131             return;
132         }
133     }
134     MessageParcel reply;
135     MessageOption option(MessageOption::TF_ASYNC);
136     if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_VISIBILITY),
137         data, reply, option) != ERR_NONE) {
138         WLOGFE("SendRequest failed");
139     }
140 }
141 
UpdateWindowDrawingContentInfo(const std::vector<sptr<WindowDrawingContentInfo>> & windowDrawingContentInfos)142 void WindowManagerAgentProxy::UpdateWindowDrawingContentInfo(
143     const std::vector<sptr<WindowDrawingContentInfo>>& windowDrawingContentInfos)
144 {
145     MessageParcel data;
146     if (!data.WriteInterfaceToken(GetDescriptor())) {
147         WLOGFE("WriteInterfaceToken failed");
148         return;
149     }
150     if (!data.WriteUint32(static_cast<uint32_t>(windowDrawingContentInfos.size()))) {
151         WLOGFE("write windowDrawingContentInfos size failed");
152         return;
153     }
154     for (auto& info : windowDrawingContentInfos) {
155         if (!data.WriteParcelable(info)) {
156             WLOGFE("Write windowDrawingContentInfos failed");
157             return;
158         }
159     }
160     MessageParcel reply;
161     MessageOption option(MessageOption::TF_ASYNC);
162     if (Remote()->SendRequest(
163         static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_DRAWING_STATE), data, reply,
164         option) != ERR_NONE) {
165         WLOGFE("SendRequest failed");
166     }
167 }
168 
UpdateCameraFloatWindowStatus(uint32_t accessTokenId,bool isShowing)169 void WindowManagerAgentProxy::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
170 {
171     MessageParcel data;
172     if (!data.WriteInterfaceToken(GetDescriptor())) {
173         WLOGFE("WriteInterfaceToken failed");
174         return;
175     }
176 
177     if (!data.WriteUint32(accessTokenId)) {
178         WLOGFE("Write accessTokenId failed");
179         return;
180     }
181 
182     if (!data.WriteBool(isShowing)) {
183         WLOGFE("Write is showing status failed");
184         return;
185     }
186     MessageParcel reply;
187     MessageOption option(MessageOption::TF_ASYNC);
188     if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT),
189         data, reply, option) != ERR_NONE) {
190         WLOGFE("SendRequest failed");
191     }
192 }
193 
NotifyWaterMarkFlagChangedResult(bool showWaterMark)194 void WindowManagerAgentProxy::NotifyWaterMarkFlagChangedResult(bool showWaterMark)
195 {
196     MessageParcel data;
197     if (!data.WriteInterfaceToken(GetDescriptor())) {
198         WLOGFE("WriteInterfaceToken failed");
199         return;
200     }
201 
202     if (!data.WriteBool(showWaterMark)) {
203         WLOGFE("Write is showing status failed");
204         return;
205     }
206     MessageParcel reply;
207     MessageOption option(MessageOption::TF_ASYNC);
208     if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_WATER_MARK_FLAG),
209         data, reply, option) != ERR_NONE) {
210         WLOGFE("SendRequest failed");
211     }
212 }
NotifyGestureNavigationEnabledResult(bool enable)213 void WindowManagerAgentProxy::NotifyGestureNavigationEnabledResult(bool enable)
214 {
215     MessageParcel data;
216     if (!data.WriteInterfaceToken(GetDescriptor())) {
217         WLOGFE("WriteInterfaceToken failed");
218         return;
219     }
220 
221     if (!data.WriteBool(enable)) {
222         WLOGFE("Write is showing status failed");
223         return;
224     }
225     MessageParcel reply;
226     MessageOption option(MessageOption::TF_ASYNC);
227     if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerAgentMsg::TRANS_ID_UPDATE_GESTURE_NAVIGATION_ENABLED),
228         data, reply, option) != ERR_NONE) {
229         WLOGFE("SendRequest failed");
230     }
231 }
232 
233 } // namespace Rosen
234 } // namespace OHOS
235 
236