1 /*
2 * Copyright (c) 2021-2022 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 "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, "WindowManagerAgentStub"};
26 }
27
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int WindowManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
29 MessageParcel& reply, MessageOption& option)
30 {
31 WLOGFD("code is %{public}u", code);
32 if (data.ReadInterfaceToken() != GetDescriptor()) {
33 WLOGFE("InterfaceToken check failed");
34 return -1;
35 }
36 WindowManagerAgentMsg msgId = static_cast<WindowManagerAgentMsg>(code);
37 switch (msgId) {
38 case WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS: {
39 sptr<FocusChangeInfo> info = data.ReadParcelable<FocusChangeInfo>();
40 bool focused = data.ReadBool();
41 UpdateFocusChangeInfo(info, focused);
42 break;
43 }
44 case WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS: {
45 DisplayId displayId = data.ReadUint64();
46 SystemBarRegionTints tints;
47 bool res = MarshallingHelper::UnmarshallingVectorObj<SystemBarRegionTint>(data, tints,
48 [](Parcel& parcel, SystemBarRegionTint& tint) {
49 uint32_t type;
50 SystemBarProperty prop;
51 Rect region;
52 bool res = parcel.ReadUint32(type) && parcel.ReadBool(prop.enable_) &&
53 parcel.ReadUint32(prop.backgroundColor_) && parcel.ReadUint32(prop.contentColor_) &&
54 parcel.ReadInt32(region.posX_) && parcel.ReadInt32(region.posY_) &&
55 parcel.ReadUint32(region.width_) && parcel.ReadUint32(region.height_);
56 tint.type_ = static_cast<WindowType>(type);
57 tint.prop_ = prop;
58 tint.region_ = region;
59 return res;
60 }
61 );
62 if (!res) {
63 WLOGFE("fail to read SystemBarRegionTints.");
64 break;
65 }
66 UpdateSystemBarRegionTints(displayId, tints);
67 break;
68 }
69 case WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STATUS: {
70 std::vector<sptr<AccessibilityWindowInfo>> infos;
71 if (!MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(data, infos)) {
72 WLOGFE("read accessibility window infos failed");
73 return -1;
74 }
75 WindowUpdateType type = static_cast<WindowUpdateType>(data.ReadUint32());
76 NotifyAccessibilityWindowInfo(infos, type);
77 break;
78 }
79 case WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_VISIBILITY: {
80 std::vector<sptr<WindowVisibilityInfo>> infos;
81 if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(data, infos)) {
82 WLOGFE("fail to read WindowVisibilityInfo.");
83 break;
84 }
85 UpdateWindowVisibilityInfo(infos);
86 break;
87 }
88 case WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT: {
89 uint32_t accessTokenId = data.ReadUint32();
90 bool isShowing = data.ReadBool();
91 UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
92 break;
93 }
94 case WindowManagerAgentMsg::TRANS_ID_UPDATE_WATER_MARK_FLAG: {
95 bool showWaterMark = data.ReadBool();
96 NotifyWaterMarkFlagChangedResult(showWaterMark);
97 break;
98 }
99 case WindowManagerAgentMsg::TRANS_ID_UPDATE_GESTURE_NAVIGATION_ENABLED: {
100 bool enbale = data.ReadBool();
101 NotifyGestureNavigationEnabledResult(enbale);
102 break;
103 }
104 default:
105 WLOGFW("unknown transaction code %{public}d", code);
106 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
107 }
108 return 0;
109 }
110 } // namespace Rosen
111 } // namespace OHOS
112