• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 
17 #include <want.h>
18 
19 #include "extension_window_impl.h"
20 #include "window_manager_hilog.h"
21 #include "wm_common.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace {
26 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "ExtensionWindowImpl"};
27 }
28 
ExtensionWindowImpl(sptr<Window> sessionImpl)29 Rosen::ExtensionWindowImpl::ExtensionWindowImpl(sptr<Window> sessionImpl)
30     : windowExtensionSessionImpl_(sessionImpl) {
31 }
32 
~ExtensionWindowImpl()33 ExtensionWindowImpl::~ExtensionWindowImpl() {}
34 
GetAvoidAreaByType(AvoidAreaType type,AvoidArea & avoidArea)35 WMError ExtensionWindowImpl::GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea)
36 {
37     WLOGI("GetAvoidAreaByType is called");
38     return windowExtensionSessionImpl_->GetAvoidAreaByType(type, avoidArea);
39 }
40 
GetWindow()41 sptr<Window> ExtensionWindowImpl::GetWindow()
42 {
43     return windowExtensionSessionImpl_;
44 }
45 
HideNonSecureWindows(bool shouldHide)46 WMError ExtensionWindowImpl::HideNonSecureWindows(bool shouldHide)
47 {
48     TLOGI(WmsLogTag::WMS_UIEXT, "HideNonSecureWindows is called");
49     return windowExtensionSessionImpl_->HideNonSecureWindows(shouldHide);
50 }
51 
SetWaterMarkFlag(bool isEnable)52 WMError ExtensionWindowImpl::SetWaterMarkFlag(bool isEnable)
53 {
54     TLOGI(WmsLogTag::WMS_UIEXT, "SetWaterMarkFlag is called");
55     return windowExtensionSessionImpl_->SetWaterMarkFlag(isEnable);
56 }
57 
HidePrivacyContentForHost(bool needHide)58 WMError ExtensionWindowImpl::HidePrivacyContentForHost(bool needHide)
59 {
60     TLOGD(WmsLogTag::WMS_UIEXT, "enter");
61     return windowExtensionSessionImpl_->HidePrivacyContentForHost(needHide);
62 }
63 
IsPcWindow() const64 bool ExtensionWindowImpl::IsPcWindow() const
65 {
66     TLOGI(WmsLogTag::WMS_UIEXT, "in");
67     return windowExtensionSessionImpl_->IsPcWindow();
68 }
69 
IsPcOrPadFreeMultiWindowMode() const70 bool ExtensionWindowImpl::IsPcOrPadFreeMultiWindowMode() const
71 {
72     TLOGI(WmsLogTag::WMS_UIEXT, "in");
73     return windowExtensionSessionImpl_->IsPcOrPadFreeMultiWindowMode();
74 }
75 
OccupyEvents(int32_t eventFlags)76 WMError ExtensionWindowImpl::OccupyEvents(int32_t eventFlags)
77 {
78     TLOGI(WmsLogTag::WMS_UIEXT, "events: %{public}d", eventFlags);
79     auto dataHandler = windowExtensionSessionImpl_->GetExtensionDataHandler();
80     if (!dataHandler) {
81         TLOGE(WmsLogTag::WMS_UIEXT, "null dataHandler");
82         return WMError::WM_ERROR_NULLPTR;
83     }
84 
85     AAFwk::Want want;
86     want.SetParam("type", std::string("OccupyEvents"));
87     want.SetParam("eventFlags", eventFlags);
88     constexpr int32_t customId = 1001;
89     auto ret = dataHandler->SendDataSync(SubSystemId::ARKUI_UIEXT, customId, want);
90     if (ret != DataHandlerErr::OK) {
91         TLOGE(WmsLogTag::WMS_UIEXT, "send failed");
92         return WMError::WM_ERROR_IPC_FAILED;
93     }
94     return WMError::WM_OK;
95 }
96 } // namespace Rosen
97 } // namespace OHOS
98