1 /* 2 * Copyright (c) 2022 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 #ifndef OHOS_ABILITY_RUNTIME_IMPLICIT_START_PROCESSOR_H 16 #define OHOS_ABILITY_RUNTIME_IMPLICIT_START_PROCESSOR_H 17 18 #include <vector> 19 #include <string> 20 #include <unordered_set> 21 22 #include "ability_record.h" 23 #include "bundle_mgr_interface.h" 24 #include "system_dialog_scheduler.h" 25 #ifdef SUPPORT_ERMS 26 #include "ecological_rule_mgr_service_client.h" 27 #endif 28 29 namespace OHOS { 30 namespace AAFwk { 31 #ifdef SUPPORT_ERMS 32 using namespace OHOS::EcologicalRuleMgrService; 33 using ErmsCallerInfo = OHOS::EcologicalRuleMgrService::CallerInfo; 34 #endif 35 /** 36 * @class ImplicitStartProcessor 37 * ImplicitStartProcessor. 38 */ 39 class ImplicitStartProcessor : public std::enable_shared_from_this<ImplicitStartProcessor> { 40 public: 41 explicit ImplicitStartProcessor() = default; 42 virtual ~ImplicitStartProcessor() = default; 43 44 static bool IsImplicitStartAction(const Want &want); 45 46 int ImplicitStartAbility(AbilityRequest &request, int32_t userId); 47 48 private: 49 int GenerateAbilityRequestByAction(int32_t userId, AbilityRequest &request, 50 std::vector<DialogAppInfo> &dialogAppInfos, std::string &deviceType, bool isMoreHapList); 51 52 sptr<AppExecFwk::IBundleMgr> GetBundleManager(); 53 54 using StartAbilityClosure = std::function<int32_t()>; 55 int CallStartAbilityInner(int32_t userId, const Want &want, const StartAbilityClosure &callBack, 56 const AbilityCallType &callType); 57 58 int32_t ImplicitStartAbilityInner(const Want &targetWant, const AbilityRequest &request, int32_t userId); 59 60 bool CheckImplicitStartExtensionIsValid(const AbilityRequest &request, 61 const AppExecFwk::ExtensionAbilityInfo &extensionInfo); 62 63 bool FilterAbilityList(const Want &want, std::vector<AppExecFwk::AbilityInfo> &abilityInfos, 64 std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos, int32_t userId); 65 sptr<AppExecFwk::IDefaultApp> GetDefaultAppProxy(); 66 67 #ifdef SUPPORT_ERMS 68 void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId); 69 #endif 70 71 private: 72 const static std::vector<std::string> blackList; 73 const static std::unordered_set<AppExecFwk::ExtensionAbilityType> extensionWhiteList; 74 sptr<AppExecFwk::IBundleMgr> iBundleManager_; 75 }; 76 } // namespace AAFwk 77 } // namespace OHOS 78 #endif // OHOS_ABILITY_RUNTIME_IMPLICIT_START_PROCESSOR_H