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_CLIENT_H 17 #define APP_DOMAIN_VERIFY_AGENT_CLIENT_H 18 19 #include "singleton.h" 20 #include "i_app_domain_verify_agent_service.h" 21 #include "zidl/i_convert_callback.h" 22 23 namespace OHOS { 24 namespace AppDomainVerify { 25 class AppDomainVerifyAgentClient : public DelayedSingleton<AppDomainVerifyAgentClient> { 26 DECLARE_DELAYED_SINGLETON(AppDomainVerifyAgentClient); 27 28 public: 29 DISALLOW_COPY_AND_MOVE(AppDomainVerifyAgentClient); 30 31 /** 32 * SingleVerify 33 * @descrition refresh single bundle verifyStatus. 34 * @param appVerifyBaseInfo appVerifyBaseInfo. 35 * @param skillUris skillUris. 36 */ 37 void SingleVerify(const AppVerifyBaseInfo &appVerifyBaseInfo, const VerifyResultInfo &verifyResultInfo); 38 39 /** 40 * ConvertToExplicitWant 41 * @descrition convert implicit want to explicit want. 42 * @param appVerifyBaseInfo appVerifyBaseInfo. 43 * @param skillUris skillUris. 44 */ 45 void ConvertToExplicitWant(OHOS::AAFwk::Want& implicitWant, sptr<IConvertCallback>& callback); 46 47 /** 48 * OnRemoteSaDied 49 * @descrition 50 * @param object systemAbility proxy object 51 * @return void. 52 */ 53 void OnRemoteSaDied(const wptr<IRemoteObject> &object); 54 55 private: 56 bool IsServiceAvailable(); 57 void ConnectService(); 58 59 private: 60 class StaticDestoryMonitor { 61 public: StaticDestoryMonitor()62 StaticDestoryMonitor() 63 : destoryed_(false) 64 { 65 } ~StaticDestoryMonitor()66 ~StaticDestoryMonitor() 67 { 68 destoryed_ = true; 69 } 70 IsDestoryed()71 bool IsDestoryed() const 72 { 73 return destoryed_; 74 } 75 76 private: 77 bool destoryed_; 78 }; 79 80 private: 81 static std::mutex proxyLock_; 82 static sptr<IAppDomainVerifyAgentService> agentServiceProxy_; 83 static StaticDestoryMonitor staticDestoryMonitor_; 84 sptr<IRemoteObject::DeathRecipient> deathRecipient_; 85 }; 86 87 class AgentSaDeathRecipient : public IRemoteObject::DeathRecipient { 88 public: 89 explicit AgentSaDeathRecipient(); 90 virtual ~AgentSaDeathRecipient(); 91 void OnRemoteDied(const wptr<IRemoteObject> &object) override; 92 93 private: 94 DISALLOW_COPY_AND_MOVE(AgentSaDeathRecipient); 95 }; 96 } 97 } 98 #endif