• 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_proxy.h"
17 
18 #include <ipc_types.h>
19 #include <message_option.h>
20 
21 #include "window_manager_hilog.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace {
26     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowExtensionProxy"};
27 }
28 
SetBounds(const Rect & rect)29 void WindowExtensionProxy::SetBounds(const Rect& rect)
30 {
31     MessageParcel data;
32     MessageParcel reply;
33     MessageOption option;
34 
35     if (!data.WriteInterfaceToken(GetDescriptor())) {
36         WLOGFE("write interface token failed");
37         return;
38     }
39     if (!(data.WriteInt32(rect.posX_) && data.WriteInt32(rect.posY_) &&
40         data.WriteInt32(rect.width_) && data.WriteInt32(rect.height_))) {
41         WLOGFE("write rect failed");
42         return;
43     }
44     if (Remote()->SendRequest(TRANS_ID_SETBOUNDS, data, reply, option) != ERR_NONE) {
45         WLOGFE("send request failed");
46         return;
47     }
48 }
49 
Hide()50 void WindowExtensionProxy::Hide()
51 {
52     MessageParcel data;
53     MessageParcel reply;
54     MessageOption option;
55     if (!data.WriteInterfaceToken(GetDescriptor())) {
56         WLOGFE("write interface token failed");
57         return;
58     }
59     if (Remote()->SendRequest(TRANS_ID_HIDE_WINDOW, data, reply, option) != ERR_NONE) {
60         WLOGFE("send request failed");
61     }
62 }
63 
Show()64 void WindowExtensionProxy::Show()
65 {
66     MessageParcel data;
67     MessageParcel reply;
68     MessageOption option;
69     if (!data.WriteInterfaceToken(GetDescriptor())) {
70         WLOGFE("write interface token failed");
71         return;
72     }
73     if (Remote()->SendRequest(TRANS_ID_SHOW_WINDOW, data, reply, option) != ERR_NONE) {
74         WLOGFE("send request failed");
75     }
76 }
77 
GetExtensionWindow(sptr<IWindowExtensionClient> & token)78 void WindowExtensionProxy::GetExtensionWindow(sptr<IWindowExtensionClient>& token)
79 {
80     MessageParcel data;
81     MessageParcel replay;
82     MessageOption option;
83     if (!data.WriteInterfaceToken(GetDescriptor())) {
84         WLOGFE("write interface token failed");
85         return;
86     }
87     if (!data.WriteRemoteObject(token->AsObject())) {
88         WLOGFE("write object failed");
89         return;
90     }
91     if (Remote()->SendRequest(TRANS_ID_CONNECT_TO_EXTENSION, data, replay, option) != ERR_NONE) {
92         WLOGFE("send request failed");
93     }
94 }
95 
RequestFocus()96 void WindowExtensionProxy::RequestFocus()
97 {
98     WLOGI("called.");
99 }
100 } // namespace Rosen
101 } // namespace OHOS