• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     WLOGFI("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             if (info != nullptr) {
41                 info->abilityToken_ = data.ReadRemoteObject();
42             }
43             bool focused = data.ReadBool();
44             UpdateFocusChangeInfo(info, focused);
45             break;
46         }
47         case WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS: {
48             DisplayId displayId = data.ReadUint64();
49             SystemBarRegionTints tints;
50             bool res = MarshallingHelper::UnmarshallingVectorObj<SystemBarRegionTint>(data, tints,
51                 [](Parcel& parcel, SystemBarRegionTint& tint) {
52                     uint32_t type;
53                     SystemBarProperty prop;
54                     Rect region;
55                     bool res = parcel.ReadUint32(type) && parcel.ReadBool(prop.enable_) &&
56                         parcel.ReadUint32(prop.backgroundColor_) && parcel.ReadUint32(prop.contentColor_) &&
57                         parcel.ReadInt32(region.posX_) && parcel.ReadInt32(region.posY_) &&
58                         parcel.ReadUint32(region.width_) && parcel.ReadUint32(region.height_);
59                     tint.type_ = static_cast<WindowType>(type);
60                     tint.prop_ = prop;
61                     tint.region_ = region;
62                     return res;
63                 }
64             );
65             if (!res) {
66                 WLOGFE("fail to read SystemBarRegionTints.");
67                 break;
68             }
69             UpdateSystemBarRegionTints(displayId, tints);
70             break;
71         }
72         case WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STATUS: {
73             std::vector<sptr<AccessibilityWindowInfo>> infos;
74             if (!MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(data, infos)) {
75                 WLOGFE("read accessibility window infos failed");
76                 return -1;
77             }
78             WindowUpdateType type = static_cast<WindowUpdateType>(data.ReadUint32());
79             NotifyAccessibilityWindowInfo(infos, type);
80             break;
81         }
82         case WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_VISIBILITY: {
83             std::vector<sptr<WindowVisibilityInfo>> infos;
84             if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(data, infos)) {
85                 WLOGFE("fail to read WindowVisibilityInfo.");
86                 break;
87             }
88             UpdateWindowVisibilityInfo(infos);
89             break;
90         }
91         case WindowManagerAgentMsg::TRANS_ID_UPDATE_CAMERA_FLOAT: {
92             uint32_t accessTokenId = data.ReadUint32();
93             bool isShowing = data.ReadBool();
94             UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
95             break;
96         }
97         default:
98             break;
99     }
100     return 0;
101 }
102 } // namespace Rosen
103 } // namespace OHOS
104