mirror of
https://gitee.com/openharmony/bundlemanager_app_domain_verify
synced 2025-01-15 21:20:28 +00:00
调整app_domain_verify_mgr 按需启动
Signed-off-by: woohoa <wanghuan36@huawei.com>
This commit is contained in:
parent
71f206928c
commit
95b30fa678
@ -14,7 +14,8 @@
|
||||
"uid" : "app_domain_verify",
|
||||
"gid" : ["app_domain_verify", "system", "shell", "netsys_socket"],
|
||||
"caps" : [],
|
||||
"jobs" : {
|
||||
"ondemand" : true,
|
||||
"jobs" : {
|
||||
"on-start" : "services:app_domain_verify_mgr_service"
|
||||
},
|
||||
"permission" : [
|
||||
|
@ -26,6 +26,7 @@ namespace AppDomainVerify {
|
||||
std::mutex AppDomainVerifyMgrClient::proxyLock_;
|
||||
sptr<IAppDomainVerifyMgrService> AppDomainVerifyMgrClient::appDomainVerifyMgrServiceProxy_;
|
||||
AppDomainVerifyMgrClient::StaticDestoryMonitor AppDomainVerifyMgrClient::staticDestoryMonitor_;
|
||||
constexpr int32_t LOADSA_TIMEOUT_MS = 10000;
|
||||
|
||||
AppDomainVerifyMgrClient::AppDomainVerifyMgrClient()
|
||||
{
|
||||
@ -139,7 +140,11 @@ void AppDomainVerifyMgrClient::ConnectService()
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObject = samgrProxy->CheckSystemAbility(APP_DOMAIN_VERIFY_MANAGER_SA_ID);
|
||||
|
||||
if (remoteObject == nullptr) {
|
||||
APP_DOMAIN_VERIFY_HILOGW(APP_DOMAIN_VERIFY_MGR_MODULE_CLIENT, "try load.");
|
||||
|
||||
remoteObject = samgrProxy->LoadSystemAbility(APP_DOMAIN_VERIFY_MANAGER_SA_ID, LOADSA_TIMEOUT_MS);
|
||||
}
|
||||
if (remoteObject != nullptr) {
|
||||
APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MGR_MODULE_CLIENT, "Get AppDomainVerifyMgrServiceProxy succeed.");
|
||||
if (deathRecipient_ == nullptr) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
{
|
||||
"name": 6200,
|
||||
"libpath": "libapp_domain_verify_mgr_service.z.so",
|
||||
"run-on-create": true,
|
||||
"run-on-create": false,
|
||||
"distributed": false,
|
||||
"dump_level": 1
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ ohos_shared_library("app_domain_verify_mgr_service") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "i_app_domain_verify_mgr_service.h"
|
||||
#include "iremote_stub.h"
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDomainVerify {
|
||||
@ -28,7 +30,8 @@ public:
|
||||
API_EXPORT virtual ~AppDomainVerifyMgrServiceStub();
|
||||
API_EXPORT int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option) override;
|
||||
|
||||
protected:
|
||||
void PostDelayUnloadTask();
|
||||
private:
|
||||
using AppDomainVerifyServiceFunc = int32_t (AppDomainVerifyMgrServiceStub::*)(MessageParcel &data,
|
||||
MessageParcel &reply);
|
||||
@ -41,6 +44,7 @@ private:
|
||||
|
||||
private:
|
||||
std::map<uint32_t, AppDomainVerifyServiceFunc> memberFuncMap_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> unloadHandler_;
|
||||
};
|
||||
} // namespace AppDomainVerify
|
||||
} // namespace OHOS
|
||||
|
@ -154,6 +154,7 @@ void AppDomainVerifyMgrService::OnStart()
|
||||
if (!res) {
|
||||
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "Publish failed");
|
||||
}
|
||||
AppDomainVerifyMgrServiceStub::PostDelayUnloadTask();
|
||||
}
|
||||
|
||||
void AppDomainVerifyMgrService::OnStop()
|
||||
|
@ -18,10 +18,15 @@
|
||||
#include "app_domain_verify_mgr_interface_code.h"
|
||||
#include "errors.h"
|
||||
#include "parcel_util.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDomainVerify {
|
||||
|
||||
namespace {
|
||||
constexpr int32_t DELAY_TIME = 300000; // 5min = 5*60*1000
|
||||
const std::string TASK_ID = "unload";
|
||||
}
|
||||
AppDomainVerifyMgrServiceStub::AppDomainVerifyMgrServiceStub()
|
||||
{
|
||||
memberFuncMap_[static_cast<uint32_t>(AppDomainVerifyMgrInterfaceCode::QUERY_VERIFY_STATUS)] =
|
||||
@ -45,6 +50,7 @@ int32_t AppDomainVerifyMgrServiceStub::OnRemoteRequest(uint32_t code, MessagePar
|
||||
MessageOption &option)
|
||||
{
|
||||
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "onRemoteRequest##code = %{public}u", code);
|
||||
PostDelayUnloadTask();
|
||||
std::u16string myDescripter = AppDomainVerifyMgrServiceStub::GetDescriptor();
|
||||
std::u16string remoteDescripter = data.ReadInterfaceToken();
|
||||
if (myDescripter != remoteDescripter) {
|
||||
@ -162,5 +168,35 @@ int32_t AppDomainVerifyMgrServiceStub::OnSaveDomainVerifyStatus(MessageParcel &d
|
||||
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "%s call end", __func__);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void AppDomainVerifyMgrServiceStub::PostDelayUnloadTask()
|
||||
{
|
||||
APP_DOMAIN_VERIFY_HILOGD(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "%s called", __func__);
|
||||
auto runner = AppExecFwk::EventRunner::Create("unload");
|
||||
if (unloadHandler_ == nullptr) {
|
||||
unloadHandler_ = std::make_shared<AppExecFwk::EventHandler>(runner);
|
||||
}
|
||||
if (unloadHandler_ == nullptr) {
|
||||
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "unloadHandler init failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto task = [this]() {
|
||||
APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "do unload task");
|
||||
auto samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (samgrProxy == nullptr) {
|
||||
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "get samgr failed");
|
||||
return;
|
||||
}
|
||||
int32_t ret = samgrProxy->UnloadSystemAbility(APP_DOMAIN_VERIFY_MANAGER_SA_ID);
|
||||
if (ret != 0) {
|
||||
APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "remove system ability failed");
|
||||
return;
|
||||
}
|
||||
APP_DOMAIN_VERIFY_HILOGI(APP_DOMAIN_VERIFY_MGR_MODULE_SERVICE, "do unload task done");
|
||||
};
|
||||
unloadHandler_->RemoveTask(TASK_ID);
|
||||
unloadHandler_->PostTask(task, TASK_ID, DELAY_TIME);
|
||||
}
|
||||
} // namespace AppDomainVerify
|
||||
} // namespace OHOS
|
Loading…
x
Reference in New Issue
Block a user