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_stub.h"
17 #include "window_manager_hilog.h"
18
19 namespace OHOS {
20 namespace Rosen {
21 namespace {
22 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowExtensionStub"};
23 }
24
OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)25 int WindowExtensionStub::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 WLOGFD("code is %{public}u", code);
33 switch (code) {
34 case TRANS_ID_SETBOUNDS: {
35 int32_t posX = 0;
36 int32_t posY = 0;
37 uint32_t width = 0;
38 uint32_t height = 0;
39 if (!data.ReadInt32(posX) || !data.ReadInt32(posY) ||
40 !data.ReadUint32(width) || !data.ReadUint32(height)) {
41 WLOGFE("Read rect info failed");
42 return ERR_TRANSACTION_FAILED;
43 }
44 SetBounds({ posX, posY, width, height });
45 break;
46 }
47 case TRANS_ID_HIDE_WINDOW: {
48 Hide();
49 break;
50 }
51 case TRANS_ID_SHOW_WINDOW: {
52 Show();
53 break;
54 }
55 case TRANS_ID_REQUESTFOCUS: {
56 RequestFocus();
57 break;
58 }
59 case TRANS_ID_CONNECT_TO_EXTENSION: {
60 sptr<IRemoteObject> object = data.ReadRemoteObject();
61 sptr<IWindowExtensionClient> token = iface_cast<IWindowExtensionClient>(object);
62 if (token == nullptr) {
63 return -1;
64 }
65 GetExtensionWindow(token);
66 break;
67 }
68 default: {
69 WLOGFW("unknown transaction code %{public}d", code);
70 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
71 }
72 }
73 return ERR_NONE;
74 }
75 } // namespace Rosen
76 } // namespace OHOS
77