• 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_SCENE_EXTENSION_SESSION_H
17 #define OHOS_ROSEN_WINDOW_SCENE_EXTENSION_SESSION_H
18 
19 #include "want.h"
20 
21 #include "session/host/include/session.h"
22 
23 namespace OHOS::Rosen {
24 using NotifyTransferAbilityResultFunc = std::function<void(uint32_t resultCode, const AAFwk::Want& want)>;
25 using NotifyTransferExtensionDataFunc = std::function<void(const AAFwk::WantParams& wantParams)>;
26 using NotifyRemoteReadyFunc = std::function<void()>;
27 using NotifySyncOnFunc = std::function<void()>;
28 using NotifyAsyncOnFunc = std::function<void()>;
29 using NotifyGetAvoidAreaByTypeFunc = std::function<AvoidArea(AvoidAreaType type)>;
30 using NotifyBindModalFunc = std::function<void()>;
31 class ExtensionSession : public Session {
32 public:
33     struct ExtensionSessionEventCallback : public RefBase {
34         NotifyTransferAbilityResultFunc transferAbilityResultFunc_;
35         NotifyTransferExtensionDataFunc transferExtensionDataFunc_;
36         NotifyRemoteReadyFunc notifyRemoteReadyFunc_;
37         NotifySyncOnFunc notifySyncOnFunc_;
38         NotifyAsyncOnFunc notifyAsyncOnFunc_;
39         NotifyGetAvoidAreaByTypeFunc notifyGetAvoidAreaByTypeFunc_;
40         NotifyBindModalFunc notifyBindModalFunc_;
41     };
42 
43     explicit ExtensionSession(const SessionInfo& info);
44     virtual ~ExtensionSession() = default;
45 
46     WSError Connect(const sptr<ISessionStage>& sessionStage, const sptr<IWindowEventChannel>& eventChannel,
47         const std::shared_ptr<RSSurfaceNode>& surfaceNode, SystemSessionConfig& systemConfig,
48         sptr<WindowSessionProperty> property, sptr<IRemoteObject> token, int32_t pid, int32_t uid) override;
49 
50     AvoidArea GetAvoidAreaByType(AvoidAreaType type) override;
51 
52     WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
53     WSError TransferAbilityResult(uint32_t resultCode, const AAFwk::Want& want) override;
54     WSError TransferExtensionData(const AAFwk::WantParams& wantParams) override;
55     WSError TransferComponentData(const AAFwk::WantParams& wantParams);
56     WSErrorCode TransferComponentDataSync(const AAFwk::WantParams& wantParams,
57                                           AAFwk::WantParams& reWantParams);
58     WSError TransferAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
59         int64_t uiExtensionIdLevel) override;
60     void NotifyRemoteReady() override;
61     void NotifySyncOn() override;
62     void NotifyAsyncOn() override;
63     void TriggerBindModalUIExtension() override;
64     void RegisterExtensionSessionEventCallback(const sptr<ExtensionSessionEventCallback>& extSessionEventCallback);
65     sptr<ExtensionSessionEventCallback> GetExtensionSessionEventCallback();
66     WSError Background() override;
67 
68 private:
69     sptr<ExtensionSessionEventCallback> extSessionEventCallback_ = nullptr;
70     bool isFirstTriggerBindModal_ = true;
71 };
72 } // namespace OHOS::Rosen
73 
74 #endif // OHOS_ROSEN_WINDOW_SCENE_EXTENSION_SESSION_H
75