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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_SESSION_WRAPPER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_SESSION_WRAPPER_H 18 19 #include <cstdint> 20 #include <list> 21 #include <map> 22 #include <memory> 23 24 #include "base/geometry/ng/rect_t.h" 25 #include "base/memory/ace_type.h" 26 #include "core/common/window_animation_config.h" 27 #include "core/components_ng/pattern/ui_extension/ui_extension_config.h" 28 29 namespace OHOS { 30 template<typename T> 31 class sptr; 32 33 namespace MMI { 34 class PointerEvent; 35 class KeyEvent; 36 class AxisEvent; 37 } // namespace MMI 38 39 namespace Rosen { 40 class OccupiedAreaChangeInfo; 41 class RSSurfaceNode; 42 class RSTransaction; 43 class AvoidArea; 44 } // namespace Rosen 45 46 namespace AAFwk { 47 class Want; 48 class WantParams; 49 } // namespace AAFwk 50 51 namespace Accessibility { 52 class AccessibilityElementInfo; 53 class AccessibilityEventInfo; 54 } // namespace Accessibility 55 56 } // namespace OHOS 57 58 namespace OHOS::Ace::NG { 59 enum class SessionType : int32_t { 60 EMBEDDED_UI_EXTENSION = 0, 61 UI_EXTENSION_ABILITY = 1, 62 CLOUD_CARD = 2, 63 SECURITY_UI_EXTENSION_ABILITY = 3, 64 }; 65 66 enum class UIExtensionUsage : uint32_t { 67 MODAL = 0, 68 EMBEDDED = 1, 69 CONSTRAINED_EMBEDDED = 2, 70 }; 71 72 struct SessionConfig { 73 bool isAsyncModalBinding = false; 74 UIExtensionUsage uiExtensionUsage = UIExtensionUsage::MODAL; 75 }; 76 77 class SessionWrapper : public AceType { 78 DECLARE_ACE_TYPE(SessionWrapper, AceType); 79 80 public: 81 virtual ~SessionWrapper() = default; 82 83 // About session 84 virtual void CreateSession( 85 const AAFwk::Want& want, const SessionConfig& config) = 0; 86 virtual void DestroySession() = 0; 87 virtual bool IsSessionValid() = 0; 88 virtual int32_t GetSessionId() const = 0; 89 virtual const std::shared_ptr<AAFwk::Want> GetWant() = 0; 90 91 // Synchronous interface for event notify 92 virtual bool NotifyFocusEventSync(bool isFocus) = 0; 93 virtual bool NotifyFocusStateSync(bool focusState) = 0; 94 virtual bool NotifyBackPressedSync() = 0; 95 virtual bool NotifyPointerEventSync(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) = 0; 96 virtual bool NotifyKeyEventSync(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent, bool isPreIme) = 0; 97 virtual bool NotifyKeyEventAsync(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent, bool isPreIme) = 0; 98 virtual bool NotifyAxisEventSync(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) = 0; 99 100 // Asynchronous interface for event notify 101 virtual bool NotifyFocusEventAsync(bool isFocus) = 0; 102 virtual bool NotifyFocusStateAsync(bool focusState) = 0; 103 virtual bool NotifyBackPressedAsync() = 0; 104 virtual bool NotifyPointerEventAsync(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) = 0; 105 virtual bool NotifyKeyEventAsync(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent) = 0; 106 virtual bool NotifyAxisEventAsync(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) = 0; 107 108 // The lifecycle interface 109 virtual void NotifyCreate() = 0; 110 virtual void NotifyForeground() = 0; 111 virtual void NotifyBackground(bool isHandleError = true) = 0; 112 virtual void NotifyDestroy(bool isHandleError = true) = 0; 113 virtual void NotifyConfigurationUpdate() = 0; 114 115 // The interface for responsing provider 116 virtual void OnConnect() = 0; 117 virtual void OnDisconnect(bool isAbnormal) = 0; OnReleaseDone()118 virtual void OnReleaseDone() {} 119 virtual void OnExtensionTimeout(int32_t errorCode) = 0; OnExtensionDetachToDisplay()120 virtual void OnExtensionDetachToDisplay() {}; 121 virtual void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t offset) = 0; 122 123 // The interface about the accessibility 124 virtual void TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType, 125 int64_t timeMs) = 0; 126 virtual void TransferAccessibilityChildTreeRegister(uint32_t windowId, int32_t treeId, int64_t accessibilityId) = 0; 127 virtual void TransferAccessibilityChildTreeDeregister() = 0; 128 virtual void TransferAccessibilityDumpChildInfo( 129 const std::vector<std::string>& params, std::vector<std::string>& info) = 0; 130 131 // The interface to control the display area and the avoid area 132 virtual std::shared_ptr<Rosen::RSSurfaceNode> GetSurfaceNode() const = 0; 133 virtual void NotifyDisplayArea(const RectF& displayArea) = 0; 134 virtual void NotifySizeChangeReason( 135 WindowSizeChangeReason type, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction) = 0; 136 virtual void NotifyOriginAvoidArea(const Rosen::AvoidArea& avoidArea, uint32_t type) const = 0; 137 virtual bool NotifyOccupiedAreaChangeInfo( 138 sptr<Rosen::OccupiedAreaChangeInfo> info, bool needWaitLayout = false) = 0; 139 virtual void SetDensityDpiImpl(bool densityDpi) = 0; 140 141 // The interface to send the data for ArkTS 142 virtual void SendDataAsync(const AAFwk::WantParams& params) const = 0; 143 virtual int32_t SendDataSync(const AAFwk::WantParams& wantParams, AAFwk::WantParams& reWantParams) const = 0; 144 // The interface for UEC dump 145 virtual uint32_t GetReasonDump() const = 0; 146 virtual void NotifyUieDump(const std::vector<std::string>& params, std::vector<std::string>& info) = 0; 147 virtual bool SendBusinessDataSyncReply(UIContentBusinessCode code, AAFwk::Want&& data, AAFwk::Want& reply) = 0; 148 virtual bool SendBusinessData(UIContentBusinessCode code, AAFwk::Want&& data, BusinessDataSendType type) = 0; 149 }; 150 } // namespace OHOS::Ace::NG 151 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_UI_EXTENSION_SESSION_WRAPPER_H 152