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 APP_DOMAIN_VERIFY_AGENT_SERVICE_H 17 #define APP_DOMAIN_VERIFY_AGENT_SERVICE_H 18 19 #include "app_domain_verify_agent_service_stub.h" 20 #include <chrono> 21 #include "inner_verify_status.h" 22 #include "skill_uri.h" 23 #include "system_ability.h" 24 #include "ffrt.h" 25 #include "app_domain_verify_extension_mgr.h" 26 #include "i_app_domain_verify_mgr_service.h" 27 #include "app_domain_verify_task_mgr.h" 28 #include "dfx/app_domain_verify_hisysevent.h" 29 #include "event_handler.h" 30 #include "event_runner.h" 31 #include "net_conn_client.h" 32 33 namespace OHOS { 34 namespace AppDomainVerify { 35 using namespace NetManagerStandard; 36 class AppDomainVerifyAgentService : public SystemAbility, public AppDomainVerifyAgentServiceStub { 37 DECLARE_SYSTEM_ABILITY(AppDomainVerifyAgentService); 38 39 public: 40 API_EXPORT AppDomainVerifyAgentService(); 41 API_EXPORT ~AppDomainVerifyAgentService() override; 42 API_EXPORT void SingleVerify( 43 const AppVerifyBaseInfo& appVerifyBaseInfo, const VerifyResultInfo &verifyResultInfo) override; 44 API_EXPORT void ConvertToExplicitWant(OHOS::AAFwk::Want& implicitWant, sptr<IConvertCallback>& callback) override; 45 46 protected: 47 void OnStart(const SystemAbilityOnDemandReason& startReason) override; 48 void OnStop() override; 49 void OnDump() override; 50 int Dump(int fd, const std::vector<std::u16string>& args) override; 51 52 private: 53 void QueryAndCompleteRefresh(TaskType type); 54 void CompleteVerifyRefresh(const BundleVerifyStatusInfo& bundleVerifyStatusInfo, TaskType type); 55 void ExecuteVerifyTask( 56 const AppVerifyBaseInfo& appVerifyBaseInfo, const VerifyResultInfo &verifyResultInfo, TaskType type); 57 void UpdateWhiteList(); 58 void OnDelayUnloadSA(); 59 void PostDelayUnloadTask(); 60 void DoSync(const TaskType& type); 61 void DoSync(); 62 bool IsIdle(); 63 bool IsNetAvailable(); 64 bool CanUnloadSa(); 65 void UnloadSa(); 66 std::string GetStatTime(); 67 68 private: 69 std::shared_ptr<AppDomainVerifyExtensionMgr> appDomainVerifyExtMgr_; 70 std::shared_ptr<AppDomainVerifyTaskMgr> appDomainVerifyTaskMgr_; 71 std::shared_ptr<AppExecFwk::EventHandler> unloadHandler_; 72 std::shared_ptr<AppExecFwk::EventRunner> runner_; 73 std::chrono::system_clock::time_point now; 74 }; 75 76 } // namespace AppDomainVerify 77 } // namespace OHOS 78 #endif // APP_DOMAIN_VERIFY_SERVICE_H