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         WLOGFE("InterfaceToken check failed");
30         return ERR_TRANSACTION_FAILED;
31     }
32     WLOGI(" code is %{public}d", code);
33     switch (code) {
34         case TRANS_ID_ON_WINDOW_READY: {
35             std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
36             OnWindowReady(surfaceNode);
37             break;
38         }
39         case TRANS_ID_ON_BACK_PRESS: {
40             OnBackPress();
41             break;
42         }
43         case TRANS_ID_ON_KEY_EVENT: {
44             std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
45             if (keyEvent == nullptr) {
46                 WLOGFE("create keyevent failed");
47                 break;
48             }
49             keyEvent->ReadFromParcel(data);
50             OnKeyEvent(keyEvent);
51             break;
52         }
53         case TRANS_ID_ON_POINTER_EVENT: {
54             std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
55             if (pointerEvent == nullptr) {
56                 WLOGFE("create pointer event failed");
57                 break;
58             }
59             pointerEvent->ReadFromParcel(data);
60             OnPointerEvent(pointerEvent);
61             break;
62         }
63         default: {
64             WLOGFW("unknown transaction code %{public}d", code);
65             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
66         }
67     }
68     return ERR_NONE;
69 }
70 } // namespace Rosen
71 } // namespace OHOS