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 SERVICES_INCLUDE_ECOLOGICALRULEMGRSERVICE_H 17 #define SERVICES_INCLUDE_ECOLOGICALRULEMGRSERVICE_H 18 19 #include <thread> 20 #include <map> 21 #include <mutex> 22 #include <condition_variable> 23 #include "system_ability.h" 24 #include "bundle_mgr_interface.h" 25 #include "bundle_mgr_proxy.h" 26 #include "ecological_rule_mgr_service_stub.h" 27 28 namespace OHOS { 29 namespace EcologicalRuleMgrService { 30 using namespace OHOS::AppExecFwk; 31 using namespace std; 32 33 enum class ServiceRunningState { 34 STATE_NOT_START, 35 STATE_RUNNING 36 }; 37 enum ReturnCode { 38 SUCCESS = 0, 39 ERROR = -1, 40 }; 41 42 class EcologicalRuleMgrService : public SystemAbility, public EcologicalRuleMgrServiceStub { 43 DECLARE_SYSTEM_ABILITY(EcologicalRuleMgrService); 44 45 public: 46 using Want = OHOS::AAFwk::Want; 47 48 DISALLOW_COPY_AND_MOVE(EcologicalRuleMgrService); 49 EcologicalRuleMgrService(); 50 EcologicalRuleMgrService(int32_t saId, bool runOnCreate); 51 ~EcologicalRuleMgrService(); 52 static sptr<EcologicalRuleMgrService> GetInstance(); 53 int32_t QueryFreeInstallExperience(const Want &want, const CallerInfo &callerInfo, ExperienceRule &rule) override; 54 int32_t EvaluateResolveInfos(const Want &want, const CallerInfo &callerInfo, int32_t type, 55 vector<AbilityInfo> &abilityInfos) override; 56 int32_t QueryStartExperience(const Want &want, const CallerInfo &callerInfo, ExperienceRule &rule) override; 57 int32_t IsSupportPublishForm(const vector<Want> &wants, const CallerInfo &callerInfo, bool &bSupport) override; 58 59 protected: 60 void OnStart() override; 61 void OnStop() override; 62 63 private: 64 static mutex instanceLock_; 65 static sptr<EcologicalRuleMgrService> instance_; 66 ServiceRunningState state_; 67 }; 68 } // EcologicalRuleMgrService 69 } // namespace OHOS 70 71 #endif // SERVICES_INCLUDE_ECOLOGICALRULEMGRSERVICE_H