mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
add death callback
Signed-off-by: lzr <liuzengrui1@huawei.com>
This commit is contained in:
parent
29fc8991a2
commit
76b4a38cdf
@ -53,6 +53,7 @@ int32_t UIContentServiceProxy::Connect(const EventCallback& eventCallback)
|
||||
}
|
||||
report_ = new (std::nothrow) UiReportStub();
|
||||
processId_ = IPCSkeleton::GetCallingRealPid();
|
||||
isConnected = true;
|
||||
if (report_ == nullptr) {
|
||||
LOGW("connect failed,create reportStub failed");
|
||||
return FAILED;
|
||||
@ -281,4 +282,9 @@ int32_t UIContentServiceProxy::UnregisterWebUnfocusEventCallback()
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool UIContentServiceProxy::IsConnect()
|
||||
{
|
||||
return isConnected;
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -80,4 +80,9 @@ int32_t UIContentServiceStubImpl::UnregisterWebUnfocusEventCallback()
|
||||
UiSessionManager::GetInstance().NotifyAllWebPattern(false);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool UIContentServiceStubImpl::IsConnect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -166,4 +166,16 @@ void UiReportProxy::SendBaseInfo(const std::string& data)
|
||||
LOGW("SendBaseInfo send request failed");
|
||||
}
|
||||
}
|
||||
|
||||
void UiReportProxyRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
LOGI("uiproxy death notice");
|
||||
if (remote == nullptr) {
|
||||
LOGW("weak remote is null");
|
||||
return;
|
||||
}
|
||||
if (handler_) {
|
||||
handler_();
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "interfaces/inner_api/ui_session/ui_session_manager.h"
|
||||
#include "ui_report_proxy.h"
|
||||
|
||||
#include "adapter/ohos/entrance/ui_session/include/ui_service_hilog.h"
|
||||
namespace OHOS::Ace {
|
||||
@ -93,6 +94,13 @@ void UiSessionManager::ReportWebUnfocusEvent(int64_t accessibilityId, const std:
|
||||
|
||||
void UiSessionManager::SaveReportStub(sptr<IRemoteObject> reportStub, int32_t processId)
|
||||
{
|
||||
// add death callback
|
||||
auto uiReportProxyRecipient = new UiReportProxyRecipient([processId, this]() {
|
||||
LOGW("agent process dead,processId:%{public}d", processId);
|
||||
// reportMap remove this processId
|
||||
this->reportObjectMap_.erase(processId);
|
||||
});
|
||||
reportStub->AddDeathRecipient(uiReportProxyRecipient);
|
||||
reportObjectMap_[processId] = reportStub;
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,13 @@ public:
|
||||
virtual int32_t UnregisterRouterChangeEventCallback() override;
|
||||
virtual int32_t UnregisterComponentChangeEventCallback() override;
|
||||
virtual int32_t UnregisterWebUnfocusEventCallback() override;
|
||||
virtual bool IsConnect() override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<UIContentServiceProxy> delegator_;
|
||||
sptr<UiReportStub> report_ = nullptr;
|
||||
int32_t processId_;
|
||||
bool isConnected = false;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H
|
||||
|
@ -113,6 +113,9 @@ public:
|
||||
* @return: result number
|
||||
*/
|
||||
virtual int32_t UnregisterWebUnfocusEventCallback() = 0;
|
||||
|
||||
/* Not Used Ipc Interface*/
|
||||
virtual bool IsConnect() = 0;
|
||||
};
|
||||
class ACE_FORCE_EXPORT ReportService : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
int32_t UnregisterRouterChangeEventCallback() override;
|
||||
int32_t UnregisterComponentChangeEventCallback() override;
|
||||
int32_t UnregisterWebUnfocusEventCallback() override;
|
||||
bool IsConnect() override;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_STUB_IMPL_H
|
||||
|
@ -66,5 +66,18 @@ public:
|
||||
private:
|
||||
static inline BrokerDelegator<UiReportProxy> delegator_;
|
||||
};
|
||||
|
||||
class ACE_FORCE_EXPORT UiReportProxyRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
using RemoteDiedHandler = std::function<void()>;
|
||||
explicit UiReportProxyRecipient(RemoteDiedHandler handler) : handler_(std::move(handler)) {}
|
||||
|
||||
~UiReportProxyRecipient() override = default;
|
||||
|
||||
void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
|
||||
|
||||
private:
|
||||
RemoteDiedHandler handler_;
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_INTERFACE_UI_CONTENT_PROXY_H
|
||||
|
Loading…
Reference in New Issue
Block a user