• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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  OHOS_ABILITY_RUNTIME_APP_STARTUP_TASK_MATCHER_H
17 #define  OHOS_ABILITY_RUNTIME_APP_STARTUP_TASK_MATCHER_H
18 
19 #include "app_startup_task.h"
20 #include "want.h"
21 
22 namespace OHOS {
23 namespace AbilityRuntime {
24 class AppStartupTaskMatcher {
25 public:
26     virtual bool Match(const AppStartupTask &task) const = 0;
27     virtual ~AppStartupTaskMatcher() = default;
28 };
29 
30 class ModuleStartStartupTaskMatcher : public AppStartupTaskMatcher {
31 public:
32     ModuleStartStartupTaskMatcher(const std::string &moduleName);
33 
34     bool Match(const AppStartupTask &task) const override;
35 
36 private:
37     std::string moduleName_;
38 };
39 
40 class ExcludeFromAutoStartStartupTaskMatcher : public AppStartupTaskMatcher {
41 public:
42     ExcludeFromAutoStartStartupTaskMatcher();
43 
44     bool Match(const AppStartupTask &task) const override;
45 };
46 
47 class UriStartupTaskMatcher : public AppStartupTaskMatcher {
48 public:
49     UriStartupTaskMatcher(std::shared_ptr<AAFwk::Want> want);
50     UriStartupTaskMatcher(std::shared_ptr<Uri> uri);
51 
52     bool Match(const AppStartupTask &task) const override;
53 
54 private:
55     std::shared_ptr<Uri> uri_ = nullptr;
56 };
57 
58 class InsightIntentStartupTaskMatcher : public AppStartupTaskMatcher {
59 public:
60     InsightIntentStartupTaskMatcher(std::shared_ptr<AAFwk::Want> want);
61     InsightIntentStartupTaskMatcher(const std::string &insightIntentName);
62 
63     bool Match(const AppStartupTask &task) const override;
64 
65 private:
66     std::string insightIntentName_;
67 };
68 
69 class ActionStartupTaskMatcher : public AppStartupTaskMatcher {
70 public:
71     ActionStartupTaskMatcher(std::shared_ptr<AAFwk::Want> want);
72     ActionStartupTaskMatcher(const std::string &action);
73 
74     bool Match(const AppStartupTask &task) const override;
75 
76 private:
77     std::string action_;
78 };
79 
80 class CustomizationStartupTaskMatcher : public AppStartupTaskMatcher {
81 public:
82     CustomizationStartupTaskMatcher(const std::string &customization);
83 
84     bool Match(const AppStartupTask &task) const override;
85 
86 private:
87     std::string customization_;
88 };
89 
90 class MatchRulesStartupTaskMatcher : public AppStartupTaskMatcher {
91 public:
92     MatchRulesStartupTaskMatcher(std::shared_ptr<AAFwk::Want> want);
93     MatchRulesStartupTaskMatcher(const std::string &uri, const std::string &action,
94         const std::string &insightIntentName);
95 
96     bool Match(const AppStartupTask &task) const override;
97 
98     void SetModuleMatcher(std::shared_ptr<ModuleStartStartupTaskMatcher> matcher);
99     void SetCustomizationMatcher(std::shared_ptr<CustomizationStartupTaskMatcher> matcher);
100 
101 private:
102     std::vector<std::shared_ptr<AppStartupTaskMatcher>> matchers_;
103     std::shared_ptr<ModuleStartStartupTaskMatcher> moduleMatcher_ = nullptr;
104     std::shared_ptr<CustomizationStartupTaskMatcher> customizationMatcher_ = nullptr;
105 };
106 
107 class DefaultStartupTaskMatcher : public AppStartupTaskMatcher {
108 public:
109     DefaultStartupTaskMatcher(const std::string &moduleName);
110 
111     bool Match(const AppStartupTask &task) const override;
112 
113 private:
114     ModuleStartStartupTaskMatcher moduleMatcher_;
115     ExcludeFromAutoStartStartupTaskMatcher excludeMatcher_;
116 };
117 } // namespace AbilityRuntime
118 } // namespace OHOS
119 #endif // OHOS_ABILITY_RUNTIME_APP_STARTUP_TASK_MATCHER_H
120