1 /* 2 * Copyright (c) 2024 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_H 17 #define OHOS_ABILITY_RUNTIME_APP_STARTUP_TASK_H 18 19 #include <string> 20 21 #include "bundle_info.h" 22 #include "startup_task.h" 23 24 namespace OHOS { 25 namespace AbilityRuntime { 26 struct StartupTaskMatchRules { 27 std::vector<std::string> uris; 28 std::vector<std::string> insightIntents; 29 std::vector<std::string> actions; 30 std::vector<std::string> customization; 31 }; 32 33 struct StartupTaskInfo { 34 std::string name; 35 std::string srcEntry; 36 std::string ohmUrl; 37 std::string moduleName; 38 std::string hapPath; 39 std::vector<std::string> dependencies; 40 bool excludeFromAutoStart = false; 41 bool callCreateOnMainThread = true; 42 bool waitOnMainThread = true; 43 bool esModule = true; 44 StartupTaskMatchRules matchRules; 45 }; 46 47 class AppStartupTask : public StartupTask { 48 public: 49 explicit AppStartupTask(const std::string& name); 50 51 ~AppStartupTask() override; 52 53 bool GetIsExcludeFromAutoStart() const; 54 55 void SetIsExcludeFromAutoStart(bool excludeFromAutoStart); 56 57 void SetMatchRules(StartupTaskMatchRules matchRules); 58 59 const std::vector<std::string> &GetUriMatchRules() const; 60 61 const std::vector<std::string> &GetInsightIntentMatchRules() const; 62 63 const std::vector<std::string> &GetActionMatchRules() const; 64 65 const std::vector<std::string> &GetCustomizationMatchRules() const; 66 67 void SetModuleName(const std::string &moduleName); 68 69 const std::string& GetModuleName() const; 70 71 void SetModuleType(AppExecFwk::ModuleType moduleType); 72 73 AppExecFwk::ModuleType GetModuleType() const; 74 75 protected: 76 bool isExcludeFromAutoStart_ = false; 77 std::string moduleName_; 78 AppExecFwk::ModuleType moduleType_ = AppExecFwk::ModuleType::UNKNOWN; 79 StartupTaskMatchRules matchRules_; 80 }; 81 } // namespace AbilityRuntime 82 } // namespace OHOS 83 #endif // OHOS_ABILITY_RUNTIME_APP_STARTUP_TASK_H 84