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             Rect rect {data.ReadInt32(), data.ReadInt32(),
36                 data.ReadInt32(), data.ReadInt32()};
37             SetBounds(rect);
38             break;
39         }
40         case TRANS_ID_HIDE_WINDOW: {
41             Hide();
42             break;
43         }
44         case TRANS_ID_SHOW_WINDOW: {
45             Show();
46             break;
47         }
48         case TRANS_ID_REQUESTFOCUS: {
49             RequestFocus();
50             break;
51         }
52         case TRANS_ID_CONNECT_TO_EXTENSION: {
53             sptr<IRemoteObject> object = data.ReadRemoteObject();
54             sptr<IWindowExtensionClient> token = iface_cast<IWindowExtensionClient>(object);
55             if (token == nullptr) {
56                 return -1;
57             }
58             GetExtensionWindow(token);
59             break;
60         }
61         default: {
62             WLOGFW("unknown transaction code %{public}d", code);
63             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
64         }
65     }
66     return ERR_NONE;
67 }
68 } // namespace Rosen
69 } // namespace OHOS
70