mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2025-01-09 09:30:30 +00:00
Signed-off-by: xuchenghua <xuchenghua09@huawei.com> Change-Id: Iaec481e163d55c6c2737b34332153cc698ff3f6f
This commit is contained in:
parent
e9e1f2c4d4
commit
47744b278a
@ -94,8 +94,14 @@ void DataAbilityHelper::AddDataAbilityDeathRecipient(const sptr<IRemoteObject> &
|
||||
token->RemoveDeathRecipient(callerDeathRecipient_);
|
||||
}
|
||||
if (callerDeathRecipient_ == nullptr) {
|
||||
std::weak_ptr<DataAbilityHelper> thisWeakPtr(shared_from_this());
|
||||
callerDeathRecipient_ =
|
||||
new DataAbilityDeathRecipient(std::bind(&DataAbilityHelper::OnSchedulerDied, this, std::placeholders::_1));
|
||||
new DataAbilityDeathRecipient([thisWeakPtr](const wptr<IRemoteObject> &remote) {
|
||||
auto dataAbilityHelper = thisWeakPtr.lock();
|
||||
if (dataAbilityHelper) {
|
||||
dataAbilityHelper->OnSchedulerDied(remote);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (token != nullptr) {
|
||||
HILOG_INFO("token AddDeathRecipient.");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -184,10 +184,16 @@ void DataObsMgrInner::AddObsDeathRecipient(const sptr<IDataAbilityObserver> &dat
|
||||
HILOG_ERROR("%{public}s this death recipient has been added.", __func__);
|
||||
return;
|
||||
} else {
|
||||
std::weak_ptr<DataObsMgrInner> thisWeakPtr(shared_from_this());
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient =
|
||||
new DataObsCallbackRecipient(std::bind(&DataObsMgrInner::OnCallBackDied, this, std::placeholders::_1));
|
||||
dataObserver->AsObject()->AddDeathRecipient(deathRecipient);
|
||||
recipientMap_.emplace(dataObserver->AsObject(), deathRecipient);
|
||||
new DataObsCallbackRecipient([thisWeakPtr](const wptr<IRemoteObject> &remote) {
|
||||
auto dataObsMgrInner = thisWeakPtr.lock();
|
||||
if (dataObsMgrInner) {
|
||||
dataObsMgrInner->OnCallBackDied(remote);
|
||||
}
|
||||
});
|
||||
dataObserver->AsObject()->AddDeathRecipient(deathRecipient);
|
||||
recipientMap_.emplace(dataObserver->AsObject(), deathRecipient);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user