1 /*
2 * Copyright (c) 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 "window_extension_client_stub.h"
17
18 #include "window_manager_hilog.h"
19
20 namespace OHOS {
21 namespace Rosen {
22 namespace {
23 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowExtensionClientStub"};
24 }
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)25 int WindowExtensionClientStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
26 MessageParcel& reply, MessageOption& option)
27 {
28 if (data.ReadInterfaceToken() != GetDescriptor()) {
29 // LCOV_EXCL_START
30 WLOGFE("InterfaceToken check failed");
31 return ERR_TRANSACTION_FAILED;
32 // LCOV_EXCL_STOP
33 }
34 WLOGI(" code is %{public}d", code);
35 switch (code) {
36 case TRANS_ID_ON_WINDOW_READY: {
37 std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
38 OnWindowReady(surfaceNode);
39 break;
40 }
41 case TRANS_ID_ON_BACK_PRESS: {
42 OnBackPress();
43 break;
44 }
45 case TRANS_ID_ON_KEY_EVENT: {
46 std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
47 if (keyEvent == nullptr) {
48 // LCOV_EXCL_START
49 WLOGFE("create keyevent failed");
50 break;
51 // LCOV_EXCL_STOP
52 }
53 keyEvent->ReadFromParcel(data);
54 OnKeyEvent(keyEvent);
55 break;
56 }
57 case TRANS_ID_ON_POINTER_EVENT: {
58 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
59 if (pointerEvent == nullptr) {
60 // LCOV_EXCL_START
61 WLOGFE("create pointer event failed");
62 break;
63 // LCOV_EXCL_STOP
64 }
65 pointerEvent->ReadFromParcel(data);
66 OnPointerEvent(pointerEvent);
67 break;
68 }
69 default: {
70 // LCOV_EXCL_START
71 WLOGFW("unknown transaction code %{public}d", code);
72 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
73 // LCOV_EXCL_STOP
74 }
75 }
76 return ERR_NONE;
77 }
78 } // namespace Rosen
79 } // namespace OHOS