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_stub.h"
17 #include "ipc_skeleton.h"
18 #include "window_manager_hilog.h"
19 #include "wm_common.h"
20
21 namespace OHOS {
22 namespace Rosen {
23 namespace {
24 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowManagerAgentStub"};
25 }
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 int WindowManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
28 MessageParcel& reply, MessageOption& option)
29 {
30 WLOGFI("WindowManagerAgentStub::OnRemoteRequest code is %{public}d", code);
31 if (data.ReadInterfaceToken() != GetDescriptor()) {
32 WLOGFE("InterfaceToken check failed");
33 return -1;
34 }
35 switch (code) {
36 case TRANS_ID_UPDATE_FOCUS: {
37 sptr<FocusChangeInfo> info = data.ReadParcelable<FocusChangeInfo>();
38 info->abilityToken_ = data.ReadRemoteObject();
39 bool focused = data.ReadBool();
40 UpdateFocusChangeInfo(info, focused);
41 break;
42 }
43 case TRANS_ID_UPDATE_SYSTEM_BAR_PROPS: {
44 DisplayId displayId = data.ReadUint64();
45 SystemBarRegionTints tints;
46 uint32_t size = data.ReadUint32();
47 if (size > data.GetReadableBytes() || size > tints.max_size()) {
48 WLOGFE("fail to get SystemBarRegionTints size");
49 break;
50 }
51 tints.resize(size);
52 if (tints.size() < size) {
53 WLOGFE("fail to resize SystemBarRegionTints");
54 break;
55 }
56 for (uint32_t i = 0; i < size; i++) {
57 WindowType type = static_cast<WindowType>(data.ReadUint32());
58 SystemBarProperty prop = { data.ReadBool(), data.ReadUint32(), data.ReadUint32() };
59 Rect region = { data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32() };
60 SystemBarRegionTint tint(type, prop, region);
61 tints.emplace_back(tint);
62 }
63 UpdateSystemBarRegionTints(displayId, tints);
64 break;
65 }
66 case TRANS_ID_UPDATE_WINDOW_STATUS: {
67 sptr<AccessibilityWindowInfo> windowInfo = data.ReadParcelable<AccessibilityWindowInfo>();
68 WindowUpdateType type = static_cast<WindowUpdateType>(data.ReadUint32());
69 NotifyAccessibilityWindowInfo(windowInfo, type);
70 break;
71 }
72 case TRANS_ID_UPDATE_WINDOW_VISIBILITY: {
73 uint32_t size = data.ReadUint32();
74 std::vector<sptr<WindowVisibilityInfo>> windowVisibilityInfos;
75 if (size > data.GetReadableBytes() || size > windowVisibilityInfos.max_size()) {
76 WLOGFE("fail to get windowVisibilityInfos size.");
77 break;
78 }
79 windowVisibilityInfos.resize(size);
80 if (windowVisibilityInfos.size() < size) {
81 WLOGFE("fail to resize windowVisibilityInfos.");
82 break;
83 }
84 for (uint32_t i = 0; i < size; ++i) {
85 sptr<WindowVisibilityInfo> info = data.ReadParcelable<WindowVisibilityInfo>();
86 windowVisibilityInfos.emplace_back(info);
87 }
88 UpdateWindowVisibilityInfo(windowVisibilityInfos);
89 break;
90 }
91 default:
92 break;
93 }
94 return 0;
95 }
96 } // namespace Rosen
97 } // namespace OHOS
98