• 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_stub.h"
17 #include <vector>
18 #include "ipc_skeleton.h"
19 #include "pointer_event.h"
20 #include "window_manager_hilog.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 namespace {
25     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowStub"};
26 }
27 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
29 {
30     if (staticDestroyMonitor_.IsDestroyed()) {
31         WLOGFE("Main thread finished, static data has been destroyed");
32         return -1;
33     }
34     if (data.ReadInterfaceToken() != GetDescriptor()) {
35         WLOGFE("InterfaceToken check failed");
36         return -1;
37     }
38     WindowMessage msgId = static_cast<WindowMessage>(code);
39     switch (msgId) {
40         case WindowMessage::TRANS_ID_UPDATE_WINDOW_RECT: {
41             struct Rect rect { data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32() };
42             bool decoStatus = data.ReadBool();
43             WindowSizeChangeReason reason = static_cast<WindowSizeChangeReason>(data.ReadUint32());
44             UpdateWindowRect(rect, decoStatus, reason);
45             break;
46         }
47         case WindowMessage::TRANS_ID_UPDATE_WINDOW_MODE: {
48             WindowMode mode = static_cast<WindowMode>(data.ReadUint32());
49             UpdateWindowMode(mode);
50             break;
51         }
52         case WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO: {
53             uint32_t modeSupportInfo = data.ReadUint32();
54             UpdateWindowModeSupportInfo(modeSupportInfo);
55             break;
56         }
57         case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: {
58             bool focused = data.ReadBool();
59             UpdateFocusStatus(focused);
60             break;
61         }
62         case WindowMessage::TRANS_ID_UPDATE_AVOID_AREA: {
63             sptr<AvoidArea> avoidArea = data.ReadStrongParcelable<AvoidArea>();
64             uint32_t type;
65             if (!data.ReadUint32(type)) {
66                 return -1;
67             }
68             UpdateAvoidArea(avoidArea, static_cast<AvoidAreaType>(type));
69             break;
70         }
71         case WindowMessage::TRANS_ID_UPDATE_WINDOW_STATE: {
72             UpdateWindowState(static_cast<WindowState>(data.ReadUint32()));
73             break;
74         }
75         case WindowMessage::TRANS_ID_UPDATE_DRAG_EVENT: {
76             PointInfo point;
77             point.x = data.ReadInt32();
78             point.y = data.ReadInt32();
79             DragEvent event = static_cast<DragEvent> (data.ReadUint32());
80             UpdateWindowDragInfo(point, event);
81             break;
82         }
83         case WindowMessage::TRANS_ID_UPDATE_DISPLAY_ID: {
84             UpdateDisplayId(data.ReadUint64(), data.ReadUint64());
85             break;
86         }
87         case WindowMessage::TRANS_ID_UPDATE_OCCUPIED_AREA: {
88             sptr<OccupiedAreaChangeInfo> info = data.ReadParcelable<OccupiedAreaChangeInfo>();
89             UpdateOccupiedAreaChangeInfo(info);
90             break;
91         }
92         case WindowMessage::TRANS_ID_UPDATE_ACTIVE_STATUS: {
93             bool isActive = data.ReadBool();
94             UpdateActiveStatus(isActive);
95             break;
96         }
97         case WindowMessage::TRANS_ID_GET_WINDOW_PROPERTY: {
98             auto property = GetWindowProperty();
99             reply.WriteParcelable(property.GetRefPtr());
100             break;
101         }
102         case WindowMessage::TRANS_ID_NOTIFY_OUTSIDE_PRESSED: {
103             NotifyTouchOutside();
104             break;
105         }
106         case WindowMessage::TRANS_ID_NOTIFY_SCREEN_SHOT: {
107             NotifyScreenshot();
108             break;
109         }
110         case WindowMessage::TRANS_ID_NOTIFY_DESTROY: {
111             NotifyDestroy();
112             break;
113         }
114         case WindowMessage::TRANS_ID_NOTIFY_FOREGROUND: {
115             NotifyForeground();
116             break;
117         }
118         case WindowMessage::TRANS_ID_NOTIFY_BACKGROUND: {
119             NotifyBackground();
120             break;
121         }
122         case WindowMessage::TRANS_ID_DUMP_INFO: {
123             std::vector<std::string> params;
124             if (!data.ReadStringVector(&params)) {
125                 WLOGFE("Fail to read params");
126                 return -1;
127             }
128             DumpInfo(params);
129             break;
130         }
131         case WindowMessage::TRANS_ID_NOTIFY_CLIENT_POINT_UP: {
132             auto pointerEvent = MMI::PointerEvent::Create();
133             if (!pointerEvent->ReadFromParcel(data)) {
134                 WLOGFE("Read Pointer Event failed");
135                 return -1;
136             }
137             NotifyWindowClientPointUp(pointerEvent);
138             break;
139         }
140         case WindowMessage::TRANS_ID_UPDATE_ZOOM_TRANSFORM: {
141             Transform trans;
142             trans.Unmarshalling(data);
143             bool isDisplayZoomOn = data.ReadBool();
144             UpdateZoomTransform(trans, isDisplayZoomOn);
145             break;
146         }
147         case WindowMessage::TRANS_ID_RESTORE_SPLIT_WINDOW_MODE: {
148             RestoreSplitWindowMode(data.ReadUint32());
149             break;
150         }
151         default:
152             break;
153     }
154     return 0;
155 }
156 } // namespace Rosen
157 } // namespace OHOS
158