• 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 #ifndef OHOS_ROSEN_WINDOW_EXTENSION_SESSION_IMPL_H
17 #define OHOS_ROSEN_WINDOW_EXTENSION_SESSION_IMPL_H
18 
19 #include <list>
20 
21 #include "accessibility_element_info.h"
22 #include "window_session_impl.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 class WindowExtensionSessionImpl : public WindowSessionImpl {
27 public:
28     explicit WindowExtensionSessionImpl(const sptr<WindowOption>& option);
29     ~WindowExtensionSessionImpl();
30 
31     WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context,
32         const sptr<Rosen::ISession>& iSession) override;
33     WMError MoveTo(int32_t x, int32_t y) override;
34     WMError Resize(uint32_t width, uint32_t height) override;
35     WMError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override;
36     WMError TransferExtensionData(const AAFwk::WantParams& wantParams) override;
37     WSError NotifyTransferComponentData(const AAFwk::WantParams& wantParams) override;
38     void RegisterTransferComponentDataListener(const NotifyTransferComponentDataFunc& func) override;
39     WSErrorCode NotifyTransferComponentDataSync(
40         const AAFwk::WantParams& wantParams, AAFwk::WantParams& reWantParams) override;
41     void RegisterTransferComponentDataForResultListener(
42         const NotifyTransferComponentDataForResultFunc& func) override;
43     void TriggerBindModalUIExtension() override;
44     WMError SetPrivacyMode(bool isPrivacyMode) override;
45     WMError NapiSetUIContent(const std::string& contentInfo, napi_env env,
46         napi_value storage, bool isdistributed, sptr<IRemoteObject> token, AppExecFwk::Ability* ability) override;
47     WSError UpdateRect(const WSRect& rect, SizeChangeReason reason,
48         const std::shared_ptr<RSTransaction>& rsTransaction = nullptr) override;
49 
50     WMError GetAvoidAreaByType(AvoidAreaType type, AvoidArea& avoidArea) override;
51     WSError NotifySearchElementInfoByAccessibilityId(int64_t elementId, int32_t mode, int64_t baseParent,
52         std::list<Accessibility::AccessibilityElementInfo>& infos) override;
53     WSError NotifySearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
54         std::list<Accessibility::AccessibilityElementInfo>& infos) override;
55     WSError NotifyFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
56         Accessibility::AccessibilityElementInfo& info) override;
57     WSError NotifyFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
58         Accessibility::AccessibilityElementInfo& info) override;
59     WSError NotifyExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionAguments,
60         int32_t action, int64_t baseParent) override;
61     WMError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
62         int64_t uiExtensionIdLevel) override;
63     WMError Destroy(bool needNotifyServer, bool needClearListener = true) override;
64 
65     WMError RegisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
66     WMError UnregisterAvoidAreaChangeListener(sptr<IAvoidAreaChangedListener>& listener) override;
67 
68     void NotifyFocusActiveEvent(bool isFocusActive) override;
69     void NotifyFocusStateEvent(bool focusState) override;
70     void NotifyBackpressedEvent(bool& isConsumed) override;
71     void NotifySessionForeground(uint32_t reason, bool withAnimation) override;
72     void NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) override;
73     void NotifyOccupiedAreaChangeInfo(sptr<OccupiedAreaChangeInfo> info) override;
74     WMError RegisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
75     WMError UnregisterOccupiedAreaChangeListener(const sptr<IOccupiedAreaChangeListener>& listener) override;
76     void UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configuration>& configuration) override;
77     static void UpdateConfigurationForAll(const std::shared_ptr<AppExecFwk::Configuration>& configuration);
78     WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) override;
79 
80 protected:
81     NotifyTransferComponentDataFunc notifyTransferComponentDataFunc_;
82     NotifyTransferComponentDataForResultFunc notifyTransferComponentDataForResultFunc_;
83 
84 private:
85     sptr<IOccupiedAreaChangeListener> occupiedAreaChangeListener_;
86     std::optional<std::atomic<bool>> focusState_ = std::nullopt;
87     static std::set<sptr<WindowSessionImpl>> windowExtensionSessionSet_;
88     static std::shared_mutex windowExtensionSessionMutex_;
89 };
90 } // namespace Rosen
91 } // namespace OHOS
92 
93 #endif // OHOS_ROSEN_WINDOW_EXTENSION_SESSION_IMPL_H
94