• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         // LCOV_EXCL_START
30         WLOGFE("InterfaceToken check failed");
31         return ERR_TRANSACTION_FAILED;
32         // LCOV_EXCL_STOP
33     }
34     WLOGFD("code is %{public}u", code);
35     switch (code) {
36         case TRANS_ID_SETBOUNDS: {
37             int32_t posX = 0;
38             int32_t posY = 0;
39             uint32_t width = 0;
40             uint32_t height = 0;
41             if (!data.ReadInt32(posX) || !data.ReadInt32(posY) ||
42                 !data.ReadUint32(width) || !data.ReadUint32(height)) {
43                 WLOGFE("Read rect info failed");
44                 return ERR_TRANSACTION_FAILED;
45             }
46             SetBounds({ posX, posY, width, height });
47             break;
48         }
49         case TRANS_ID_HIDE_WINDOW: {
50             Hide();
51             break;
52         }
53         case TRANS_ID_SHOW_WINDOW: {
54             Show();
55             break;
56         }
57         case TRANS_ID_REQUESTFOCUS: {
58             RequestFocus();
59             break;
60         }
61         case TRANS_ID_CONNECT_TO_EXTENSION: {
62             sptr<IRemoteObject> object = data.ReadRemoteObject();
63             sptr<IWindowExtensionClient> token = iface_cast<IWindowExtensionClient>(object);
64             if (token == nullptr) {
65                 return -1;
66             }
67             GetExtensionWindow(token);
68             break;
69         }
70         default: {
71             // LCOV_EXCL_START
72             WLOGFW("unknown transaction code %{public}d", code);
73             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
74             // LCOV_EXCL_STOP
75         }
76     }
77     return ERR_NONE;
78 }
79 } // namespace Rosen
80 } // namespace OHOS
81