• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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_COMMON_CONTAINER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_CONTAINER_H
18 
19 #include <atomic>
20 #include <functional>
21 #include <mutex>
22 #include <unordered_map>
23 
24 #include "interfaces/inner_api/ace/ace_forward_compatibility.h"
25 #include "interfaces/inner_api/ace/constants.h"
26 #include "interfaces/inner_api/ace/navigation_controller.h"
27 
28 #include "base/memory/ace_type.h"
29 #include "base/view_data/hint_to_type_wrap.h"
30 #include "base/resource/asset_manager.h"
31 #include "base/resource/shared_image_manager.h"
32 #include "base/thread/task_executor.h"
33 #include "base/utils/macros.h"
34 #include "base/utils/noncopyable.h"
35 #include "base/utils/system_properties.h"
36 #include "base/utils/utils.h"
37 #include "core/common/ace_application_info.h"
38 #include "core/common/container_consts.h"
39 #include "core/common/display_info.h"
40 #include "core/common/display_info_utils.h"
41 #include "core/common/frontend.h"
42 #include "core/common/page_url_checker.h"
43 #include "core/common/platform_res_register.h"
44 #include "core/common/resource/resource_configuration.h"
45 #include "core/common/settings.h"
46 #include "core/common/window.h"
47 #include "core/components/common/layout/constants.h"
48 #include "core/components_ng/base/distributed_ui.h"
49 #include "core/components_ng/pattern/app_bar/app_bar_view.h"
50 #include "core/components_ng/pattern/navigation/navigation_route.h"
51 #include "core/components_ng/pattern/navigator/navigator_event_hub.h"
52 #include "core/event/non_pointer_event.h"
53 #include "core/event/pointer_event.h"
54 #include "core/pipeline/pipeline_base.h"
55 
56 namespace OHOS::Ace {
57 
58 using PageTask = std::function<void()>;
59 using TouchEventCallback = std::function<void(const TouchEvent&, const std::function<void()>&,
60     const RefPtr<NG::FrameNode>&)>;
61 using KeyEventCallback = std::function<bool(const KeyEvent&)>;
62 using NonPointerEventCallback = std::function<bool(const NonPointerEvent&, const std::function<void()>&)>;
63 using MouseEventCallback = std::function<void(const MouseEvent&, const std::function<void()>&,
64     const RefPtr<NG::FrameNode>&)>;
65 using AxisEventCallback = std::function<void(const AxisEvent&, const std::function<void()>&,
66     const RefPtr<NG::FrameNode>&)>;
67 using RotationEventCallBack = std::function<bool(const RotationEvent&)>;
68 using CardViewPositionCallBack = std::function<void(int id, float offsetX, float offsetY)>;
69 using DragEventCallBack = std::function<void(const DragPointerEvent&, const DragEventAction&,
70     const RefPtr<NG::FrameNode>&)>;
71 using StopDragCallback = std::function<void()>;
72 
73 class ACE_FORCE_EXPORT Container : public virtual AceType {
74     DECLARE_ACE_TYPE(Container, AceType);
75 
76 public:
77     Container() = default;
78     ~Container() override = default;
79 
80     virtual void Initialize() = 0;
81 
82     virtual void Destroy() = 0;
83 
SetAppRunningUniqueId(const std::string & uniqueId)84     virtual void SetAppRunningUniqueId(const std::string& uniqueId) {};
85 
GetAppRunningUniqueId()86     virtual const std::string& GetAppRunningUniqueId() const
87     {
88         static const std::string res;
89         return res;
90     }
91 
IsKeyboard()92     virtual bool IsKeyboard()
93     {
94         return false;
95     }
96 
DestroyView()97     virtual void DestroyView() {}
98     virtual bool UpdatePopupUIExtension(const RefPtr<NG::FrameNode>& node,
99         uint32_t autoFillSessionId, bool isNative = true)
100     {
101         return false;
102     }
103 
ClosePopupUIExtension(uint32_t autoFillSessionId)104     virtual bool ClosePopupUIExtension(uint32_t autoFillSessionId)
105     {
106         return false;
107     }
108 
PlaceHolderToType(const std::string & onePlaceHolder)109     virtual HintToTypeWrap PlaceHolderToType(const std::string& onePlaceHolder)
110     {
111         HintToTypeWrap hintToTypeWrap;
112         return hintToTypeWrap;
113     }
114 
115     // Get the instance id of this container
116     virtual int32_t GetInstanceId() const = 0;
117 
118     // Get the ability name of this container
119     virtual std::string GetHostClassName() const = 0;
120 
121     // Get the frontend of container
122     virtual RefPtr<Frontend> GetFrontend() const = 0;
123 
124     // Get task executor.
125     virtual RefPtr<TaskExecutor> GetTaskExecutor() const = 0;
126 
127     // Get assert manager.
128     virtual RefPtr<AssetManager> GetAssetManager() const = 0;
129 
130     // Get platform resource register.
131     virtual RefPtr<PlatformResRegister> GetPlatformResRegister() const = 0;
132 
133     // Get the pipelineContext of container.
134     virtual RefPtr<PipelineBase> GetPipelineContext() const = 0;
135 
136     // Dump container.
137     virtual bool Dump(const std::vector<std::string>& params, std::vector<std::string>& info);
138 
139     // Get the width/height of the view
140     virtual int32_t GetViewWidth() const = 0;
141     virtual int32_t GetViewHeight() const = 0;
142     virtual int32_t GetViewPosX() const = 0;
143     virtual int32_t GetViewPosY() const = 0;
144 
145     virtual uint32_t GetWindowId() const = 0;
SetWindowId(uint32_t windowId)146     virtual void SetWindowId(uint32_t windowId) {}
WindowIsShow()147     virtual bool WindowIsShow() const
148     {
149         return false;
150     }
151 
152     virtual RefPtr<AceView> GetAceView() const = 0;
153 
154     virtual void* GetView() const = 0;
155 
156     // Trigger garbage collection
TriggerGarbageCollection()157     virtual void TriggerGarbageCollection() {}
158 
DumpHeapSnapshot(bool isPrivate)159     virtual void DumpHeapSnapshot(bool isPrivate) {}
160 
DestroyHeapProfiler()161     virtual void DestroyHeapProfiler() {}
162 
ForceFullGC()163     virtual void ForceFullGC() {}
164 
NotifyFontNodes()165     virtual void NotifyFontNodes() {}
166 
NotifyAppStorage(const std::string & key,const std::string & value)167     virtual void NotifyAppStorage(const std::string& key, const std::string& value) {}
168 
SetCardFrontend(WeakPtr<Frontend> frontend,int64_t cardId)169     virtual void SetCardFrontend(WeakPtr<Frontend> frontend, int64_t cardId) {}
170 
GetCardFrontend(int64_t cardId)171     virtual WeakPtr<Frontend> GetCardFrontend(int64_t cardId) const
172     {
173         return nullptr;
174     }
175 
SetCardPipeline(WeakPtr<PipelineBase>,int64_t cardId)176     virtual void SetCardPipeline(WeakPtr<PipelineBase>, int64_t cardId) {}
177 
GetCardPipeline(int64_t cardId)178     virtual WeakPtr<PipelineBase> GetCardPipeline(int64_t cardId) const
179     {
180         return nullptr;
181     }
182 
183     // Get MultiModal ptr.
GetMutilModalPtr()184     virtual uintptr_t GetMutilModalPtr() const
185     {
186         return 0;
187     }
188 
ProcessScreenOnEvents()189     virtual void ProcessScreenOnEvents() {}
190 
ProcessScreenOffEvents()191     virtual void ProcessScreenOffEvents() {}
192 
SetOrientation(Orientation orientation)193     virtual void SetOrientation(Orientation orientation) {}
194 
GetOrientation()195     virtual Orientation GetOrientation()
196     {
197         return Orientation::UNSPECIFIED;
198     }
199 
200     virtual RefPtr<DisplayInfo> GetDisplayInfo();
201 
202     virtual void InitIsFoldable();
203 
204     virtual bool IsFoldable();
205 
206     virtual FoldStatus GetCurrentFoldStatus();
207 
208     virtual std::vector<Rect> GetCurrentFoldCreaseRegion();
209 
GetKeyboardSafeArea()210     virtual NG::SafeAreaInsets GetKeyboardSafeArea()
211     {
212         return {};
213     }
214 
GetHapPath()215     virtual std::string GetHapPath() const
216     {
217         return {};
218     }
219 
GetWebHapPath()220     virtual std::string GetWebHapPath() const
221     {
222         return {};
223     }
224 
SetCreateTime(std::chrono::time_point<std::chrono::high_resolution_clock> time)225     void SetCreateTime(std::chrono::time_point<std::chrono::high_resolution_clock> time)
226     {
227         createTime_ = time;
228     }
229 
IsFirstUpdate()230     bool IsFirstUpdate() const
231     {
232         return firstUpdateData_;
233     }
234 
AlreadyFirstUpdate()235     void AlreadyFirstUpdate()
236     {
237         firstUpdateData_ = false;
238     }
239 
SetBundleName(const std::string & bundleName)240     void SetBundleName(const std::string& bundleName)
241     {
242         bundleName_ = bundleName;
243     }
244 
GetBundleName()245     const std::string& GetBundleName() const
246     {
247         return bundleName_;
248     }
249 
SetModuleName(const std::string & moduleName)250     void SetModuleName(const std::string& moduleName)
251     {
252         moduleName_ = moduleName;
253     }
254 
GetModuleName()255     std::string GetModuleName() const
256     {
257         return moduleName_;
258     }
259 
IsMainWindow()260     virtual bool IsMainWindow() const { return false; }
IsSubWindow()261     virtual bool IsSubWindow() const { return false; }
IsDialogWindow()262     virtual bool IsDialogWindow() const { return false; }
IsSystemWindow()263     virtual bool IsSystemWindow() const { return false; }
IsHostMainWindow()264     virtual bool IsHostMainWindow() const { return false; }
IsHostSubWindow()265     virtual bool IsHostSubWindow() const { return false; }
IsHostDialogWindow()266     virtual bool IsHostDialogWindow() const { return false; }
IsHostSystemWindow()267     virtual bool IsHostSystemWindow() const { return false; }
IsHostScenceBoardWindow()268     virtual bool IsHostScenceBoardWindow() const { return false; }
IsSubContainer()269     virtual bool IsSubContainer() const { return false; }
IsFormRender()270     virtual bool IsFormRender() const { return false; }
GetParentMainWindowId(uint32_t currentWindowId)271     virtual uint32_t GetParentMainWindowId(uint32_t currentWindowId) const
272     {
273         return 0;
274     }
275 
SetIsFormRender(bool isFormRender)276     virtual void SetIsFormRender(bool isFormRender) {};
277 
GetCardHapPath()278     const std::string& GetCardHapPath() const
279     {
280         return cardHapPath_;
281     }
282 
283     bool UpdateState(const Frontend::State& state);
284 
GetSettings()285     Settings& GetSettings()
286     {
287         return settings_;
288     }
289 
SetBundlePath(const std::string & path)290     void SetBundlePath(const std::string& path)
291     {
292         bundlePath_ = path;
293     }
294 
GetBundlePath()295     const std::string& GetBundlePath() const
296     {
297         return bundlePath_;
298     }
299 
SetFilesDataPath(const std::string & path)300     void SetFilesDataPath(const std::string& path)
301     {
302         filesDataPath_ = path;
303     }
304 
GetFilesDataPath()305     const std::string& GetFilesDataPath() const
306     {
307         return filesDataPath_;
308     }
309 
SetTempDir(const std::string & path)310     void SetTempDir(const std::string& path)
311     {
312         tempDir_ = path;
313     }
314 
GetTempDir()315     const std::string& GetTempDir() const
316     {
317         return tempDir_;
318     }
319 
SetViewFirstUpdating(std::chrono::time_point<std::chrono::high_resolution_clock> time)320     virtual void SetViewFirstUpdating(std::chrono::time_point<std::chrono::high_resolution_clock> time) {}
321 
UpdateResourceConfiguration(const std::string & jsonStr)322     virtual void UpdateResourceConfiguration(const std::string& jsonStr) {}
323 
324     static int32_t SafelyId();
325     static int32_t CurrentId();
326     static int32_t CurrentIdSafely();
327     static int32_t CurrentIdSafelyWithCheck();
328     static RefPtr<Container> Current();
329     static RefPtr<Container> CurrentSafely();
330     static RefPtr<Container> CurrentSafelyWithCheck();
331     static RefPtr<Container> GetContainer(int32_t containerId);
332     static RefPtr<Container> GetActive();
333     static RefPtr<Container> GetDefault();
334     static RefPtr<Container> GetFoucsed();
335     static RefPtr<TaskExecutor> CurrentTaskExecutor();
336     static RefPtr<TaskExecutor> CurrentTaskExecutorSafely();
337     static RefPtr<TaskExecutor> CurrentTaskExecutorSafelyWithCheck();
338     static void UpdateCurrent(int32_t id);
339 
SetUseNewPipeline()340     void SetUseNewPipeline()
341     {
342         useNewPipeline_ = true;
343     }
344 
SetUsePartialUpdate()345     void SetUsePartialUpdate()
346     {
347         usePartialUpdate_ = true;
348     }
349 
IsUseNewPipeline()350     bool IsUseNewPipeline() const
351     {
352         return useNewPipeline_;
353     }
354 
IsCurrentUseNewPipeline()355     static bool IsCurrentUseNewPipeline()
356     {
357         auto container = Current();
358         return container ? container->useNewPipeline_ : AceForwardCompatibility::IsUseNG();
359     }
360 
361     // SetCurrentUsePartialUpdate is called when initial render on a page
362     // starts, see zyz_view_register loadDocument() implementation
IsCurrentUsePartialUpdate()363     static bool IsCurrentUsePartialUpdate()
364     {
365         auto container = Current();
366         return container ? container->usePartialUpdate_ : false;
367     }
368 
369     static void SetCurrentUsePartialUpdate(bool useIt = false)
370     {
371         auto container = Current();
372         if (container) {
373             container->usePartialUpdate_ = useIt;
374         }
375     }
376 
IsInFormContainer()377     static bool IsInFormContainer() {
378         auto container = Current();
379         return container ? container->isFRSCardContainer_ : false;
380     }
381 
IsInSubContainer()382     static bool IsInSubContainer()
383     {
384         auto container = Current();
385         return container ? container->IsSubContainer() : false;
386     }
387 
GetWindow()388     Window* GetWindow() const
389     {
390         auto context = GetPipelineContext();
391         return context ? context->GetWindow() : nullptr;
392     }
393 
IsUseStageModel()394     virtual bool IsUseStageModel() const
395     {
396         return false;
397     }
398 
GetCardFrontendMap(std::unordered_map<int64_t,WeakPtr<Frontend>> & cardFrontendMap)399     virtual void GetCardFrontendMap(std::unordered_map<int64_t, WeakPtr<Frontend>>& cardFrontendMap) const {}
400 
SetSharedRuntime(void * runtime)401     virtual void SetSharedRuntime(void* runtime) {}
GetSharedRuntime()402     virtual void* GetSharedRuntime()
403     {
404         return nullptr;
405     }
406 
IsFRSCardContainer()407     bool IsFRSCardContainer() const
408     {
409         return isFRSCardContainer_;
410     }
411 
SetIsFRSCardContainer(bool isFRSCardContainer)412     void SetIsFRSCardContainer(bool isFRSCardContainer)
413     {
414         isFRSCardContainer_ = isFRSCardContainer;
415     }
416 
IsDynamicRender()417     bool IsDynamicRender() const
418     {
419         return isDynamicRender_;
420     }
421 
SetIsDynamicRender(bool isDynamicRender)422     void SetIsDynamicRender(bool isDynamicRender)
423     {
424         isDynamicRender_ = isDynamicRender;
425     }
426 
GetRegisterComponents()427     virtual std::vector<std::string> GetRegisterComponents() { return {}; };
428 
SetPageUrlChecker(const RefPtr<PageUrlChecker> & pageUrlChecker)429     void SetPageUrlChecker(const RefPtr<PageUrlChecker>& pageUrlChecker)
430     {
431         pageUrlChecker_ = pageUrlChecker;
432     }
433 
GetPageUrlChecker()434     const RefPtr<PageUrlChecker>& GetPageUrlChecker()
435     {
436         return pageUrlChecker_;
437     }
438 
SetNavigationRoute(const RefPtr<NG::NavigationRoute> & navigationRoute)439     void SetNavigationRoute(const RefPtr<NG::NavigationRoute>& navigationRoute)
440     {
441         navigationRoute_ = navigationRoute;
442     }
443 
GetNavigationRoute()444     RefPtr<NG::NavigationRoute> GetNavigationRoute() const
445     {
446         return navigationRoute_;
447     }
448 
IsDialogContainer()449     virtual bool IsDialogContainer() const
450     {
451         return false;
452     }
453 
SetWindowScale(float windowScale)454     virtual void SetWindowScale(float windowScale) {}
455 
GetWindowScale()456     virtual float GetWindowScale() const
457     {
458         return 1.0f;
459     }
460 
461     virtual void NotifyConfigurationChange(bool, const ConfigurationChange& configurationChange = { false, false }) {}
462 
HotReload()463     virtual void HotReload() {}
464 
SetIsModule(bool isModule)465     void SetIsModule(bool isModule)
466     {
467         isModule_ = isModule;
468     }
469 
IsModule()470     bool IsModule() const
471     {
472         return isModule_;
473     }
474 
SetDistributedUI(std::shared_ptr<NG::DistributedUI> & distributedUI)475     void SetDistributedUI(std::shared_ptr<NG::DistributedUI>& distributedUI)
476     {
477         distributedUI_ = distributedUI;
478     }
479 
GetDistributedUI()480     std::shared_ptr<NG::DistributedUI>& GetDistributedUI()
481     {
482         return distributedUI_;
483     }
484 
IsLauncherContainer()485     virtual bool IsLauncherContainer()
486     {
487         return false;
488     }
489 
IsScenceBoardWindow()490     virtual bool IsScenceBoardWindow()
491     {
492         return false;
493     }
494 
IsUIExtensionWindow()495     virtual bool IsUIExtensionWindow()
496     {
497         return false;
498     }
499 
IsSceneBoardEnabled()500     virtual bool IsSceneBoardEnabled()
501     {
502         return false;
503     }
504 
GetCurPointerEventInfo(DragPointerEvent & dragPointerEvent,StopDragCallback && stopDragCallback)505     virtual bool GetCurPointerEventInfo(DragPointerEvent& dragPointerEvent, StopDragCallback&& stopDragCallback)
506     {
507         return false;
508     }
509 
GetCurPointerEventSourceType(int32_t & sourceType)510     virtual bool GetCurPointerEventSourceType(int32_t& sourceType)
511     {
512         return false;
513     }
514 
515     virtual bool RequestAutoFill(const RefPtr<NG::FrameNode>& node, AceAutoFillType autoFillType,
516         bool isNewPassWord, bool& isPopup, uint32_t& autoFillSessionId, bool isNative = true)
517     {
518         return false;
519     }
520 
IsNeedToCreatePopupWindow(const AceAutoFillType & autoFillType)521     virtual bool IsNeedToCreatePopupWindow(const AceAutoFillType& autoFillType)
522     {
523         return false;
524     }
525 
526     virtual bool RequestAutoSave(const RefPtr<NG::FrameNode>& node, const std::function<void()>& onFinish = nullptr,
527         const std::function<void()>& onUIExtNodeBindingCompleted = nullptr, bool isNative = true,
528         int32_t instanceId = -1)
529     {
530         return false;
531     }
532 
533 
GetNavigationController(const std::string & navigationId)534     virtual std::shared_ptr<NavigationController> GetNavigationController(const std::string& navigationId)
535     {
536         return nullptr;
537     }
538 
LessThanAPIVersion(PlatformVersion version)539     static bool LessThanAPIVersion(PlatformVersion version)
540     {
541         return PipelineBase::GetCurrentContext() &&
542                PipelineBase::GetCurrentContext()->GetMinPlatformVersion() < static_cast<int32_t>(version);
543     }
544 
GreatOrEqualAPIVersion(PlatformVersion version)545     static bool GreatOrEqualAPIVersion(PlatformVersion version)
546     {
547         return PipelineBase::GetCurrentContext() &&
548                PipelineBase::GetCurrentContext()->GetMinPlatformVersion() >= static_cast<int32_t>(version);
549     }
550 
LessThanAPITargetVersion(PlatformVersion version)551     static bool LessThanAPITargetVersion(PlatformVersion version)
552     {
553         auto container = Current();
554         CHECK_NULL_RETURN(container, false);
555         auto apiTargetVersion = container->GetApiTargetVersion();
556         return apiTargetVersion < static_cast<int32_t>(version);
557     }
558 
GreatOrEqualAPITargetVersion(PlatformVersion version)559     static bool GreatOrEqualAPITargetVersion(PlatformVersion version)
560     {
561         auto container = Current();
562         if (!container) {
563             auto apiTargetVersion = AceApplicationInfo::GetInstance().GetApiTargetVersion() % 1000;
564             return apiTargetVersion >= static_cast<int32_t>(version);
565         }
566         auto apiTargetVersion = container->GetApiTargetVersion();
567         return apiTargetVersion >= static_cast<int32_t>(version);
568     }
569 
SetAppBar(const RefPtr<NG::AppBarView> & appBar)570     void SetAppBar(const RefPtr<NG::AppBarView>& appBar)
571     {
572         appBar_ = appBar;
573     }
574 
GetAppBar()575     RefPtr<NG::AppBarView> GetAppBar() const
576     {
577         return appBar_;
578     }
579 
TerminateUIExtension()580     virtual void TerminateUIExtension() {}
581 
582     template<ContainerType type>
583     static int32_t GenerateId();
584     static void SetFontScale(int32_t instanceId, float fontScale);
585     static void SetFontWeightScale(int32_t instanceId, float fontScale);
586 
GetApiTargetVersion()587     int32_t GetApiTargetVersion() const
588     {
589         return apiTargetVersion_;
590     }
591 
SetApiTargetVersion(int32_t apiTargetVersion)592     void SetApiTargetVersion(int32_t apiTargetVersion)
593     {
594         apiTargetVersion_ = apiTargetVersion % 1000;
595     }
596 
GetUIContentType()597     UIContentType GetUIContentType() const
598     {
599         return uIContentType_;
600     }
601 
SetUIContentType(UIContentType uIContentType)602     void SetUIContentType(UIContentType uIContentType)
603     {
604         uIContentType_ = uIContentType;
605     }
606 
IsFreeMultiWindow()607     virtual bool IsFreeMultiWindow() const
608     {
609         return false;
610     }
611 
612     virtual ResourceConfiguration GetResourceConfiguration() const = 0;
613 
614 private:
615     static bool IsIdAvailable(int32_t id);
616 
617 protected:
618     std::chrono::time_point<std::chrono::high_resolution_clock> createTime_;
619     bool firstUpdateData_ = true;
620     std::string cardHapPath_;
621     bool useNewPipeline_ = false;
622     std::mutex stateMutex_;
623     Frontend::State state_ = Frontend::State::UNDEFINE;
624     bool isFRSCardContainer_ = false;
625     bool isDynamicRender_ = false;
626     RefPtr<DisplayInfoUtils> displayManager_ = AceType::MakeRefPtr<DisplayInfoUtils>();
627 
628 private:
629     std::string bundleName_;
630     std::string moduleName_;
631     std::string bundlePath_;
632     std::string filesDataPath_;
633     std::string tempDir_;
634     bool usePartialUpdate_ = false;
635     Settings settings_;
636     RefPtr<PageUrlChecker> pageUrlChecker_;
637     RefPtr<NG::NavigationRoute> navigationRoute_;
638     bool isModule_ = false;
639     std::shared_ptr<NG::DistributedUI> distributedUI_;
640     RefPtr<NG::AppBarView> appBar_;
641     int32_t apiTargetVersion_ = 0;
642     // Define the type of UI Content, for example, Security UIExtension.
643     UIContentType uIContentType_ = UIContentType::UNDEFINED;
644     ACE_DISALLOW_COPY_AND_MOVE(Container);
645 };
646 
647 template<ContainerType type>
GenerateId()648 int32_t Container::GenerateId()
649 {
650     static std::atomic<int32_t> gInstanceId;
651     int32_t id;
652     do {
653         id = type * CONTAINER_ID_DIVIDE_SIZE + gInstanceId.fetch_add(1) % CONTAINER_ID_DIVIDE_SIZE;
654     } while (!IsIdAvailable(id));
655     return id;
656 }
657 
658 template<>
659 int32_t Container::GenerateId<PLUGIN_SUBCONTAINER>();
660 
661 } // namespace OHOS::Ace
662 
663 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_CONTAINER_H
664