mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-25 12:23:20 -04:00
!5021 notify window manager service if ability dies unexpectedly
Merge pull request !5021 from wangzhen/ability_died_notify
This commit is contained in:
@@ -42,6 +42,8 @@ public:
|
||||
|
||||
virtual void CancelStartingWindow(sptr<IRemoteObject> abilityToken) = 0;
|
||||
|
||||
virtual void NotifyAnimationAbilityDied(sptr<AbilityTransitionInfo> info) = 0;
|
||||
|
||||
enum WMSCmd {
|
||||
// ipc id for NotifyWindowTransition
|
||||
ON_NOTIFY_WINDOW_TRANSITION,
|
||||
@@ -57,6 +59,9 @@ public:
|
||||
|
||||
// ipc id for CancelStartingWindow
|
||||
ON_CANCEL_STARTING_WINDOW,
|
||||
|
||||
// ipc id for NotifyAnimationAbilityDied
|
||||
ON_NOTIFY_ANIMATION_ABILITY_DIED,
|
||||
};
|
||||
};
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
|
||||
virtual void CancelStartingWindow(sptr<IRemoteObject> abilityToken) override;
|
||||
|
||||
virtual void NotifyAnimationAbilityDied(sptr<AbilityTransitionInfo> info) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<WindowManagerServiceHandlerProxy> delegator_;
|
||||
};
|
||||
|
||||
@@ -41,6 +41,7 @@ private:
|
||||
int StartingWindowCold(MessageParcel &data, MessageParcel &reply);
|
||||
int StartingWindowHot(MessageParcel &data, MessageParcel &reply);
|
||||
int CancelStartingWindowInner(MessageParcel &data, MessageParcel &reply);
|
||||
int NotifyAnimationAbilityDiedInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using RequestFuncType = int (WindowManagerServiceHandlerStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, RequestFuncType> requestFuncMap_;
|
||||
|
||||
@@ -157,6 +157,26 @@ void WindowManagerServiceHandlerProxy::CancelStartingWindow(sptr<IRemoteObject>
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManagerServiceHandlerProxy::NotifyAnimationAbilityDied(sptr<AbilityTransitionInfo> info)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(info.GetRefPtr())) {
|
||||
HILOG_ERROR("Write info failed.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = Remote()->SendRequest(WMSCmd::ON_NOTIFY_ANIMATION_ABILITY_DIED, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
||||
@@ -38,6 +38,8 @@ void WindowManagerServiceHandlerStub::Init()
|
||||
requestFuncMap_[ON_COLD_STARTING_WINDOW] = &WindowManagerServiceHandlerStub::StartingWindowCold;
|
||||
requestFuncMap_[ON_HOT_STARTING_WINDOW] = &WindowManagerServiceHandlerStub::StartingWindowHot;
|
||||
requestFuncMap_[ON_CANCEL_STARTING_WINDOW] = &WindowManagerServiceHandlerStub::CancelStartingWindowInner;
|
||||
requestFuncMap_[ON_NOTIFY_ANIMATION_ABILITY_DIED] =
|
||||
&WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner;
|
||||
}
|
||||
|
||||
int WindowManagerServiceHandlerStub::OnRemoteRequest(
|
||||
@@ -151,6 +153,18 @@ int WindowManagerServiceHandlerStub::CancelStartingWindowInner(MessageParcel &da
|
||||
CancelStartingWindow(abilityToken);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
sptr<AbilityTransitionInfo> info(data.ReadParcelable<AbilityTransitionInfo>());
|
||||
if (!info) {
|
||||
HILOG_ERROR("To read info failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
NotifyAnimationAbilityDied(info);
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
||||
@@ -1819,6 +1819,16 @@ void AbilityRecord::OnSchedulerDied(const wptr<IRemoteObject> &remote)
|
||||
ability->SendResultToCallers();
|
||||
};
|
||||
handler->PostTask(uriTask);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// notify winddow manager service the ability died
|
||||
handler->PostTask([ability = shared_from_this()]() {
|
||||
if (ability->GetWMSHandler()) {
|
||||
sptr<AbilityTransitionInfo> info = new AbilityTransitionInfo();
|
||||
ability->SetAbilityTransitionInfo(info);
|
||||
ability->GetWMSHandler()->NotifyAnimationAbilityDied(info);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
HandleDlpClosed();
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ public:
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void NotifyAnimationAbilityDied(sptr<AbilityTransitionInfo> info) {}
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user