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_stub.h" 17#include <ipc_skeleton.h> 18#include <key_event.h> 19#include <rs_iwindow_animation_controller.h> 20#include <rs_window_animation_target.h> 21 22#include "marshalling_helper.h" 23#include "memory_guard.h" 24#include "window_manager_hilog.h" 25 26namespace OHOS { 27namespace Rosen { 28namespace { 29constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowManagerStub"}; 30} 31 32int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, 33 MessageOption& option) 34{ 35 MemoryGuard cacheGuard; 36 if (data.ReadInterfaceToken() != GetDescriptor()) { 37 WLOGFE("InterfaceToken check failed"); 38 return ERR_TRANSACTION_FAILED; 39 } 40 auto msgId = static_cast<WindowManagerMessage>(code); 41 switch (msgId) { 42 case WindowManagerMessage::TRANS_ID_CREATE_WINDOW: { 43 sptr<IRemoteObject> windowObject = data.ReadRemoteObject(); 44 sptr<IWindow> windowProxy = iface_cast<IWindow>(windowObject); 45 sptr<WindowProperty> windowProperty = data.ReadStrongParcelable<WindowProperty>(); 46 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data); 47 uint32_t windowId; 48 sptr<IRemoteObject> token = nullptr; 49 if (windowProperty && windowProperty->GetTokenState()) { 50 token = data.ReadRemoteObject(); 51 } 52 WMError errCode = CreateWindow(windowProxy, windowProperty, surfaceNode, windowId, token); 53 reply.WriteUint32(windowId); 54 reply.WriteInt32(static_cast<int32_t>(errCode)); 55 if (windowProperty) { 56 reply.WriteUint32(windowProperty->GetWindowFlags()); 57 reply.WriteUint32(windowProperty->GetApiCompatibleVersion()); 58 } 59 break; 60 } 61 case WindowManagerMessage::TRANS_ID_ADD_WINDOW: { 62 sptr<WindowProperty> windowProperty = data.ReadStrongParcelable<WindowProperty>(); 63 WMError errCode = AddWindow(windowProperty); 64 reply.WriteInt32(static_cast<int32_t>(errCode)); 65 break; 66 } 67 case WindowManagerMessage::TRANS_ID_REMOVE_WINDOW: { 68 uint32_t windowId = 0; 69 if (!data.ReadUint32(windowId)) { 70 TLOGE(WmsLogTag::WMS_LIFE, "TRANS_ID_REMOVE_WINDOW Read windowId failed."); 71 return ERR_INVALID_DATA; 72 } 73 bool isFromInnerkits = false; 74 if (!data.ReadBool(isFromInnerkits)) { 75 TLOGE(WmsLogTag::WMS_LIFE, "TRANS_ID_REMOVE_WINDOW Read isFromInnerkits failed."); 76 return ERR_INVALID_DATA; 77 } 78 WMError errCode = RemoveWindow(windowId, isFromInnerkits); 79 reply.WriteInt32(static_cast<int32_t>(errCode)); 80 break; 81 } 82 case WindowManagerMessage::TRANS_ID_DESTROY_WINDOW: { 83 uint32_t windowId = 0; 84 if (!data.ReadUint32(windowId)) { 85 TLOGE(WmsLogTag::WMS_LIFE, "TRANS_ID_DESTROY_WINDOW Read windowId failed."); 86 return ERR_INVALID_DATA; 87 } 88 WMError errCode = DestroyWindow(windowId); 89 reply.WriteInt32(static_cast<int32_t>(errCode)); 90 break; 91 } 92 case WindowManagerMessage::TRANS_ID_REQUEST_FOCUS: { 93 uint32_t windowId = 0; 94 if (!data.ReadUint32(windowId)) { 95 TLOGE(WmsLogTag::WMS_FOCUS, "read focus failed"); 96 return ERR_INVALID_DATA; 97 } 98 WMError errCode = RequestFocus(windowId); 99 reply.WriteInt32(static_cast<int32_t>(errCode)); 100 break; 101 } 102 case WindowManagerMessage::TRANS_ID_GET_AVOID_AREA: { 103 uint32_t windowId = data.ReadUint32(); 104 uint32_t avoidAreaTypeId = 0; 105 if (!data.ReadUint32(avoidAreaTypeId) || 106 avoidAreaTypeId < static_cast<uint32_t>(AvoidAreaType::TYPE_SYSTEM) || 107 avoidAreaTypeId > static_cast<uint32_t>(AvoidAreaType::TYPE_NAVIGATION_INDICATOR)) { 108 return ERR_INVALID_DATA; 109 } 110 auto avoidAreaType = static_cast<AvoidAreaType>(avoidAreaTypeId); 111 AvoidArea avoidArea = GetAvoidAreaByType(windowId, avoidAreaType); 112 reply.WriteParcelable(&avoidArea); 113 break; 114 } 115 case WindowManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT: { 116 uint32_t windowType = 0; 117 if (!data.ReadUint32(windowType) || 118 windowType >= static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_END)) { 119 return ERR_INVALID_DATA; 120 } 121 auto type = static_cast<WindowManagerAgentType>(windowType); 122 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject(); 123 if (windowManagerAgentObject == nullptr) { 124 return ERR_INVALID_DATA; 125 } 126 sptr<IWindowManagerAgent> windowManagerAgentProxy = 127 iface_cast<IWindowManagerAgent>(windowManagerAgentObject); 128 WMError errCode = RegisterWindowManagerAgent(type, windowManagerAgentProxy); 129 reply.WriteInt32(static_cast<int32_t>(errCode)); 130 break; 131 } 132 case WindowManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT: { 133 uint32_t windowType = 0; 134 if (!data.ReadUint32(windowType) || 135 windowType >= static_cast<uint32_t>(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_END)) { 136 return ERR_INVALID_DATA; 137 } 138 auto type = static_cast<WindowManagerAgentType>(windowType); 139 sptr<IRemoteObject> windowManagerAgentObject = data.ReadRemoteObject(); 140 if (windowManagerAgentObject == nullptr) { 141 return ERR_INVALID_DATA; 142 } 143 sptr<IWindowManagerAgent> windowManagerAgentProxy = 144 iface_cast<IWindowManagerAgent>(windowManagerAgentObject); 145 WMError errCode = UnregisterWindowManagerAgent(type, windowManagerAgentProxy); 146 reply.WriteInt32(static_cast<int32_t>(errCode)); 147 break; 148 } 149 case WindowManagerMessage::TRANS_ID_NOTIFY_READY_MOVE_OR_DRAG: { 150 uint32_t windowId = 0; 151 if (!data.ReadUint32(windowId)) { 152 return ERR_INVALID_DATA; 153 } 154 sptr<WindowProperty> windowProperty = data.ReadStrongParcelable<WindowProperty>(); 155 if (windowProperty == nullptr) { 156 return ERR_INVALID_DATA; 157 } 158 sptr<MoveDragProperty> moveDragProperty = data.ReadStrongParcelable<MoveDragProperty>(); 159 if (moveDragProperty == nullptr) { 160 return ERR_INVALID_DATA; 161 } 162 NotifyServerReadyToMoveOrDrag(windowId, windowProperty, moveDragProperty); 163 break; 164 } 165 case WindowManagerMessage::TRANS_ID_PROCESS_POINT_DOWN: { 166 uint32_t windowId = 0; 167 if (!data.ReadUint32(windowId)) { 168 return ERR_INVALID_DATA; 169 } 170 bool isPointDown = false; 171 if (!data.ReadBool(isPointDown)) { 172 return ERR_INVALID_DATA; 173 } 174 ProcessPointDown(windowId, isPointDown); 175 break; 176 } 177 case WindowManagerMessage::TRANS_ID_PROCESS_POINT_UP: { 178 uint32_t windowId = 0; 179 if (!data.ReadUint32(windowId)) { 180 return ERR_INVALID_DATA; 181 } 182 ProcessPointUp(windowId); 183 break; 184 } 185 case WindowManagerMessage::TRANS_ID_GET_TOP_WINDOW_ID: { 186 uint32_t mainWinId = 0; 187 if (!data.ReadUint32(mainWinId)) { 188 TLOGE(WmsLogTag::WMS_HIERARCHY, "read mainWinId failed"); 189 return ERR_INVALID_DATA; 190 } 191 uint32_t topWinId = 0; 192 WMError errCode = GetTopWindowId(mainWinId, topWinId); 193 reply.WriteUint32(topWinId); 194 reply.WriteInt32(static_cast<int32_t>(errCode)); 195 break; 196 } 197 case WindowManagerMessage::TRANS_ID_MINIMIZE_ALL_APP_WINDOWS: { 198 uint64_t displayId = 0; 199 if (!data.ReadUint64(displayId)) { 200 TLOGE(WmsLogTag::WMS_LIFE, "Read displayID failed."); 201 return ERR_INVALID_DATA; 202 } 203 WMError errCode = MinimizeAllAppWindows(displayId); 204 reply.WriteInt32(static_cast<int32_t>(errCode)); 205 break; 206 } 207 case WindowManagerMessage::TRANS_ID_TOGGLE_SHOWN_STATE_FOR_ALL_APP_WINDOWS: { 208 WMError errCode = ToggleShownStateForAllAppWindows(); 209 reply.WriteInt32(static_cast<int32_t>(errCode)); 210 break; 211 } 212 case WindowManagerMessage::TRANS_ID_UPDATE_LAYOUT_MODE: { 213 uint32_t layoutMode = 0; 214 if (!data.ReadUint32(layoutMode)) { 215 TLOGE(WmsLogTag::WMS_LAYOUT, "read layoutMode failed"); 216 return ERR_INVALID_DATA; 217 } 218 auto mode = static_cast<WindowLayoutMode>(layoutMode); 219 WMError errCode = SetWindowLayoutMode(mode); 220 reply.WriteInt32(static_cast<int32_t>(errCode)); 221 break; 222 } 223 case WindowManagerMessage::TRANS_ID_UPDATE_PROPERTY: { 224 uint32_t actionValue = 0; 225 if (!data.ReadUint32(actionValue)) { 226 TLOGE(WmsLogTag::DEFAULT, "read action error"); 227 return ERR_INVALID_DATA; 228 } 229 auto action = static_cast<PropertyChangeAction>(actionValue); 230 sptr<WindowProperty> windowProperty = new WindowProperty(); 231 windowProperty->Read(data, action); 232 WMError errCode = UpdateProperty(windowProperty, action); 233 reply.WriteInt32(static_cast<int32_t>(errCode)); 234 break; 235 } 236 case WindowManagerMessage::TRANS_ID_GET_ACCESSIBILITY_WINDOW_INFO_ID: { 237 std::vector<sptr<AccessibilityWindowInfo>> infos; 238 WMError errCode = GetAccessibilityWindowInfo(infos); 239 if (!MarshallingHelper::MarshallingVectorParcelableObj<AccessibilityWindowInfo>(reply, infos)) { 240 WLOGFE("Write accessibility window infos failed"); 241 return -1; 242 } 243 reply.WriteInt32(static_cast<int32_t>(errCode)); 244 break; 245 } 246 case WindowManagerMessage::TRANS_ID_GET_UNRELIABLE_WINDOW_INFO_ID: { 247 int32_t windowId = 0; 248 if (!data.ReadInt32(windowId)) { 249 WLOGFE("Failed to readInt32 windowId"); 250 return ERR_INVALID_DATA; 251 } 252 std::vector<sptr<UnreliableWindowInfo>> infos; 253 WMError errCode = GetUnreliableWindowInfo(windowId, infos); 254 if (!MarshallingHelper::MarshallingVectorParcelableObj<UnreliableWindowInfo>(reply, infos)) { 255 WLOGFE("Write unreliable window infos failed"); 256 return ERR_INVALID_DATA; 257 } 258 reply.WriteInt32(static_cast<int32_t>(errCode)); 259 break; 260 } 261 case WindowManagerMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID: { 262 std::vector<sptr<WindowVisibilityInfo>> infos; 263 WMError errCode = GetVisibilityWindowInfo(infos); 264 if (!MarshallingHelper::MarshallingVectorParcelableObj<WindowVisibilityInfo>(reply, infos)) { 265 WLOGFE("Write visibility window infos failed"); 266 return -1; 267 } 268 reply.WriteInt32(static_cast<int32_t>(errCode)); 269 break; 270 } 271 case WindowManagerMessage::TRANS_ID_ANIMATION_SET_CONTROLLER: { 272 sptr<IRemoteObject> controllerObject = data.ReadRemoteObject(); 273 if (controllerObject == nullptr) { 274 TLOGE(WmsLogTag::DEFAULT, "Read animation controller object failed"); 275 return ERR_INVALID_DATA; 276 } 277 sptr<RSIWindowAnimationController> controller = iface_cast<RSIWindowAnimationController>(controllerObject); 278 WMError errCode = SetWindowAnimationController(controller); 279 reply.WriteInt32(static_cast<int32_t>(errCode)); 280 break; 281 } 282 case WindowManagerMessage::TRANS_ID_GET_SYSTEM_CONFIG: { 283 SystemConfig config; 284 WMError errCode = GetSystemConfig(config); 285 reply.WriteParcelable(&config); 286 reply.WriteInt32(static_cast<int32_t>(errCode)); 287 break; 288 } 289 case WindowManagerMessage::TRANS_ID_NOTIFY_WINDOW_TRANSITION: { 290 sptr<WindowTransitionInfo> from = data.ReadParcelable<WindowTransitionInfo>(); 291 sptr<WindowTransitionInfo> to = data.ReadParcelable<WindowTransitionInfo>(); 292 bool isFromClient = false; 293 if (!data.ReadBool(isFromClient)) { 294 return ERR_INVALID_DATA; 295 } 296 WMError errCode = NotifyWindowTransition(from, to, isFromClient); 297 reply.WriteInt32(static_cast<int32_t>(errCode)); 298 break; 299 } 300 case WindowManagerMessage::TRANS_ID_GET_FULLSCREEN_AND_SPLIT_HOT_ZONE: { 301 DisplayId displayId = 0; 302 if (!data.ReadUint64(displayId)) { 303 TLOGE(WmsLogTag::WMS_FOCUS, "read displayId failed"); 304 return ERR_INVALID_DATA; 305 } 306 ModeChangeHotZones hotZones = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; 307 WMError errCode = GetModeChangeHotZones(displayId, hotZones); 308 reply.WriteInt32(static_cast<int32_t>(errCode)); 309 310 reply.WriteInt32(hotZones.fullscreen_.posX_); 311 reply.WriteInt32(hotZones.fullscreen_.posY_); 312 reply.WriteUint32(hotZones.fullscreen_.width_); 313 reply.WriteUint32(hotZones.fullscreen_.height_); 314 315 reply.WriteInt32(hotZones.primary_.posX_); 316 reply.WriteInt32(hotZones.primary_.posY_); 317 reply.WriteUint32(hotZones.primary_.width_); 318 reply.WriteUint32(hotZones.primary_.height_); 319 320 reply.WriteInt32(hotZones.secondary_.posX_); 321 reply.WriteInt32(hotZones.secondary_.posY_); 322 reply.WriteUint32(hotZones.secondary_.width_); 323 reply.WriteUint32(hotZones.secondary_.height_); 324 break; 325 } 326 case WindowManagerMessage::TRANS_ID_GET_ANIMATION_CALLBACK: { 327 std::vector<uint32_t> windowIds; 328 data.ReadUInt32Vector(&windowIds); 329 bool isAnimated = data.ReadBool(); 330 sptr<RSIWindowAnimationFinishedCallback> finishedCallback = nullptr; 331 MinimizeWindowsByLauncher(windowIds, isAnimated, finishedCallback); 332 if (finishedCallback == nullptr) { 333 if (!reply.WriteBool(false)) { 334 WLOGFE("finishedCallback is nullptr and failed to write!"); 335 return ERR_INVALID_DATA; 336 } 337 } else { 338 if (!reply.WriteBool(true) || !reply.WriteRemoteObject(finishedCallback->AsObject())) { 339 WLOGFE("finishedCallback is not nullptr and failed to write!"); 340 return ERR_INVALID_DATA; 341 } 342 } 343 break; 344 } 345 case WindowManagerMessage::TRANS_ID_UPDATE_AVOIDAREA_LISTENER: { 346 uint32_t windowId = 0; 347 if (!data.ReadUint32(windowId)) { 348 return ERR_INVALID_DATA; 349 } 350 bool haveAvoidAreaListener = false; 351 if (!data.ReadBool(haveAvoidAreaListener)) { 352 return ERR_INVALID_DATA; 353 } 354 WMError errCode = UpdateAvoidAreaListener(windowId, haveAvoidAreaListener); 355 reply.WriteInt32(static_cast<int32_t>(errCode)); 356 break; 357 } 358 case WindowManagerMessage::TRANS_ID_UPDATE_RS_TREE: { 359 uint32_t windowId = 0; 360 if (!data.ReadUint32(windowId)) { 361 return ERR_INVALID_DATA; 362 } 363 bool isAdd = false; 364 if (!data.ReadBool(isAdd)) { 365 return ERR_INVALID_DATA; 366 } 367 WMError errCode = UpdateRsTree(windowId, isAdd); 368 reply.WriteInt32(static_cast<int32_t>(errCode)); 369 break; 370 } 371 case WindowManagerMessage::TRANS_ID_BIND_DIALOG_TARGET: { 372 uint32_t windowId = data.ReadUint32(); 373 sptr<IRemoteObject> targetToken = data.ReadRemoteObject(); 374 if (targetToken == nullptr) { 375 TLOGE(WmsLogTag::WMS_DIALOG, "Read targetToken object failed!"); 376 return ERR_INVALID_DATA; 377 } 378 WMError errCode = BindDialogTarget(windowId, targetToken); 379 reply.WriteInt32(static_cast<int32_t>(errCode)); 380 break; 381 } 382 case WindowManagerMessage::TRANS_ID_SET_ANCHOR_AND_SCALE : { 383 int32_t x = 0; 384 int32_t y = 0; 385 if (!data.ReadInt32(x) || !data.ReadInt32(y)) { 386 return ERR_INVALID_DATA; 387 } 388 float scale = 0.0f; 389 if (!data.ReadFloat(scale)) { 390 return ERR_INVALID_DATA; 391 } 392 SetAnchorAndScale(x, y, scale); 393 break; 394 } 395 case WindowManagerMessage::TRANS_ID_SET_ANCHOR_OFFSET: { 396 int32_t deltaX = 0; 397 int32_t deltaY = 0; 398 if (!data.ReadInt32(deltaX) || !data.ReadInt32(deltaY)) { 399 return ERR_INVALID_DATA; 400 } 401 SetAnchorOffset(deltaX, deltaY); 402 break; 403 } 404 case WindowManagerMessage::TRANS_ID_OFF_WINDOW_ZOOM: { 405 OffWindowZoom(); 406 break; 407 } 408 case WindowManagerMessage::TRANS_ID_RAISE_WINDOW_Z_ORDER: { 409 uint32_t windowId = 0; 410 if (!data.ReadUint32(windowId)) { 411 TLOGE(WmsLogTag::WMS_HIERARCHY, "read windowId failed"); 412 return ERR_INVALID_DATA; 413 } 414 WMError errCode = RaiseToAppTop(windowId); 415 reply.WriteInt32(static_cast<int32_t>(errCode)); 416 break; 417 } 418 case WindowManagerMessage::TRANS_ID_GET_SNAPSHOT: { 419 uint32_t windowId = 0; 420 if (!data.ReadUint32(windowId)) { 421 TLOGE(WmsLogTag::DEFAULT, "read windowId error"); 422 return ERR_INVALID_DATA; 423 } 424 std::shared_ptr<Media::PixelMap> pixelMap = GetSnapshot(windowId); 425 reply.WriteParcelable(pixelMap.get()); 426 break; 427 } 428 case WindowManagerMessage::TRANS_ID_GESTURE_NAVIGATION_ENABLED: { 429 bool enable = data.ReadBool(); 430 WMError errCode = SetGestureNavigationEnabled(enable); 431 reply.WriteInt32(static_cast<int32_t>(errCode)); 432 break; 433 } 434 case WindowManagerMessage::TRANS_ID_SET_WINDOW_GRAVITY: { 435 uint32_t windowId = INVALID_WINDOW_ID; 436 if (!data.ReadUint32(windowId)) { 437 TLOGE(WmsLogTag::WMS_KEYBOARD, "Read windowId failed."); 438 return ERR_INVALID_DATA; 439 } 440 uint32_t gravityValue = 0; 441 if (!data.ReadUint32(gravityValue) || 442 gravityValue < static_cast<uint32_t>(WindowGravity::WINDOW_GRAVITY_FLOAT) || 443 gravityValue > static_cast<uint32_t>(WindowGravity::WINDOW_GRAVITY_BOTTOM)) { 444 TLOGE(WmsLogTag::WMS_KEYBOARD, "Window gravity value read failed, gravityValue: %{public}d", 445 gravityValue); 446 return ERR_INVALID_DATA; 447 } 448 WindowGravity gravity = static_cast<WindowGravity>(gravityValue); 449 uint32_t percent = 0; 450 if (!data.ReadUint32(percent)) { 451 TLOGE(WmsLogTag::WMS_KEYBOARD, "Percent read failed."); 452 return ERR_INVALID_DATA; 453 } 454 WMError errCode = SetWindowGravity(windowId, gravity, percent); 455 reply.WriteInt32(static_cast<int32_t>(errCode)); 456 break; 457 } 458 case WindowManagerMessage::TRANS_ID_DISPATCH_KEY_EVENT: { 459 uint32_t windowId = 0; 460 if (!data.ReadUint32(windowId)) { 461 TLOGE(WmsLogTag::WMS_EVENT, "Read failed!"); 462 return ERR_INVALID_DATA; 463 } 464 std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create(); 465 if (event == nullptr) { 466 TLOGE(WmsLogTag::WMS_EVENT, "event is null"); 467 return ERR_INVALID_DATA; 468 } 469 event->ReadFromParcel(data); 470 DispatchKeyEvent(windowId, event); 471 break; 472 } 473 case WindowManagerMessage::TRANS_ID_NOTIFY_DUMP_INFO_RESULT: { 474 std::vector<std::string> info; 475 if (!data.ReadStringVector(&info)) { 476 return ERR_INVALID_DATA; 477 } 478 NotifyDumpInfoResult(info); 479 break; 480 } 481 case WindowManagerMessage::TRANS_ID_GET_WINDOW_ANIMATION_TARGETS: { 482 std::vector<uint32_t> missionIds; 483 if (!data.ReadUInt32Vector(&missionIds)) { 484 TLOGE(WmsLogTag::DEFAULT, "Read animation target mission ids failed"); 485 return ERR_INVALID_DATA; 486 } 487 std::vector<sptr<RSWindowAnimationTarget>> targets; 488 WMError errCode = GetWindowAnimationTargets(missionIds, targets); 489 if (!MarshallingHelper::MarshallingVectorParcelableObj<RSWindowAnimationTarget>(reply, targets)) { 490 WLOGFE("Write window animation targets failed"); 491 return ERR_INVALID_DATA; 492 } 493 reply.WriteInt32(static_cast<int32_t>(errCode)); 494 break; 495 } 496 case WindowManagerMessage::TRANS_ID_SET_MAXIMIZE_MODE: { 497 uint32_t modeId = 0; 498 if (!data.ReadUint32(modeId) || modeId >= static_cast<uint32_t>(MaximizeMode::MODE_END)) { 499 return ERR_INVALID_DATA; 500 } 501 MaximizeMode maximizeMode = static_cast<MaximizeMode>(modeId); 502 SetMaximizeMode(maximizeMode); 503 break; 504 } 505 case WindowManagerMessage::TRANS_ID_GET_MAXIMIZE_MODE: { 506 MaximizeMode maximizeMode = GetMaximizeMode(); 507 reply.WriteInt32(static_cast<int32_t>(maximizeMode)); 508 break; 509 } 510 case WindowManagerMessage::TRANS_ID_GET_FOCUS_WINDOW_INFO: { 511 FocusChangeInfo focusInfo; 512 GetFocusWindowInfo(focusInfo); 513 reply.WriteParcelable(&focusInfo); 514 break; 515 } 516 default: 517 WLOGFW("unknown transaction code %{public}d", code); 518 return IPCObjectStub::OnRemoteRequest(code, data, reply, option); 519 } 520 return ERR_NONE; 521} 522} // namespace Rosen 523} // namespace OHOS 524