mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-27 01:10:52 +00:00
commit
3cffd53107
@ -617,9 +617,8 @@ void AbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
|||||||
TAG_LOGE(AAFwkTag::ABILITY, "null stage mode ability/abilityImpl");
|
TAG_LOGE(AAFwkTag::ABILITY, "null stage mode ability/abilityImpl");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
std::string entry = "AbilityImpl::WindowLifeCycleImpl::AfterForeground";
|
||||||
std::string entry = "AbilityImpl::WindowLifeCycleImpl::AfterForeground; the foreground lifecycle";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
|
|
||||||
bool needNotifyAMS = false;
|
bool needNotifyAMS = false;
|
||||||
{
|
{
|
||||||
@ -639,7 +638,7 @@ void AbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
|||||||
auto ret = AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
auto ret = AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||||
AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
||||||
if (ret == ERR_OK) {
|
if (ret == ERR_OK) {
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -653,16 +652,15 @@ void AbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
|||||||
TAG_LOGW(AAFwkTag::ABILITY, "not stage");
|
TAG_LOGW(AAFwkTag::ABILITY, "not stage");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::BACKGROUND };
|
std::string entry = "AbilityImpl::WindowLifeCycleImpl::AfterBackground";
|
||||||
std::string entry = "AbilityImpl::WindowLifeCycleImpl::AfterBackground; the background lifecycle";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
|
|
||||||
TAG_LOGI(AAFwkTag::ABILITY, "window after background");
|
TAG_LOGI(AAFwkTag::ABILITY, "window after background");
|
||||||
PacMap restoreData;
|
PacMap restoreData;
|
||||||
auto ret = AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
auto ret = AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||||
AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
||||||
if (ret == ERR_OK) {
|
if (ret == ERR_OK) {
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,16 +181,14 @@ void CJUIAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo
|
|||||||
|
|
||||||
void CJUIAbility::AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
void CJUIAbility::AddLifecycleEventBeforeCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
auto entry = std::string("CJUIAbility::") + methodName + " begin";
|
||||||
auto entry = std::string("CJUIAbility::") + methodName + "; the " + methodName + " begin";
|
FreezeUtil::GetInstance().AddLifecycleEvent(AbilityContext::token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CJUIAbility::AddLifecycleEventAfterCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
void CJUIAbility::AddLifecycleEventAfterCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
auto entry = std::string("CJUIAbility::") + methodName + " end";
|
||||||
auto entry = std::string("CJUIAbility::") + methodName + "; the " + methodName + " end.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(AbilityContext::token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CJUIAbility::OnShare(WantParams &wantParams)
|
int32_t CJUIAbility::OnShare(WantParams &wantParams)
|
||||||
|
@ -271,16 +271,14 @@ void JsAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
|||||||
|
|
||||||
void JsAbility::AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
void JsAbility::AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
auto entry = std::string("JsAbility::") + methodName + " begin";
|
||||||
auto entry = std::string("JsAbility::") + methodName + "; the " + methodName + " begin";
|
FreezeUtil::GetInstance().AddLifecycleEvent(AbilityContext::token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsAbility::AddLifecycleEventAfterJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
void JsAbility::AddLifecycleEventAfterJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
auto entry = std::string("JsAbility::") + methodName + " end";
|
||||||
auto entry = std::string("JsAbility::") + methodName + "; the " + methodName + " end";
|
FreezeUtil::GetInstance().AddLifecycleEvent(AbilityContext::token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t JsAbility::OnShare(WantParams &wantParam)
|
int32_t JsAbility::OnShare(WantParams &wantParam)
|
||||||
|
@ -362,16 +362,14 @@ void JsUIAbility::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo
|
|||||||
|
|
||||||
void JsUIAbility::AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
void JsUIAbility::AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
auto entry = std::string("JsUIAbility::") + methodName + " begin";
|
||||||
auto entry = std::string("JsUIAbility::") + methodName + "; the " + methodName + " begin.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(AbilityContext::token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsUIAbility::AddLifecycleEventAfterJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
void JsUIAbility::AddLifecycleEventAfterJSCall(FreezeUtil::TimeoutState state, const std::string &methodName) const
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, state };
|
auto entry = std::string("JsUIAbility::") + methodName + " end";
|
||||||
auto entry = std::string("JsUIAbility::") + methodName + "; the " + methodName + " end.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(AbilityContext::token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t JsUIAbility::OnShare(WantParams &wantParam)
|
int32_t JsUIAbility::OnShare(WantParams &wantParam)
|
||||||
@ -878,9 +876,8 @@ void JsUIAbility::DoOnForegroundForSceneIsNull(const Want &want)
|
|||||||
}
|
}
|
||||||
if (ret != Rosen::WMError::WM_OK) {
|
if (ret != Rosen::WMError::WM_OK) {
|
||||||
TAG_LOGE(AAFwkTag::UIABILITY, "init window scene failed");
|
TAG_LOGE(AAFwkTag::UIABILITY, "init window scene failed");
|
||||||
FreezeUtil::LifecycleFlow flow = { AbilityContext::token_, FreezeUtil::TimeoutState::FOREGROUND };
|
FreezeUtil::GetInstance().AppendLifecycleEvent(AbilityContext::token_,
|
||||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
|
std::string("JsUIAbility::DoOnForegroundForSceneIsNull; error ") + std::to_string(static_cast<int>(ret)));
|
||||||
std::string("ERROR JsUIAbility::DoOnForegroundForSceneIsNull: ") + std::to_string(static_cast<int>(ret)));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,15 +315,14 @@ void FAAbilityThread::AttachInner(const std::shared_ptr<AppExecFwk::OHOSApplicat
|
|||||||
abilityImpl_->Init(application, abilityRecord, currentAbility_, abilityHandler_, token_);
|
abilityImpl_->Init(application, abilityRecord, currentAbility_, abilityHandler_, token_);
|
||||||
// 4. ability attach : ipc
|
// 4. ability attach : ipc
|
||||||
TAG_LOGD(AAFwkTag::FA, "attach ability");
|
TAG_LOGD(AAFwkTag::FA, "attach ability");
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::LOAD };
|
std::string entry = "AbilityThread::Attach";
|
||||||
std::string entry = "AbilityThread::Attach; the load lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
ErrCode err = AbilityManagerClient::GetInstance()->AttachAbilityThread(this, token_);
|
ErrCode err = AbilityManagerClient::GetInstance()->AttachAbilityThread(this, token_);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
TAG_LOGE(AAFwkTag::FA, "err = %{public}d", err);
|
TAG_LOGE(AAFwkTag::FA, "err = %{public}d", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,14 +495,12 @@ void FAAbilityThread::AddLifecycleEvent(uint32_t state, std::string &methodName)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
if (state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
std::string entry = "AbilityThread::" + methodName;
|
||||||
std::string entry = "AbilityThread::" + methodName + "; the foreground lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
if (state == AAFwk::ABILITY_STATE_BACKGROUND_NEW) {
|
if (state == AAFwk::ABILITY_STATE_BACKGROUND_NEW) {
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::BACKGROUND };
|
std::string entry = "AbilityThread::" + methodName;
|
||||||
std::string entry = "AbilityThread::" + methodName + "; the background lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +77,7 @@ void NewAbilityImpl::AbilityTransactionCallback(const AbilityLifeCycleState &sta
|
|||||||
TAG_LOGI(AAFwkTag::ABILITY, "notify ams");
|
TAG_LOGI(AAFwkTag::ABILITY, "notify ams");
|
||||||
auto ret = AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, state, GetRestoreData());
|
auto ret = AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, state, GetRestoreData());
|
||||||
if (ret == ERR_OK && state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
if (ret == ERR_OK && state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,15 +217,14 @@ void UIAbilityImpl::HandleShareData(int32_t uniqueId)
|
|||||||
void UIAbilityImpl::AbilityTransactionCallback(const AAFwk::AbilityLifeCycleState &state)
|
void UIAbilityImpl::AbilityTransactionCallback(const AAFwk::AbilityLifeCycleState &state)
|
||||||
{
|
{
|
||||||
TAG_LOGD(AAFwkTag::UIABILITY, "called");
|
TAG_LOGD(AAFwkTag::UIABILITY, "called");
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
|
||||||
if (state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
if (state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||||
lifecycleState_ = AAFwk::ABILITY_STATE_FOREGROUND_NEW;
|
lifecycleState_ = AAFwk::ABILITY_STATE_FOREGROUND_NEW;
|
||||||
std::string entry = "AbilityManagerClient::AbilityTransitionDone; the transaction start.";
|
std::string entry = "AbilityManagerClient::AbilityTransitionDone";
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
}
|
}
|
||||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, state, GetRestoreData());
|
auto ret = AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, state, GetRestoreData());
|
||||||
if (ret == ERR_OK && state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
if (ret == ERR_OK && state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,9 +418,8 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
|||||||
TAG_LOGE(AAFwkTag::UIABILITY, "null owner");
|
TAG_LOGE(AAFwkTag::UIABILITY, "null owner");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
std::string entry = "UIAbilityImpl::WindowLifeCycleImpl::AfterForeground";
|
||||||
std::string entry = "UIAbilityImpl::WindowLifeCycleImpl::AfterForeground; the foreground lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
|
|
||||||
bool needNotifyAMS = false;
|
bool needNotifyAMS = false;
|
||||||
{
|
{
|
||||||
@ -437,14 +435,14 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
|||||||
|
|
||||||
if (needNotifyAMS) {
|
if (needNotifyAMS) {
|
||||||
TAG_LOGI(AAFwkTag::UIABILITY, "notify ability manager service");
|
TAG_LOGI(AAFwkTag::UIABILITY, "notify ability manager service");
|
||||||
entry = "AbilityManagerClient::AbilityTransitionDone; the transaction start.";
|
entry = "AbilityManagerClient::AbilityTransitionDone";
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
owner->lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND_NEW;
|
owner->lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND_NEW;
|
||||||
AppExecFwk::PacMap restoreData;
|
AppExecFwk::PacMap restoreData;
|
||||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(
|
auto ret = AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(
|
||||||
token_, AAFwk::AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
token_, AAFwk::AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
||||||
if (ret == ERR_OK) {
|
if (ret == ERR_OK) {
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,15 +452,14 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
|||||||
{
|
{
|
||||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||||
TAG_LOGI(AAFwkTag::UIABILITY, "Lifecycle:call");
|
TAG_LOGI(AAFwkTag::UIABILITY, "Lifecycle:call");
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::BACKGROUND };
|
std::string entry = "UIAbilityImpl::WindowLifeCycleImpl::AfterBackground";
|
||||||
std::string entry = "UIAbilityImpl::WindowLifeCycleImpl::AfterBackground; the background lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
|
|
||||||
AppExecFwk::PacMap restoreData;
|
AppExecFwk::PacMap restoreData;
|
||||||
auto ret = AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(
|
auto ret = AAFwk::AbilityManagerClient::GetInstance()->AbilityTransitionDone(
|
||||||
token_, AAFwk::AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
token_, AAFwk::AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
||||||
if (ret == ERR_OK) {
|
if (ret == ERR_OK) {
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,9 +487,8 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterUnfocused()
|
|||||||
void UIAbilityImpl::WindowLifeCycleImpl::ForegroundFailed(int32_t type)
|
void UIAbilityImpl::WindowLifeCycleImpl::ForegroundFailed(int32_t type)
|
||||||
{
|
{
|
||||||
TAG_LOGE(AAFwkTag::UIABILITY, "scb call, ForegroundFailed");
|
TAG_LOGE(AAFwkTag::UIABILITY, "scb call, ForegroundFailed");
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
std::string entry = "UIAbilityImpl::WindowLifeCycleImpl::ForegroundFailed; GoForeground failed";
|
||||||
std::string entry = "ERROR UIAbilityImpl::WindowLifeCycleImpl::ForegroundFailed; GoForeground failed.";
|
FreezeUtil::GetInstance().AppendLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow, entry);
|
|
||||||
AppExecFwk::PacMap restoreData;
|
AppExecFwk::PacMap restoreData;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case static_cast<int32_t>(OHOS::Rosen::WMError::WM_ERROR_INVALID_OPERATION): {
|
case static_cast<int32_t>(OHOS::Rosen::WMError::WM_ERROR_INVALID_OPERATION): {
|
||||||
|
@ -167,17 +167,16 @@ void UIAbilityThread::AttachInner(const std::shared_ptr<AppExecFwk::OHOSApplicat
|
|||||||
|
|
||||||
// ability attach : ipc
|
// ability attach : ipc
|
||||||
TAG_LOGI(AAFwkTag::UIABILITY, "Lifecycle:Attach");
|
TAG_LOGI(AAFwkTag::UIABILITY, "Lifecycle:Attach");
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::LOAD };
|
std::string entry = "AbilityThread::Attach";
|
||||||
std::string entry = "AbilityThread::Attach start; the load lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
ErrCode err = AbilityManagerClient::GetInstance()->AttachAbilityThread(this, token_);
|
ErrCode err = AbilityManagerClient::GetInstance()->AttachAbilityThread(this, token_);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
entry = std::string("AbilityThread::Attach failed ipc error: ") + std::to_string(err);
|
entry = std::string("AbilityThread::Attach; error ") + std::to_string(err);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
TAG_LOGE(AAFwkTag::UIABILITY, "err: %{public}d", err);
|
TAG_LOGE(AAFwkTag::UIABILITY, "err: %{public}d", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,14 +249,12 @@ void UIAbilityThread::HandleAbilityTransaction(
|
|||||||
void UIAbilityThread::AddLifecycleEvent(uint32_t state, std::string &methodName) const
|
void UIAbilityThread::AddLifecycleEvent(uint32_t state, std::string &methodName) const
|
||||||
{
|
{
|
||||||
if (state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
if (state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
std::string entry = "AbilityThread::" + methodName;
|
||||||
std::string entry = "AbilityThread::" + methodName + "; the foreground lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
if (state == AAFwk::ABILITY_STATE_BACKGROUND_NEW) {
|
if (state == AAFwk::ABILITY_STATE_BACKGROUND_NEW) {
|
||||||
FreezeUtil::LifecycleFlow flow = { token_, FreezeUtil::TimeoutState::BACKGROUND };
|
std::string entry = "AbilityThread::" + methodName;
|
||||||
std::string entry = "AbilityThread::" + methodName + "; the background lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token_, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "js_ability_stage.h"
|
#include "js_ability_stage.h"
|
||||||
|
|
||||||
#include "ability_delegator_registry.h"
|
#include "ability_delegator_registry.h"
|
||||||
|
#include "freeze_util.h"
|
||||||
#include "hilog_tag_wrapper.h"
|
#include "hilog_tag_wrapper.h"
|
||||||
#include "js_ability_stage_context.h"
|
#include "js_ability_stage_context.h"
|
||||||
#include "js_context_utils.h"
|
#include "js_context_utils.h"
|
||||||
@ -72,6 +73,7 @@ std::shared_ptr<AbilityStage> JsAbilityStage::Create(
|
|||||||
TAG_LOGW(AAFwkTag::APPKIT, "runtime is nullptr");
|
TAG_LOGW(AAFwkTag::APPKIT, "runtime is nullptr");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "JsAbilityStage::Create");
|
||||||
auto& jsRuntime = static_cast<JsRuntime&>(*runtime);
|
auto& jsRuntime = static_cast<JsRuntime&>(*runtime);
|
||||||
std::string srcPath(hapModuleInfo.name);
|
std::string srcPath(hapModuleInfo.name);
|
||||||
std::string moduleName(hapModuleInfo.moduleName);
|
std::string moduleName(hapModuleInfo.moduleName);
|
||||||
@ -169,8 +171,10 @@ void JsAbilityStage::OnCreate(const AAFwk::Want &want) const
|
|||||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get 'onCreate' from AbilityStage object");
|
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get 'onCreate' from AbilityStage object");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "JsAbilityStage::OnCreate begin");
|
||||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||||
napi_call_function(env, obj, methodOnCreate, 0, nullptr, nullptr);
|
napi_call_function(env, obj, methodOnCreate, 0, nullptr, nullptr);
|
||||||
|
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "JsAbilityStage::OnCreate end");
|
||||||
|
|
||||||
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||||
if (delegator) {
|
if (delegator) {
|
||||||
|
@ -734,9 +734,8 @@ void MainThread::ScheduleLaunchAbility(const AbilityInfo &info, const sptr<IRemo
|
|||||||
tmpWatchdog->SetBgWorkingThreadStatus(IsBgWorkingThread(info));
|
tmpWatchdog->SetBgWorkingThreadStatus(IsBgWorkingThread(info));
|
||||||
tmpWatchdog = nullptr;
|
tmpWatchdog = nullptr;
|
||||||
}
|
}
|
||||||
FreezeUtil::LifecycleFlow flow = { token, FreezeUtil::TimeoutState::LOAD };
|
std::string entry = "MainThread::ScheduleLaunchAbility";
|
||||||
std::string entry = "MainThread::ScheduleLaunchAbility; the load lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
|
|
||||||
wptr<MainThread> weak = this;
|
wptr<MainThread> weak = this;
|
||||||
auto task = [weak, abilityRecord]() {
|
auto task = [weak, abilityRecord]() {
|
||||||
@ -1297,7 +1296,7 @@ CJUncaughtExceptionInfo MainThread::CreateCjExceptionInfo(const std::string &bun
|
|||||||
void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, const Configuration &config)
|
void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, const Configuration &config)
|
||||||
{
|
{
|
||||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleLaunchApplication:begin");
|
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleLaunchApplication begin");
|
||||||
if (!CheckForHandleLaunchApplication(appLaunchData)) {
|
if (!CheckForHandleLaunchApplication(appLaunchData)) {
|
||||||
TAG_LOGE(AAFwkTag::APPKIT, "CheckForHandleLaunchApplication failed");
|
TAG_LOGE(AAFwkTag::APPKIT, "CheckForHandleLaunchApplication failed");
|
||||||
return;
|
return;
|
||||||
@ -1748,7 +1747,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
|||||||
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_->PerformAppReady failed");
|
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_->PerformAppReady failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleLaunchApplication:end");
|
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleLaunchApplication end");
|
||||||
// L1 needs to add corresponding interface
|
// L1 needs to add corresponding interface
|
||||||
ApplicationEnvImpl *pAppEvnIml = ApplicationEnvImpl::GetInstance();
|
ApplicationEnvImpl *pAppEvnIml = ApplicationEnvImpl::GetInstance();
|
||||||
|
|
||||||
@ -2159,9 +2158,8 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &
|
|||||||
|
|
||||||
auto abilityToken = abilityRecord->GetToken();
|
auto abilityToken = abilityRecord->GetToken();
|
||||||
CHECK_POINTER_LOG(abilityToken, "abilityRecord->GetToken failed");
|
CHECK_POINTER_LOG(abilityToken, "abilityRecord->GetToken failed");
|
||||||
FreezeUtil::LifecycleFlow flow = { abilityToken, FreezeUtil::TimeoutState::LOAD };
|
std::string entry = "MainThread::HandleLaunchAbility";
|
||||||
std::string entry = "MainThread::HandleLaunchAbility; the load lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(abilityToken, entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
|
|
||||||
abilityRecordMgr_->SetToken(abilityToken);
|
abilityRecordMgr_->SetToken(abilityToken);
|
||||||
abilityRecordMgr_->AddAbilityRecord(abilityToken, abilityRecord);
|
abilityRecordMgr_->AddAbilityRecord(abilityToken, abilityRecord);
|
||||||
@ -2332,7 +2330,7 @@ void MainThread::HandleForegroundApplication()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!applicationImpl_->PerformForeground()) {
|
if (!applicationImpl_->PerformForeground()) {
|
||||||
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleForegroundApplication fail");
|
FreezeUtil::GetInstance().AddAppLifecycleEvent(0, "HandleForegroundApplication; fail");
|
||||||
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_->PerformForeground() failed");
|
TAG_LOGE(AAFwkTag::APPKIT, "applicationImpl_->PerformForeground() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,9 +188,8 @@ int AppfreezeInner::AcquireStack(const FaultData& info, bool onlyMainThread)
|
|||||||
FaultData faultData;
|
FaultData faultData;
|
||||||
faultData.errorObject.message = it->errorObject.message + "\n";
|
faultData.errorObject.message = it->errorObject.message + "\n";
|
||||||
if (it->state != 0) {
|
if (it->state != 0) {
|
||||||
FreezeUtil::LifecycleFlow flow = { it->token, static_cast<FreezeUtil::TimeoutState>(it->state) };
|
faultData.errorObject.message += "client actions for ability:\n" +
|
||||||
faultData.errorObject.message += "client:\n" +
|
FreezeUtil::GetInstance().GetLifecycleEvent(it->token) + "\nclient actions for app:\n" +
|
||||||
FreezeUtil::GetInstance().GetLifecycleEvent(flow) + "\nclient app:\n" +
|
|
||||||
FreezeUtil::GetInstance().GetAppLifecycleEvent(0) + "\n";
|
FreezeUtil::GetInstance().GetAppLifecycleEvent(0) + "\n";
|
||||||
}
|
}
|
||||||
faultData.errorObject.stack = stack;
|
faultData.errorObject.stack = stack;
|
||||||
|
@ -67,11 +67,6 @@ enum UserStatus {
|
|||||||
ASSERT_CONTINUE,
|
ASSERT_CONTINUE,
|
||||||
ASSERT_RETRY,
|
ASSERT_RETRY,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class FreezeStrategy : uint8_t {
|
|
||||||
PRINT_FREEZE_LOG,
|
|
||||||
NOTIFY_FREEZE_MGR,
|
|
||||||
};
|
|
||||||
} // namespace AAFwk
|
} // namespace AAFwk
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
#endif // OHOS_ABILITY_RUNTIME_ABILITY_STATE_H
|
#endif // OHOS_ABILITY_RUNTIME_ABILITY_STATE_H
|
||||||
|
@ -61,9 +61,6 @@ ohos_shared_library("app_manager") {
|
|||||||
"src/appmgr/app_debug_info.cpp",
|
"src/appmgr/app_debug_info.cpp",
|
||||||
"src/appmgr/app_debug_listener_proxy.cpp",
|
"src/appmgr/app_debug_listener_proxy.cpp",
|
||||||
"src/appmgr/app_debug_listener_stub.cpp",
|
"src/appmgr/app_debug_listener_stub.cpp",
|
||||||
"src/appmgr/app_exception_callback_proxy.cpp",
|
|
||||||
"src/appmgr/app_exception_callback_stub.cpp",
|
|
||||||
"src/appmgr/app_exception_manager.cpp",
|
|
||||||
"src/appmgr/app_foreground_state_observer_proxy.cpp",
|
"src/appmgr/app_foreground_state_observer_proxy.cpp",
|
||||||
"src/appmgr/app_foreground_state_observer_stub.cpp",
|
"src/appmgr/app_foreground_state_observer_stub.cpp",
|
||||||
"src/appmgr/app_jsheap_mem_info.cpp",
|
"src/appmgr/app_jsheap_mem_info.cpp",
|
||||||
|
@ -463,8 +463,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetAppExceptionCallback(sptr<IRemoteObject> callback) {}
|
|
||||||
|
|
||||||
enum class Message {
|
enum class Message {
|
||||||
LOAD_ABILITY = 0,
|
LOAD_ABILITY = 0,
|
||||||
TERMINATE_ABILITY,
|
TERMINATE_ABILITY,
|
||||||
@ -518,7 +516,6 @@ public:
|
|||||||
IS_PROCESS_ATTACHED,
|
IS_PROCESS_ATTACHED,
|
||||||
IS_CALLER_KILLING,
|
IS_CALLER_KILLING,
|
||||||
ENABLE_START_PROCESS_FLAG_BY_USER_ID,
|
ENABLE_START_PROCESS_FLAG_BY_USER_ID,
|
||||||
SET_APP_EXCEPTION_CALLBACK,
|
|
||||||
SET_KEEP_ALIVE_DKV,
|
SET_KEEP_ALIVE_DKV,
|
||||||
KILL_PROCESSES_IN_BATCH,
|
KILL_PROCESSES_IN_BATCH,
|
||||||
// Add enumeration values above
|
// Add enumeration values above
|
||||||
|
@ -411,8 +411,6 @@ public:
|
|||||||
|
|
||||||
virtual bool IsCallerKilling(const std::string& callerKey) override;
|
virtual bool IsCallerKilling(const std::string& callerKey) override;
|
||||||
|
|
||||||
virtual void SetAppExceptionCallback(sptr<IRemoteObject> callback) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool WriteInterfaceToken(MessageParcel &data);
|
bool WriteInterfaceToken(MessageParcel &data);
|
||||||
int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
||||||
|
@ -104,7 +104,6 @@ private:
|
|||||||
int32_t HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply);
|
||||||
int32_t HandleIsProcessAttached(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleIsProcessAttached(MessageParcel &data, MessageParcel &reply);
|
||||||
int32_t HandleIsCallerKilling(MessageParcel &data, MessageParcel &reply);
|
int32_t HandleIsCallerKilling(MessageParcel &data, MessageParcel &reply);
|
||||||
int32_t HandleSetAppExceptionCallback(MessageParcel &data, MessageParcel &reply);
|
|
||||||
DISALLOW_COPY_AND_MOVE(AmsMgrStub);
|
DISALLOW_COPY_AND_MOVE(AmsMgrStub);
|
||||||
};
|
};
|
||||||
} // namespace AppExecFwk
|
} // namespace AppExecFwk
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OHOS_ABILITY_RUNTIME_APP_EXCEPTION_CALLBACK_PROXY_H
|
|
||||||
#define OHOS_ABILITY_RUNTIME_APP_EXCEPTION_CALLBACK_PROXY_H
|
|
||||||
|
|
||||||
#include "iapp_exception_callback.h"
|
|
||||||
#include "iremote_proxy.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace AppExecFwk {
|
|
||||||
class AppExceptionCallbackProxy : public IRemoteProxy<IAppExceptionCallback> {
|
|
||||||
public:
|
|
||||||
explicit AppExceptionCallbackProxy(const sptr<IRemoteObject> &impl);
|
|
||||||
virtual ~AppExceptionCallbackProxy() = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify abilityManager lifecycle exception.
|
|
||||||
*
|
|
||||||
* @param type lifecycle failed type
|
|
||||||
* @param token associated ability
|
|
||||||
*/
|
|
||||||
virtual void OnLifecycleException(LifecycleException type, sptr<IRemoteObject> token);
|
|
||||||
private:
|
|
||||||
bool WriteInterfaceToken(MessageParcel &data);
|
|
||||||
static inline BrokerDelegator<AppExceptionCallbackProxy> delegator_;
|
|
||||||
int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
|
|
||||||
};
|
|
||||||
} // namespace AppExecFwk
|
|
||||||
} // namespace OHOS
|
|
||||||
#endif // OHOS_ABILITY_RUNTIME_APP_EXCEPTION_CALLBACK_PROXY_H
|
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OHOS_ABILITY_RUNTIME_APP_EXCEPTION_CALLBACK_STUB_H
|
|
||||||
#define OHOS_ABILITY_RUNTIME_APP_EXCEPTION_CALLBACK_STUB_H
|
|
||||||
|
|
||||||
#include "iapp_exception_callback.h"
|
|
||||||
#include "iremote_stub.h"
|
|
||||||
#include "nocopyable.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace AppExecFwk {
|
|
||||||
class AppExceptionCallbackStub : public IRemoteStub<IAppExceptionCallback> {
|
|
||||||
public:
|
|
||||||
AppExceptionCallbackStub() = default;
|
|
||||||
virtual ~AppExceptionCallbackStub() = default;
|
|
||||||
|
|
||||||
virtual int32_t OnRemoteRequest(
|
|
||||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
|
||||||
private:
|
|
||||||
int32_t HandleLifecycleException(MessageParcel &data, MessageParcel &reply);
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_MOVE(AppExceptionCallbackStub);
|
|
||||||
};
|
|
||||||
} // namespace AppExecFwk
|
|
||||||
} // namespace OHOS
|
|
||||||
#endif // OHOS_ABILITY_RUNTIME_APP_EXCEPTION_CALLBACK_STUB_H
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OHOS_ABILITY_RUNTIME_APP_EXCEPTION_MANAGER_H
|
|
||||||
#define OHOS_ABILITY_RUNTIME_APP_EXCEPTION_MANAGER_H
|
|
||||||
|
|
||||||
#include "iapp_exception_callback.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace AppExecFwk {
|
|
||||||
class AppExceptionManager {
|
|
||||||
public:
|
|
||||||
static AppExceptionManager &GetInstance();
|
|
||||||
AppExceptionManager(AppExceptionManager &) = delete;
|
|
||||||
void operator=(AppExceptionManager &) = delete;
|
|
||||||
|
|
||||||
void LaunchAbilityFailed(sptr<IRemoteObject> token, const std::string &msg);
|
|
||||||
void ForegroundAppFailed(sptr<IRemoteObject> token, const std::string &msg);
|
|
||||||
void ForegroundAppWait(sptr<IRemoteObject> token, const std::string &msg);
|
|
||||||
|
|
||||||
void NotifyLifecycleException(LifecycleException type, sptr<IRemoteObject> token);
|
|
||||||
void SetExceptionCallback(sptr<IAppExceptionCallback> exceptionCallback);
|
|
||||||
sptr<IAppExceptionCallback> GetExceptionCallback() const;
|
|
||||||
private:
|
|
||||||
AppExceptionManager() = default;
|
|
||||||
mutable std::mutex exceptionCallbackMutex_;
|
|
||||||
sptr<IAppExceptionCallback> exceptionCallback_;
|
|
||||||
};
|
|
||||||
} // namespace AppExecFwk
|
|
||||||
} // namespace OHOS
|
|
||||||
#endif // OHOS_ABILITY_RUNTIME_APP_EXCEPTION_MANAGER_H
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OHOS_ABILITY_RUNTIME_I_APP_EXCEPTION_CALLBACK_H
|
|
||||||
#define OHOS_ABILITY_RUNTIME_I_APP_EXCEPTION_CALLBACK_H
|
|
||||||
|
|
||||||
#include "iremote_broker.h"
|
|
||||||
#include "iremote_object.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace AppExecFwk {
|
|
||||||
enum class LifecycleException {
|
|
||||||
LAUNCH_ABILITY_FAIL,
|
|
||||||
FOREGROUND_APP_FAIL,
|
|
||||||
FOREGROUND_APP_WAIT,
|
|
||||||
END
|
|
||||||
};
|
|
||||||
|
|
||||||
class IAppExceptionCallback : public IRemoteBroker {
|
|
||||||
public:
|
|
||||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AppExceptionCallback");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify abilityManager lifecycle exception.
|
|
||||||
*
|
|
||||||
* @param type lifecycle failed type
|
|
||||||
* @param token associated ability
|
|
||||||
*/
|
|
||||||
virtual void OnLifecycleException(LifecycleException type, sptr<IRemoteObject> token) {}
|
|
||||||
|
|
||||||
enum class Message {
|
|
||||||
LIFECYCLE_EXCEPTION_MSG_ID = 0,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} // namespace AppExecFwk
|
|
||||||
} // namespace OHOS
|
|
||||||
#endif // OHOS_ABILITY_RUNTIME_I_APP_EXCEPTION_CALLBACK_H
|
|
@ -1395,27 +1395,5 @@ bool AmsMgrProxy::IsCallerKilling(const std::string& callerKey)
|
|||||||
}
|
}
|
||||||
return reply.ReadBool();
|
return reply.ReadBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmsMgrProxy::SetAppExceptionCallback(sptr<IRemoteObject> callback)
|
|
||||||
{
|
|
||||||
MessageParcel data;
|
|
||||||
MessageParcel reply;
|
|
||||||
MessageOption option;
|
|
||||||
if (!WriteInterfaceToken(data)) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!data.WriteRemoteObject(callback.GetRefPtr())) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write callback");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ret = SendTransactCmd(static_cast<uint32_t>(IAmsMgr::Message::SET_APP_EXCEPTION_CALLBACK),
|
|
||||||
data, reply, option);
|
|
||||||
if (ret != NO_ERROR) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Send request failed, error code is %{public}d.", ret);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace AppExecFwk
|
} // namespace AppExecFwk
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -901,12 +901,5 @@ int32_t AmsMgrStub::HandleIsCallerKilling(MessageParcel &data, MessageParcel &re
|
|||||||
}
|
}
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t AmsMgrStub::HandleSetAppExceptionCallback(MessageParcel &data, MessageParcel &reply)
|
|
||||||
{
|
|
||||||
sptr<IRemoteObject> callback = data.ReadRemoteObject();
|
|
||||||
SetAppExceptionCallback(callback);
|
|
||||||
return NO_ERROR;
|
|
||||||
}
|
|
||||||
} // namespace AppExecFwk
|
} // namespace AppExecFwk
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "app_exception_callback_proxy.h"
|
|
||||||
|
|
||||||
#include "hilog_tag_wrapper.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace AppExecFwk {
|
|
||||||
AppExceptionCallbackProxy::AppExceptionCallbackProxy(const sptr<IRemoteObject> &impl)
|
|
||||||
: IRemoteProxy<IAppExceptionCallback>(impl) {}
|
|
||||||
|
|
||||||
bool AppExceptionCallbackProxy::WriteInterfaceToken(MessageParcel &data)
|
|
||||||
{
|
|
||||||
if (!data.WriteInterfaceToken(AppExceptionCallbackProxy::GetDescriptor())) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "write interface token failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t AppExceptionCallbackProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
|
|
||||||
MessageParcel &reply, MessageOption &option)
|
|
||||||
{
|
|
||||||
sptr<IRemoteObject> remote = Remote();
|
|
||||||
if (remote == nullptr) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr.");
|
|
||||||
return ERR_NULL_OBJECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ret = remote->SendRequest(code, data, reply, option);
|
|
||||||
if (ret != NO_ERROR) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Send request failed with error code: %{public}d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionCallbackProxy::OnLifecycleException(LifecycleException type, sptr<IRemoteObject> token)
|
|
||||||
{
|
|
||||||
MessageParcel data;
|
|
||||||
MessageParcel reply;
|
|
||||||
MessageOption option(MessageOption::TF_ASYNC);
|
|
||||||
if (!WriteInterfaceToken(data)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t exceptionType = static_cast<int32_t>(type);
|
|
||||||
if (!data.WriteInt32(exceptionType)) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write exceptionType");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token) {
|
|
||||||
if (!data.WriteBool(true) || !data.WriteRemoteObject(token.GetRefPtr())) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag and token");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!data.WriteBool(false)) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ret = SendTransactCmd(
|
|
||||||
static_cast<uint32_t>(IAppExceptionCallback::Message::LIFECYCLE_EXCEPTION_MSG_ID), data, reply, option);
|
|
||||||
if (ret != NO_ERROR) {
|
|
||||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namespace AppExecFwk
|
|
||||||
} // namespace OHOS
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "app_exception_callback_stub.h"
|
|
||||||
|
|
||||||
#include "hilog_tag_wrapper.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace AppExecFwk {
|
|
||||||
int32_t AppExceptionCallbackStub::OnRemoteRequest(
|
|
||||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
|
||||||
{
|
|
||||||
std::u16string descriptor = AppExceptionCallbackStub::GetDescriptor();
|
|
||||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
|
||||||
if (descriptor != remoteDescriptor) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "local descriptor is not equal to remote");
|
|
||||||
return ERR_INVALID_STATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (code) {
|
|
||||||
case static_cast<uint32_t>(IAppExceptionCallback::Message::LIFECYCLE_EXCEPTION_MSG_ID):
|
|
||||||
return HandleLifecycleException(data, reply);
|
|
||||||
default:
|
|
||||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t AppExceptionCallbackStub::HandleLifecycleException(MessageParcel &data, MessageParcel &reply)
|
|
||||||
{
|
|
||||||
auto type = data.ReadInt32();
|
|
||||||
if (type < 0 || type > static_cast<int32_t>(LifecycleException::END)) {
|
|
||||||
return ERR_INVALID_STATE;
|
|
||||||
}
|
|
||||||
auto lifecycleExceptType = static_cast<LifecycleException>(type);
|
|
||||||
sptr<IRemoteObject> token;
|
|
||||||
if (data.ReadBool()) {
|
|
||||||
token = data.ReadRemoteObject();
|
|
||||||
}
|
|
||||||
OnLifecycleException(lifecycleExceptType, token);
|
|
||||||
return ERR_OK;
|
|
||||||
}
|
|
||||||
} // namespace AppExecFwk
|
|
||||||
} // namespace OHOS
|
|
@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "app_exception_manager.h"
|
|
||||||
|
|
||||||
#include "freeze_util.h"
|
|
||||||
#include "hilog_tag_wrapper.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
using AbilityRuntime::FreezeUtil;
|
|
||||||
namespace AppExecFwk {
|
|
||||||
AppExceptionManager &AppExceptionManager::GetInstance()
|
|
||||||
{
|
|
||||||
static AppExceptionManager appExceptionMgr;
|
|
||||||
return appExceptionMgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionManager::LaunchAbilityFailed(sptr<IRemoteObject> token, const std::string &msg)
|
|
||||||
{
|
|
||||||
FreezeUtil::LifecycleFlow flow{token, FreezeUtil::TimeoutState::LOAD};
|
|
||||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow, std::string("LaunchAbilityFailed: " + msg));
|
|
||||||
NotifyLifecycleException(LifecycleException::LAUNCH_ABILITY_FAIL, token);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionManager::ForegroundAppFailed(sptr<IRemoteObject> token, const std::string &msg)
|
|
||||||
{
|
|
||||||
FreezeUtil::LifecycleFlow flow{token, FreezeUtil::TimeoutState::FOREGROUND};
|
|
||||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow, std::string("ForegroundAppFailed: " + msg));
|
|
||||||
NotifyLifecycleException(LifecycleException::FOREGROUND_APP_FAIL, token);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionManager::ForegroundAppWait(sptr<IRemoteObject> token, const std::string &msg)
|
|
||||||
{
|
|
||||||
FreezeUtil::LifecycleFlow flow{token, FreezeUtil::TimeoutState::FOREGROUND};
|
|
||||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow, std::string("ForegroundAppWait: " + msg));
|
|
||||||
NotifyLifecycleException(LifecycleException::FOREGROUND_APP_WAIT, token);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionManager::NotifyLifecycleException(LifecycleException type, sptr<IRemoteObject> token)
|
|
||||||
{
|
|
||||||
auto callback = GetExceptionCallback();
|
|
||||||
if (callback != nullptr) {
|
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "notify app exception");
|
|
||||||
callback->OnLifecycleException(type, token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionManager::SetExceptionCallback(sptr<IAppExceptionCallback> exceptionCallback)
|
|
||||||
{
|
|
||||||
if (exceptionCallback == nullptr) {
|
|
||||||
TAG_LOGW(AAFwkTag::APPMGR, "callback null");
|
|
||||||
}
|
|
||||||
std::lock_guard lock(exceptionCallbackMutex_);
|
|
||||||
if (exceptionCallback_ != nullptr) {
|
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "inner callback not null");
|
|
||||||
}
|
|
||||||
exceptionCallback_ = exceptionCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
sptr<IAppExceptionCallback> AppExceptionManager::GetExceptionCallback() const
|
|
||||||
{
|
|
||||||
std::lock_guard lock(exceptionCallbackMutex_);
|
|
||||||
return exceptionCallback_;
|
|
||||||
}
|
|
||||||
} // namespace AppExecFwk
|
|
||||||
} // namespace OHOS
|
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "app_scheduler_proxy.h"
|
#include "app_scheduler_proxy.h"
|
||||||
|
|
||||||
#include "app_exception_manager.h"
|
#include "error_msg_util.h"
|
||||||
#include "freeze_util.h"
|
#include "freeze_util.h"
|
||||||
#include "hilog_tag_wrapper.h"
|
#include "hilog_tag_wrapper.h"
|
||||||
#include "hitrace_meter.h"
|
#include "hitrace_meter.h"
|
||||||
@ -46,6 +46,9 @@ bool AppSchedulerProxy::ScheduleForegroundApplication()
|
|||||||
if (!WriteInterfaceToken(data)) {
|
if (!WriteInterfaceToken(data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
auto msgKey = AbilityRuntime::ErrorMgsUtil::BuildErrorKey(reinterpret_cast<uintptr_t>(this),
|
||||||
|
"ScheduleForegroundRunning");
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "AppScheduler::ScheduleForegroundApplication");
|
||||||
int32_t ret =
|
int32_t ret =
|
||||||
SendTransactCmd(static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION),
|
SendTransactCmd(static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION),
|
||||||
data,
|
data,
|
||||||
@ -53,6 +56,8 @@ bool AppSchedulerProxy::ScheduleForegroundApplication()
|
|||||||
option);
|
option);
|
||||||
if (ret != NO_ERROR) {
|
if (ret != NO_ERROR) {
|
||||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey,
|
||||||
|
std::string("ScheduleForegroundApplication ipc error ") + std::to_string(ret));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -193,7 +198,6 @@ void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const spt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data.WriteParcelable(&info);
|
data.WriteParcelable(&info);
|
||||||
AbilityRuntime::FreezeUtil::LifecycleFlow flow = {token, AbilityRuntime::FreezeUtil::TimeoutState::LOAD};
|
|
||||||
if (token) {
|
if (token) {
|
||||||
if (!data.WriteBool(true) || !data.WriteRemoteObject(token.GetRefPtr())) {
|
if (!data.WriteBool(true) || !data.WriteRemoteObject(token.GetRefPtr())) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag and token");
|
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write flag and token");
|
||||||
@ -208,8 +212,8 @@ void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const spt
|
|||||||
|
|
||||||
if (!data.WriteParcelable(want.get())) {
|
if (!data.WriteParcelable(want.get())) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "write want fail.");
|
TAG_LOGE(AAFwkTag::APPMGR, "write want fail.");
|
||||||
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
|
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(token,
|
||||||
"ERROR AppLifeCycleDeal::LaunchAbility; write want fail");
|
"AppLifeCycleDeal::LaunchAbility; write want fail");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!data.WriteInt32(abilityRecordId)) {
|
if (!data.WriteInt32(abilityRecordId)) {
|
||||||
@ -220,8 +224,8 @@ void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const spt
|
|||||||
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_ABILITY_TRANSACTION), data, reply, option);
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_ABILITY_TRANSACTION), data, reply, option);
|
||||||
if (ret != NO_ERROR) {
|
if (ret != NO_ERROR) {
|
||||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
||||||
AppExceptionManager::GetInstance().LaunchAbilityFailed(token, std::string("SendRequest failed") +
|
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(token,
|
||||||
std::to_string(ret));
|
"AppLifeCycleDeal::LaunchAbility; ipc error " + std::to_string(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,13 +262,18 @@ void AppSchedulerProxy::ScheduleLaunchApplication(const AppLaunchData &launchDat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto msgKey = AbilityRuntime::ErrorMgsUtil::BuildErrorKey(reinterpret_cast<uintptr_t>(this),
|
||||||
|
"LaunchApplication");
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "AppScheduler::ScheduleLaunchApplication");
|
||||||
if (!data.WriteParcelable(&launchData)) {
|
if (!data.WriteParcelable(&launchData)) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteParcelable launchData failed");
|
TAG_LOGE(AAFwkTag::APPMGR, "WriteParcelable launchData failed");
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write launchData fail");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.WriteParcelable(&config)) {
|
if (!data.WriteParcelable(&config)) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteParcelable config failed");
|
TAG_LOGE(AAFwkTag::APPMGR, "WriteParcelable config failed");
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write config fail");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,6 +281,8 @@ void AppSchedulerProxy::ScheduleLaunchApplication(const AppLaunchData &launchDat
|
|||||||
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_APPLICATION_TRANSACTION), data, reply, option);
|
static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_LAUNCH_APPLICATION_TRANSACTION), data, reply, option);
|
||||||
if (ret != NO_ERROR) {
|
if (ret != NO_ERROR) {
|
||||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey,
|
||||||
|
std::string("ScheduleLaunchApplication ipc error ") + std::to_string(ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ abilityms_files = [
|
|||||||
"src/ability_manager_xcollie.cpp",
|
"src/ability_manager_xcollie.cpp",
|
||||||
"src/ability_scheduler_proxy.cpp",
|
"src/ability_scheduler_proxy.cpp",
|
||||||
"src/ability_token_stub.cpp",
|
"src/ability_token_stub.cpp",
|
||||||
"src/app_exception_handler.cpp",
|
|
||||||
"src/app_scheduler.cpp",
|
"src/app_scheduler.cpp",
|
||||||
"src/app_exit_reason_helper.cpp",
|
"src/app_exit_reason_helper.cpp",
|
||||||
"src/assert_fault_callback_death_mgr.cpp",
|
"src/assert_fault_callback_death_mgr.cpp",
|
||||||
|
@ -1128,16 +1128,6 @@ public:
|
|||||||
return securityFlag_;
|
return securityFlag_;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreezeStrategy GetFreezeStrategy() const
|
|
||||||
{
|
|
||||||
return freezeStrategy_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFreezeStrategy(FreezeStrategy value)
|
|
||||||
{
|
|
||||||
freezeStrategy_ = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1, bool isExtension = false);
|
void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1, bool isExtension = false);
|
||||||
|
|
||||||
@ -1365,7 +1355,6 @@ private:
|
|||||||
LaunchDebugInfo launchDebugInfo_;
|
LaunchDebugInfo launchDebugInfo_;
|
||||||
std::string instanceKey_ = "";
|
std::string instanceKey_ = "";
|
||||||
bool securityFlag_ = false;
|
bool securityFlag_ = false;
|
||||||
std::atomic<FreezeStrategy> freezeStrategy_{FreezeStrategy::NOTIFY_FREEZE_MGR};
|
|
||||||
};
|
};
|
||||||
} // namespace AAFwk
|
} // namespace AAFwk
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OHOS_ABILITY_RUNTIME_APP_EXCEPTION_HANDLER_H
|
|
||||||
#define OHOS_ABILITY_RUNTIME_APP_EXCEPTION_HANDLER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "iremote_object.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
namespace AAFwk {
|
|
||||||
class AppExceptionHandler {
|
|
||||||
public:
|
|
||||||
static AppExceptionHandler &GetInstance();
|
|
||||||
AppExceptionHandler(AppExceptionHandler &) = delete;
|
|
||||||
void operator=(AppExceptionHandler &) = delete;
|
|
||||||
|
|
||||||
void RegisterAppExceptionCallback();
|
|
||||||
void AbilityForegroundFailed(sptr<IRemoteObject> token, const std::string &msg);
|
|
||||||
private:
|
|
||||||
AppExceptionHandler() = default;
|
|
||||||
};
|
|
||||||
} // namespace AAFwk
|
|
||||||
} // namespace OHOS
|
|
||||||
#endif // OHOS_ABILITY_RUNTIME_APP_EXCEPTION_HANDLER_H
|
|
@ -1336,7 +1336,6 @@ int AbilityManagerProxy::AttachAbilityThread(const sptr<IAbilityScheduler> &sche
|
|||||||
MessageParcel data;
|
MessageParcel data;
|
||||||
MessageParcel reply;
|
MessageParcel reply;
|
||||||
MessageOption option;
|
MessageOption option;
|
||||||
AbilityRuntime::FreezeUtil::LifecycleFlow flow = {token, AbilityRuntime::FreezeUtil::TimeoutState::LOAD};
|
|
||||||
if (scheduler == nullptr) {
|
if (scheduler == nullptr) {
|
||||||
return ERR_INVALID_VALUE;
|
return ERR_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
@ -1351,8 +1350,8 @@ int AbilityManagerProxy::AttachAbilityThread(const sptr<IAbilityScheduler> &sche
|
|||||||
error = SendRequest(AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD, data, reply, option);
|
error = SendRequest(AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD, data, reply, option);
|
||||||
if (error != NO_ERROR) {
|
if (error != NO_ERROR) {
|
||||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
|
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
|
||||||
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
|
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(token,
|
||||||
std::string("ERROR AttachAbilityThread failed IPC error") + std::to_string(error));
|
std::string("AttachAbilityThread; ipc error ") + std::to_string(error));
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
return reply.ReadInt32();
|
return reply.ReadInt32();
|
||||||
@ -1365,7 +1364,6 @@ int AbilityManagerProxy::AbilityTransitionDone(const sptr<IRemoteObject> &token,
|
|||||||
MessageParcel reply;
|
MessageParcel reply;
|
||||||
MessageOption option;
|
MessageOption option;
|
||||||
|
|
||||||
AbilityRuntime::FreezeUtil::LifecycleFlow flow = {token, AbilityRuntime::FreezeUtil::TimeoutState::FOREGROUND};
|
|
||||||
if (!WriteInterfaceToken(data)) {
|
if (!WriteInterfaceToken(data)) {
|
||||||
return INNER_ERR;
|
return INNER_ERR;
|
||||||
}
|
}
|
||||||
@ -1375,16 +1373,16 @@ int AbilityManagerProxy::AbilityTransitionDone(const sptr<IRemoteObject> &token,
|
|||||||
}
|
}
|
||||||
if (!data.WriteParcelable(&saveData)) {
|
if (!data.WriteParcelable(&saveData)) {
|
||||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "saveData write fail");
|
TAG_LOGE(AAFwkTag::ABILITYMGR, "saveData write fail");
|
||||||
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
|
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(token,
|
||||||
"write saveData failed");
|
"AbilityTransitionDone; write saveData failed");
|
||||||
return INNER_ERR;
|
return INNER_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = SendRequest(AbilityManagerInterfaceCode::ABILITY_TRANSITION_DONE, data, reply, option);
|
error = SendRequest(AbilityManagerInterfaceCode::ABILITY_TRANSITION_DONE, data, reply, option);
|
||||||
if (error != NO_ERROR) {
|
if (error != NO_ERROR) {
|
||||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
|
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
|
||||||
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
|
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(token,
|
||||||
std::string("ERROR AbilityTransitionDone failed IPC error") + std::to_string(error));
|
std::string("AbilityTransitionDone; ipc error ") + std::to_string(error));
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
return reply.ReadInt32();
|
return reply.ReadInt32();
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "ability_manager_radar.h"
|
#include "ability_manager_radar.h"
|
||||||
#include "accesstoken_kit.h"
|
#include "accesstoken_kit.h"
|
||||||
#include "ability_manager_xcollie.h"
|
#include "ability_manager_xcollie.h"
|
||||||
#include "app_exception_handler.h"
|
|
||||||
#include "app_utils.h"
|
#include "app_utils.h"
|
||||||
#include "app_exit_reason_data_manager.h"
|
#include "app_exit_reason_data_manager.h"
|
||||||
#include "application_util.h"
|
#include "application_util.h"
|
||||||
@ -5399,9 +5398,8 @@ int AbilityManagerService::AttachAbilityThread(
|
|||||||
}
|
}
|
||||||
return dataAbilityManager->AttachAbilityThread(scheduler, token);
|
return dataAbilityManager->AttachAbilityThread(scheduler, token);
|
||||||
} else {
|
} else {
|
||||||
FreezeUtil::LifecycleFlow flow = { token, FreezeUtil::TimeoutState::LOAD };
|
|
||||||
std::string entry = "AbilityManagerService::AttachAbilityThread; the end of load lifecycle.";
|
std::string entry = "AbilityManagerService::AttachAbilityThread; the end of load lifecycle.";
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, entry);
|
||||||
int32_t ownerMissionUserId = abilityRecord->GetOwnerMissionUserId();
|
int32_t ownerMissionUserId = abilityRecord->GetOwnerMissionUserId();
|
||||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||||
auto uiAbilityManager = GetUIAbilityManagerByUserId(ownerMissionUserId);
|
auto uiAbilityManager = GetUIAbilityManagerByUserId(ownerMissionUserId);
|
||||||
@ -6003,14 +6001,12 @@ int AbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &toke
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (targetState == AbilityState::BACKGROUND) {
|
if (targetState == AbilityState::BACKGROUND) {
|
||||||
FreezeUtil::LifecycleFlow flow = { token, FreezeUtil::TimeoutState::BACKGROUND };
|
|
||||||
std::string entry = "AbilityManagerService::AbilityTransitionDone; the end of background lifecycle.";
|
std::string entry = "AbilityManagerService::AbilityTransitionDone; the end of background lifecycle.";
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, entry);
|
||||||
} else if (targetState != AbilityState::INITIAL) {
|
} else if (targetState != AbilityState::INITIAL) {
|
||||||
FreezeUtil::LifecycleFlow flow = { token, FreezeUtil::TimeoutState::FOREGROUND };
|
|
||||||
std::string entry = "AbilityManagerService::AbilityTransitionDone; the end of foreground lifecycle."
|
std::string entry = "AbilityManagerService::AbilityTransitionDone; the end of foreground lifecycle."
|
||||||
" the end of foreground lifecycle.";
|
" the end of foreground lifecycle.";
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ownerMissionUserId = abilityRecord->GetOwnerMissionUserId();
|
int32_t ownerMissionUserId = abilityRecord->GetOwnerMissionUserId();
|
||||||
@ -7268,7 +7264,6 @@ void AbilityManagerService::ConnectServices()
|
|||||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed init appScheduler");
|
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed init appScheduler");
|
||||||
usleep(REPOLL_TIME_MICRO_SECONDS);
|
usleep(REPOLL_TIME_MICRO_SECONDS);
|
||||||
}
|
}
|
||||||
AppExceptionHandler::GetInstance().RegisterAppExceptionCallback();
|
|
||||||
|
|
||||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "waiting bundleMgr service run completed");
|
TAG_LOGI(AAFwkTag::ABILITYMGR, "waiting bundleMgr service run completed");
|
||||||
while (AbilityUtil::GetBundleManagerHelper() == nullptr) {
|
while (AbilityUtil::GetBundleManagerHelper() == nullptr) {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "ability_manager_service.h"
|
#include "ability_manager_service.h"
|
||||||
#include "ability_resident_process_rdb.h"
|
#include "ability_resident_process_rdb.h"
|
||||||
#include "ability_scheduler_stub.h"
|
#include "ability_scheduler_stub.h"
|
||||||
#include "app_exception_handler.h"
|
|
||||||
#include "app_exit_reason_data_manager.h"
|
#include "app_exit_reason_data_manager.h"
|
||||||
#include "app_utils.h"
|
#include "app_utils.h"
|
||||||
#include "array_wrapper.h"
|
#include "array_wrapper.h"
|
||||||
@ -28,6 +27,7 @@
|
|||||||
#include "configuration_convertor.h"
|
#include "configuration_convertor.h"
|
||||||
#include "connection_state_manager.h"
|
#include "connection_state_manager.h"
|
||||||
#include "common_event_manager.h"
|
#include "common_event_manager.h"
|
||||||
|
#include "error_msg_util.h"
|
||||||
#include "freeze_util.h"
|
#include "freeze_util.h"
|
||||||
#include "global_constant.h"
|
#include "global_constant.h"
|
||||||
#include "hitrace_meter.h"
|
#include "hitrace_meter.h"
|
||||||
@ -108,11 +108,10 @@ const int MAX_URI_COUNT = 500;
|
|||||||
const int RESTART_SCENEBOARD_DELAY = 500;
|
const int RESTART_SCENEBOARD_DELAY = 500;
|
||||||
constexpr int32_t DMS_UID = 5522;
|
constexpr int32_t DMS_UID = 5522;
|
||||||
|
|
||||||
auto g_addLifecycleEventTask = [](sptr<Token> token, FreezeUtil::TimeoutState state, std::string &methodName) {
|
auto g_addLifecycleEventTask = [](sptr<Token> token, std::string &methodName) {
|
||||||
CHECK_POINTER_LOG(token, "token is nullptr");
|
CHECK_POINTER_LOG(token, "token is nullptr");
|
||||||
FreezeUtil::LifecycleFlow flow = { token->AsObject(), state };
|
|
||||||
std::string entry = std::string("AbilityRecord::") + methodName + "; the " + methodName + " lifecycle starts.";
|
std::string entry = std::string("AbilityRecord::") + methodName + "; the " + methodName + " lifecycle starts.";
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token->AsObject(), entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
Token::Token(std::weak_ptr<AbilityRecord> abilityRecord) : abilityRecord_(abilityRecord)
|
Token::Token(std::weak_ptr<AbilityRecord> abilityRecord) : abilityRecord_(abilityRecord)
|
||||||
@ -308,7 +307,7 @@ void AbilityRecord::LoadUIAbility()
|
|||||||
SendEvent(AbilityManagerService::LOAD_HALF_TIMEOUT_MSG, loadTimeout / HALF_TIMEOUT);
|
SendEvent(AbilityManagerService::LOAD_HALF_TIMEOUT_MSG, loadTimeout / HALF_TIMEOUT);
|
||||||
SendEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, loadTimeout);
|
SendEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, loadTimeout);
|
||||||
std::string methodName = "LoadAbility";
|
std::string methodName = "LoadAbility";
|
||||||
g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::LOAD, methodName);
|
g_addLifecycleEventTask(token_, methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AbilityRecord::LoadAbility(bool isShellCall)
|
int AbilityRecord::LoadAbility(bool isShellCall)
|
||||||
@ -410,9 +409,9 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag)
|
|||||||
lifeCycleStateInfo_.sceneFlag = sceneFlag;
|
lifeCycleStateInfo_.sceneFlag = sceneFlag;
|
||||||
Want want = GetWant();
|
Want want = GetWant();
|
||||||
UpdateDmsCallerInfo(want);
|
UpdateDmsCallerInfo(want);
|
||||||
if (!lifecycleDeal_->ForegroundNew(want, lifeCycleStateInfo_, GetSessionInfo()) && token_) {
|
AbilityRuntime::ErrorMsgGuard errorMsgGuard(token_ ? token_->AsObject() : nullptr,
|
||||||
AppExceptionHandler::GetInstance().AbilityForegroundFailed(token_->AsObject(), "ForegroundNew");
|
reinterpret_cast<uintptr_t>(GetScheduler().GetRefPtr()), "ScheduleAbilityTransaction");
|
||||||
}
|
lifecycleDeal_->ForegroundNew(want, lifeCycleStateInfo_, GetSessionInfo());
|
||||||
lifeCycleStateInfo_.sceneFlag = 0;
|
lifeCycleStateInfo_.sceneFlag = 0;
|
||||||
lifeCycleStateInfo_.sceneFlagBak = 0;
|
lifeCycleStateInfo_.sceneFlagBak = 0;
|
||||||
{
|
{
|
||||||
@ -501,7 +500,7 @@ void AbilityRecord::PostForegroundTimeoutTask()
|
|||||||
SendEvent(AbilityManagerService::FOREGROUND_HALF_TIMEOUT_MSG, foregroundTimeout / HALF_TIMEOUT);
|
SendEvent(AbilityManagerService::FOREGROUND_HALF_TIMEOUT_MSG, foregroundTimeout / HALF_TIMEOUT);
|
||||||
SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, foregroundTimeout);
|
SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, foregroundTimeout);
|
||||||
std::string methodName = "ProcessForegroundAbility";
|
std::string methodName = "ProcessForegroundAbility";
|
||||||
g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::FOREGROUND, methodName);
|
g_addLifecycleEventTask(token_, methodName);
|
||||||
ResSchedUtil::GetInstance().ReportLoadingEventToRss(LoadingStage::FOREGROUND_BEGIN, GetPid(), GetUid(),
|
ResSchedUtil::GetInstance().ReportLoadingEventToRss(LoadingStage::FOREGROUND_BEGIN, GetPid(), GetUid(),
|
||||||
foregroundTimeout, GetAbilityRecordId());
|
foregroundTimeout, GetAbilityRecordId());
|
||||||
}
|
}
|
||||||
@ -512,7 +511,6 @@ void AbilityRecord::RemoveForegroundTimeoutTask()
|
|||||||
CHECK_POINTER(handler);
|
CHECK_POINTER(handler);
|
||||||
handler->RemoveEvent(AbilityManagerService::FOREGROUND_HALF_TIMEOUT_MSG, GetAbilityRecordId());
|
handler->RemoveEvent(AbilityManagerService::FOREGROUND_HALF_TIMEOUT_MSG, GetAbilityRecordId());
|
||||||
handler->RemoveEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, GetAbilityRecordId());
|
handler->RemoveEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, GetAbilityRecordId());
|
||||||
SetFreezeStrategy(FreezeStrategy::NOTIFY_FREEZE_MGR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbilityRecord::RemoveLoadTimeoutTask()
|
void AbilityRecord::RemoveLoadTimeoutTask()
|
||||||
@ -521,7 +519,6 @@ void AbilityRecord::RemoveLoadTimeoutTask()
|
|||||||
CHECK_POINTER(handler);
|
CHECK_POINTER(handler);
|
||||||
handler->RemoveEvent(AbilityManagerService::LOAD_HALF_TIMEOUT_MSG, GetAbilityRecordId());
|
handler->RemoveEvent(AbilityManagerService::LOAD_HALF_TIMEOUT_MSG, GetAbilityRecordId());
|
||||||
handler->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, GetAbilityRecordId());
|
handler->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, GetAbilityRecordId());
|
||||||
SetFreezeStrategy(FreezeStrategy::NOTIFY_FREEZE_MGR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbilityRecord::PostUIExtensionAbilityTimeoutTask(uint32_t messageId)
|
void AbilityRecord::PostUIExtensionAbilityTimeoutTask(uint32_t messageId)
|
||||||
@ -1271,7 +1268,7 @@ void AbilityRecord::BackgroundAbility(const Closure &task)
|
|||||||
|
|
||||||
if (abilityInfo_.type == AppExecFwk::AbilityType::PAGE) {
|
if (abilityInfo_.type == AppExecFwk::AbilityType::PAGE) {
|
||||||
std::string methodName = "BackgroundAbility";
|
std::string methodName = "BackgroundAbility";
|
||||||
g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::BACKGROUND, methodName);
|
g_addLifecycleEventTask(token_, methodName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "data_ability_operation.h"
|
#include "data_ability_operation.h"
|
||||||
#include "data_ability_predicates.h"
|
#include "data_ability_predicates.h"
|
||||||
#include "data_ability_result.h"
|
#include "data_ability_result.h"
|
||||||
|
#include "error_msg_util.h"
|
||||||
#include "hilog_tag_wrapper.h"
|
#include "hilog_tag_wrapper.h"
|
||||||
#include "hitrace_meter.h"
|
#include "hitrace_meter.h"
|
||||||
#include "ishared_result_set.h"
|
#include "ishared_result_set.h"
|
||||||
@ -52,14 +53,18 @@ bool AbilitySchedulerProxy::ScheduleAbilityTransaction(const Want &want, const L
|
|||||||
if (!WriteInterfaceToken(data)) {
|
if (!WriteInterfaceToken(data)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
auto msgKey = AbilityRuntime::ErrorMgsUtil::BuildErrorKey(reinterpret_cast<uintptr_t>(this),
|
||||||
|
"ScheduleAbilityTransaction");
|
||||||
if (!data.WriteParcelable(&want)) {
|
if (!data.WriteParcelable(&want)) {
|
||||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write want failed");
|
TAG_LOGE(AAFwkTag::ABILITYMGR, "write want failed");
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write want failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
data.WriteParcelable(&stateInfo);
|
data.WriteParcelable(&stateInfo);
|
||||||
if (sessionInfo) {
|
if (sessionInfo) {
|
||||||
if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
|
if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
|
||||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write sessionInfo failed");
|
TAG_LOGE(AAFwkTag::ABILITYMGR, "write sessionInfo failed");
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey, "write sessionInfo failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -70,6 +75,8 @@ bool AbilitySchedulerProxy::ScheduleAbilityTransaction(const Want &want, const L
|
|||||||
int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_TRANSACTION, data, reply, option);
|
int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITY_TRANSACTION, data, reply, option);
|
||||||
if (err != NO_ERROR) {
|
if (err != NO_ERROR) {
|
||||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err);
|
TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err);
|
||||||
|
AbilityRuntime::ErrorMgsUtil::GetInstance().UpdateErrorMsg(msgKey,
|
||||||
|
std::string("ScheduleAbilityTransaction ipc error " + std::to_string(err)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int64_t cost = std::chrono::duration_cast<std::chrono::microseconds>(
|
int64_t cost = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2024 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
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "app_exception_handler.h"
|
|
||||||
|
|
||||||
#include "ability_record.h"
|
|
||||||
#include "app_exception_callback_stub.h"
|
|
||||||
#include "app_mgr_util.h"
|
|
||||||
#include "freeze_util.h"
|
|
||||||
#include "hilog_tag_wrapper.h"
|
|
||||||
|
|
||||||
namespace OHOS {
|
|
||||||
using AppExecFwk::LifecycleException;
|
|
||||||
using AbilityRuntime::FreezeUtil;
|
|
||||||
namespace AAFwk {
|
|
||||||
namespace {
|
|
||||||
class AppExceptionCallback : public AppExecFwk::AppExceptionCallbackStub {
|
|
||||||
/**
|
|
||||||
* Notify abilityManager lifecycle exception.
|
|
||||||
*
|
|
||||||
* @param type lifecycle failed type
|
|
||||||
* @param token associated ability
|
|
||||||
*/
|
|
||||||
void OnLifecycleException(LifecycleException type, sptr<IRemoteObject> token) override
|
|
||||||
{
|
|
||||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
|
||||||
if (abilityRecord == nullptr) {
|
|
||||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "abilityRecord null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "lifecycle exception: %{public}s, %{public}d",
|
|
||||||
abilityRecord->GetURI().c_str(), type);
|
|
||||||
abilityRecord->SetFreezeStrategy(FreezeStrategy::NOTIFY_FREEZE_MGR);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
AppExceptionHandler &AppExceptionHandler::GetInstance()
|
|
||||||
{
|
|
||||||
static AppExceptionHandler appExceptionHandler;
|
|
||||||
return appExceptionHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionHandler::RegisterAppExceptionCallback()
|
|
||||||
{
|
|
||||||
auto appMgr = AppMgrUtil::GetAppMgr();
|
|
||||||
if (appMgr == nullptr) {
|
|
||||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "AppMgrUtil::GetAppMgr failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto service = appMgr->GetAmsMgr();
|
|
||||||
if (service == nullptr) {
|
|
||||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "GetAmsMgr failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto callback = sptr<AppExceptionCallback>(new AppExceptionCallback());
|
|
||||||
service->SetAppExceptionCallback(callback->AsObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppExceptionHandler::AbilityForegroundFailed(sptr<IRemoteObject> token, const std::string &msg)
|
|
||||||
{
|
|
||||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
|
||||||
if (abilityRecord == nullptr) {
|
|
||||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "abilityRecord null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FreezeUtil::LifecycleFlow flow{token, FreezeUtil::TimeoutState::FOREGROUND};
|
|
||||||
FreezeUtil::GetInstance().AppendLifecycleEvent(flow, std::string("AbilityForegroundFailed: " + msg));
|
|
||||||
|
|
||||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "AbilityForegroundFailed: %{public}s", abilityRecord->GetURI().c_str());
|
|
||||||
abilityRecord->SetFreezeStrategy(FreezeStrategy::NOTIFY_FREEZE_MGR);
|
|
||||||
}
|
|
||||||
} // namespace AAFwk
|
|
||||||
} // namespace OHOS
|
|
@ -89,10 +89,9 @@ FreezeUtil::TimeoutState MsgId2State(uint32_t msgId)
|
|||||||
return FreezeUtil::TimeoutState::UNKNOWN;
|
return FreezeUtil::TimeoutState::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto g_deleteLifecycleEventTask = [](const sptr<Token> &token, FreezeUtil::TimeoutState state) {
|
auto g_deleteLifecycleEventTask = [](const sptr<Token> &token) {
|
||||||
CHECK_POINTER_LOG(token, "token is nullptr.");
|
CHECK_POINTER_LOG(token, "token is nullptr.");
|
||||||
FreezeUtil::LifecycleFlow flow = { token->AsObject(), state };
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token->AsObject());
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -1015,8 +1014,7 @@ int MissionListManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
|
|||||||
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||||
abilityRecord->RemoveLoadTimeoutTask();
|
abilityRecord->RemoveLoadTimeoutTask();
|
||||||
abilityRecord->SetLoading(false);
|
abilityRecord->SetLoading(false);
|
||||||
FreezeUtil::LifecycleFlow flow = { token, FreezeUtil::TimeoutState::LOAD };
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token);
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
|
||||||
|
|
||||||
abilityRecord->SetScheduler(scheduler);
|
abilityRecord->SetScheduler(scheduler);
|
||||||
|
|
||||||
@ -1256,7 +1254,7 @@ int MissionListManager::DispatchForeground(const std::shared_ptr<AbilityRecord>
|
|||||||
auto eventHandler = AbilityManagerService::GetPubInstance()->GetEventHandler();
|
auto eventHandler = AbilityManagerService::GetPubInstance()->GetEventHandler();
|
||||||
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||||
abilityRecord->RemoveForegroundTimeoutTask();
|
abilityRecord->RemoveForegroundTimeoutTask();
|
||||||
g_deleteLifecycleEventTask(abilityRecord->GetToken(), FreezeUtil::TimeoutState::FOREGROUND);
|
g_deleteLifecycleEventTask(abilityRecord->GetToken());
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
||||||
auto self(weak_from_this());
|
auto self(weak_from_this());
|
||||||
auto taskHandler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
|
auto taskHandler = AbilityManagerService::GetPubInstance()->GetTaskHandler();
|
||||||
@ -1394,7 +1392,7 @@ int MissionListManager::DispatchBackground(const std::shared_ptr<AbilityRecord>
|
|||||||
|
|
||||||
// remove background timeout task.
|
// remove background timeout task.
|
||||||
handler->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
handler->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||||
g_deleteLifecycleEventTask(abilityRecord->GetToken(), FreezeUtil::TimeoutState::BACKGROUND);
|
g_deleteLifecycleEventTask(abilityRecord->GetToken());
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
||||||
auto self(shared_from_this());
|
auto self(shared_from_this());
|
||||||
auto task = [self, abilityRecord]() { self->CompleteBackground(abilityRecord); };
|
auto task = [self, abilityRecord]() { self->CompleteBackground(abilityRecord); };
|
||||||
@ -2249,20 +2247,17 @@ void MissionListManager::PrintTimeOutLog(const std::shared_ptr<AbilityRecord> &a
|
|||||||
flow.token = ability->GetToken()->AsObject();
|
flow.token = ability->GetToken()->AsObject();
|
||||||
flow.state = state;
|
flow.state = state;
|
||||||
}
|
}
|
||||||
info.msg = msgContent + "\nserver:\n" + FreezeUtil::GetInstance().GetLifecycleEvent(flow)
|
info.msg = msgContent + "\nserver actions for ability:\n" +
|
||||||
+ "\nserver app:\n" + FreezeUtil::GetInstance().GetAppLifecycleEvent(processInfo.pid_);
|
FreezeUtil::GetInstance().GetLifecycleEvent(flow.token) +
|
||||||
|
"\nserver actions for app:\n" + FreezeUtil::GetInstance().GetAppLifecycleEvent(processInfo.pid_);
|
||||||
if (!isHalf) {
|
if (!isHalf) {
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow.token);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(ability->GetPid());
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(ability->GetPid());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info.msg = msgContent;
|
info.msg = msgContent;
|
||||||
}
|
}
|
||||||
if (ability->GetFreezeStrategy() == FreezeStrategy::NOTIFY_FREEZE_MGR) {
|
AppExecFwk::AppfreezeManager::GetInstance()->LifecycleTimeoutHandle(info, flow);
|
||||||
AppExecFwk::AppfreezeManager::GetInstance()->LifecycleTimeoutHandle(info, flow);
|
|
||||||
} else {
|
|
||||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "%{public}s", info.msg.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MissionListManager::GetContentAndTypeId(uint32_t msgId, std::string &msgContent, int &typeId) const
|
bool MissionListManager::GetContentAndTypeId(uint32_t msgId, std::string &msgContent, int &typeId) const
|
||||||
|
@ -68,10 +68,9 @@ FreezeUtil::TimeoutState MsgId2State(uint32_t msgId)
|
|||||||
return FreezeUtil::TimeoutState::UNKNOWN;
|
return FreezeUtil::TimeoutState::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto g_deleteLifecycleEventTask = [](const sptr<Token> &token, FreezeUtil::TimeoutState state) {
|
auto g_deleteLifecycleEventTask = [](const sptr<Token> &token) {
|
||||||
CHECK_POINTER_LOG(token, "token is nullptr.");
|
CHECK_POINTER_LOG(token, "token is nullptr.");
|
||||||
FreezeUtil::LifecycleFlow flow = { token->AsObject(), state };
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token->AsObject());
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,8 +293,7 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr<IAbilityScheduler>
|
|||||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||||
abilityRecord->RemoveLoadTimeoutTask();
|
abilityRecord->RemoveLoadTimeoutTask();
|
||||||
abilityRecord->SetLoading(false);
|
abilityRecord->SetLoading(false);
|
||||||
FreezeUtil::LifecycleFlow flow = {token, FreezeUtil::TimeoutState::LOAD};
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token);
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
|
||||||
|
|
||||||
abilityRecord->SetScheduler(scheduler);
|
abilityRecord->SetScheduler(scheduler);
|
||||||
if (DoProcessAttachment(abilityRecord) != ERR_OK) {
|
if (DoProcessAttachment(abilityRecord) != ERR_OK) {
|
||||||
@ -551,7 +549,7 @@ int UIAbilityLifecycleManager::DispatchForeground(const std::shared_ptr<AbilityR
|
|||||||
|
|
||||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "ForegroundLifecycle: end.");
|
TAG_LOGD(AAFwkTag::ABILITYMGR, "ForegroundLifecycle: end.");
|
||||||
abilityRecord->RemoveForegroundTimeoutTask();
|
abilityRecord->RemoveForegroundTimeoutTask();
|
||||||
g_deleteLifecycleEventTask(abilityRecord->GetToken(), FreezeUtil::TimeoutState::FOREGROUND);
|
g_deleteLifecycleEventTask(abilityRecord->GetToken());
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
||||||
auto self(weak_from_this());
|
auto self(weak_from_this());
|
||||||
if (success) {
|
if (success) {
|
||||||
@ -602,7 +600,7 @@ int UIAbilityLifecycleManager::DispatchBackground(const std::shared_ptr<AbilityR
|
|||||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "end.");
|
TAG_LOGD(AAFwkTag::ABILITYMGR, "end.");
|
||||||
// remove background timeout task.
|
// remove background timeout task.
|
||||||
handler->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
handler->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||||
g_deleteLifecycleEventTask(abilityRecord->GetToken(), FreezeUtil::TimeoutState::BACKGROUND);
|
g_deleteLifecycleEventTask(abilityRecord->GetToken());
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(abilityRecord->GetPid());
|
||||||
auto self(shared_from_this());
|
auto self(shared_from_this());
|
||||||
auto task = [self, abilityRecord]() { self->CompleteBackground(abilityRecord); };
|
auto task = [self, abilityRecord]() { self->CompleteBackground(abilityRecord); };
|
||||||
@ -1214,20 +1212,17 @@ void UIAbilityLifecycleManager::PrintTimeOutLog(std::shared_ptr<AbilityRecord> a
|
|||||||
flow.token = ability->GetToken()->AsObject();
|
flow.token = ability->GetToken()->AsObject();
|
||||||
flow.state = state;
|
flow.state = state;
|
||||||
}
|
}
|
||||||
info.msg = msgContent + "\nserver:\n" + FreezeUtil::GetInstance().GetLifecycleEvent(flow)
|
info.msg = msgContent + "\nserver actions for ability:\n" +
|
||||||
+ "\nserver app:\n" + FreezeUtil::GetInstance().GetAppLifecycleEvent(processInfo.pid_);
|
FreezeUtil::GetInstance().GetLifecycleEvent(flow.token)
|
||||||
|
+ "\nserver actions for app:\n" + FreezeUtil::GetInstance().GetAppLifecycleEvent(processInfo.pid_);
|
||||||
if (!isHalf) {
|
if (!isHalf) {
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow.token);
|
||||||
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(processInfo.pid_);
|
FreezeUtil::GetInstance().DeleteAppLifecycleEvent(processInfo.pid_);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
info.msg = msgContent;
|
info.msg = msgContent;
|
||||||
}
|
}
|
||||||
if (ability->GetFreezeStrategy() == FreezeStrategy::NOTIFY_FREEZE_MGR) {
|
AppExecFwk::AppfreezeManager::GetInstance()->LifecycleTimeoutHandle(info, flow);
|
||||||
AppExecFwk::AppfreezeManager::GetInstance()->LifecycleTimeoutHandle(info, flow);
|
|
||||||
} else {
|
|
||||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "%{public}s", info.msg.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIAbilityLifecycleManager::GetContentAndTypeId(uint32_t msgId, std::string &msgContent, int &typeId) const
|
bool UIAbilityLifecycleManager::GetContentAndTypeId(uint32_t msgId, std::string &msgContent, int &typeId) const
|
||||||
|
@ -438,8 +438,6 @@ public:
|
|||||||
|
|
||||||
virtual bool IsCallerKilling(const std::string& callerKey) override;
|
virtual bool IsCallerKilling(const std::string& callerKey) override;
|
||||||
|
|
||||||
virtual void SetAppExceptionCallback(sptr<IRemoteObject> callback) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Judge whether the application service is ready.
|
* @brief Judge whether the application service is ready.
|
||||||
|
@ -938,6 +938,7 @@ public:
|
|||||||
bool GetIsGPU();
|
bool GetIsGPU();
|
||||||
void SetGPUPid(pid_t gpuPid);
|
void SetGPUPid(pid_t gpuPid);
|
||||||
pid_t GetGPUPid();
|
pid_t GetGPUPid();
|
||||||
|
pid_t GetPid();
|
||||||
|
|
||||||
inline void SetStrictMode(bool strictMode)
|
inline void SetStrictMode(bool strictMode)
|
||||||
{
|
{
|
||||||
@ -1022,9 +1023,9 @@ public:
|
|||||||
void AddAppLifecycleEvent(const std::string &msg);
|
void AddAppLifecycleEvent(const std::string &msg);
|
||||||
|
|
||||||
void SetNWebPreload(const bool isAllowedNWebPreload);
|
void SetNWebPreload(const bool isAllowedNWebPreload);
|
||||||
|
|
||||||
void SetIsUnSetPermission(bool isUnSetPermission);
|
void SetIsUnSetPermission(bool isUnSetPermission);
|
||||||
|
|
||||||
bool IsUnSetPermission();
|
bool IsUnSetPermission();
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "accesstoken_kit.h"
|
#include "accesstoken_kit.h"
|
||||||
#include "app_death_recipient.h"
|
#include "app_death_recipient.h"
|
||||||
#include "app_exception_manager.h"
|
|
||||||
#include "app_mgr_constants.h"
|
#include "app_mgr_constants.h"
|
||||||
#include "app_utils.h"
|
#include "app_utils.h"
|
||||||
#include "hilog_tag_wrapper.h"
|
#include "hilog_tag_wrapper.h"
|
||||||
@ -769,25 +768,5 @@ bool AmsMgrScheduler::IsCallerKilling(const std::string& callerKey)
|
|||||||
}
|
}
|
||||||
return amsMgrServiceInner_->IsCallerKilling(callerKey);
|
return amsMgrServiceInner_->IsCallerKilling(callerKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmsMgrScheduler::SetAppExceptionCallback(sptr<IRemoteObject> callback)
|
|
||||||
{
|
|
||||||
if (!IsReady()) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
|
||||||
pid_t procPid = getprocpid();
|
|
||||||
if (callingPid != procPid) {
|
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "not allow other process to call");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callback == nullptr) {
|
|
||||||
TAG_LOGW(AAFwkTag::APPMGR, "callback null");
|
|
||||||
}
|
|
||||||
auto exceptionCallback = iface_cast<IAppExceptionCallback>(callback);
|
|
||||||
return AppExceptionManager::GetInstance().SetExceptionCallback(exceptionCallback);
|
|
||||||
}
|
|
||||||
} // namespace AppExecFwk
|
} // namespace AppExecFwk
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -75,9 +75,8 @@ void AppLifeCycleDeal::LaunchAbility(const std::shared_ptr<AbilityRunningRecord>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (abilityInfo->type == AbilityType::PAGE) {
|
if (abilityInfo->type == AbilityType::PAGE) {
|
||||||
FreezeUtil::LifecycleFlow flow = {ability->GetToken(), FreezeUtil::TimeoutState::LOAD};
|
std::string entry = "AppLifeCycleDeal::LaunchAbility";
|
||||||
std::string entry = "AppLifeCycleDeal::LaunchAbility; the LoadAbility lifecycle.";
|
FreezeUtil::GetInstance().AddLifecycleEvent(ability->GetToken(), entry);
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "Launch");
|
TAG_LOGD(AAFwkTag::APPMGR, "Launch");
|
||||||
appThread->ScheduleLaunchAbility(*abilityInfo, ability->GetToken(),
|
appThread->ScheduleLaunchAbility(*abilityInfo, ability->GetToken(),
|
||||||
|
@ -33,8 +33,8 @@ int32_t AppMgrEventUtil::GetCallerPid(const std::shared_ptr<AppRunningRecord> &c
|
|||||||
TAG_LOGW(AAFwkTag::APPMGR, "null priorityObject");
|
TAG_LOGW(AAFwkTag::APPMGR, "null priorityObject");
|
||||||
return IPCSkeleton::GetCallingPid();
|
return IPCSkeleton::GetCallingPid();
|
||||||
}
|
}
|
||||||
|
|
||||||
return callerAppRecord->GetPriorityObject()->GetPid();
|
return callerAppRecord->GetPid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppMgrEventUtil::UpdateStartupType(const std::shared_ptr<AbilityInfo> &abilityInfo, int32_t &abilityType,
|
void AppMgrEventUtil::UpdateStartupType(const std::shared_ptr<AbilityInfo> &abilityInfo, int32_t &abilityType,
|
||||||
@ -125,7 +125,7 @@ bool AppMgrEventUtil::SendProcessStartEvent(const std::shared_ptr<AppRunningReco
|
|||||||
if (!appRecord->GetPriorityObject()) {
|
if (!appRecord->GetPriorityObject()) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
||||||
} else {
|
} else {
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
AAFwk::EventReport::SendProcessStartEvent(AAFwk::EventName::PROCESS_START, eventInfo);
|
AAFwk::EventReport::SendProcessStartEvent(AAFwk::EventName::PROCESS_START, eventInfo);
|
||||||
return true;
|
return true;
|
||||||
@ -165,7 +165,7 @@ bool AppMgrEventUtil::SendProcessStartFailedEvent(std::shared_ptr<AppRunningReco
|
|||||||
if (!appRecord->GetPriorityObject()) {
|
if (!appRecord->GetPriorityObject()) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
||||||
} else {
|
} else {
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
AAFwk::EventReport::SendProcessStartFailedEvent(AAFwk::EventName::PROCESS_START_FAILED, eventInfo);
|
AAFwk::EventReport::SendProcessStartFailedEvent(AAFwk::EventName::PROCESS_START_FAILED, eventInfo);
|
||||||
return true;
|
return true;
|
||||||
@ -213,7 +213,7 @@ bool AppMgrEventUtil::SendChildProcessStartFailedEvent(std::shared_ptr<ChildProc
|
|||||||
}
|
}
|
||||||
eventInfo.time = currentTime;
|
eventInfo.time = currentTime;
|
||||||
eventInfo.callerUid = hostRecord->GetUid();
|
eventInfo.callerUid = hostRecord->GetUid();
|
||||||
eventInfo.callerPid = hostRecord->GetPriorityObject() != nullptr ? hostRecord->GetPriorityObject()->GetPid() : -1;
|
eventInfo.callerPid = hostRecord->GetPriorityObject() != nullptr ? hostRecord->GetPid() : -1;
|
||||||
eventInfo.callerBundleName = hostRecord->GetBundleName();
|
eventInfo.callerBundleName = hostRecord->GetBundleName();
|
||||||
eventInfo.callerProcessName = hostRecord->GetProcessName();
|
eventInfo.callerProcessName = hostRecord->GetProcessName();
|
||||||
eventInfo.bundleName = hostRecord->GetBundleName();
|
eventInfo.bundleName = hostRecord->GetBundleName();
|
||||||
@ -245,7 +245,7 @@ bool AppMgrEventUtil::SendRenderProcessStartFailedEvent(std::shared_ptr<RenderRe
|
|||||||
}
|
}
|
||||||
eventInfo.time = currentTime;
|
eventInfo.time = currentTime;
|
||||||
eventInfo.callerUid = hostRecord->GetUid();
|
eventInfo.callerUid = hostRecord->GetUid();
|
||||||
eventInfo.callerPid = hostRecord->GetPriorityObject() != nullptr ? hostRecord->GetPriorityObject()->GetPid() : -1;
|
eventInfo.callerPid = hostRecord->GetPriorityObject() != nullptr ? hostRecord->GetPid() : -1;
|
||||||
eventInfo.callerBundleName = hostRecord->GetBundleName();
|
eventInfo.callerBundleName = hostRecord->GetBundleName();
|
||||||
eventInfo.callerProcessName = hostRecord->GetProcessName();
|
eventInfo.callerProcessName = hostRecord->GetProcessName();
|
||||||
eventInfo.bundleName = hostRecord->GetBundleName();
|
eventInfo.bundleName = hostRecord->GetBundleName();
|
||||||
|
@ -599,14 +599,14 @@ int32_t AppMgrServiceInner::ProcessKia(bool isKia, std::shared_ptr<AppRunningRec
|
|||||||
#ifdef SUPPORT_SCREEN
|
#ifdef SUPPORT_SCREEN
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "Openning KIA file, start setting watermark");
|
TAG_LOGI(AAFwkTag::APPMGR, "Openning KIA file, start setting watermark");
|
||||||
int32_t resultCode = static_cast<int32_t>(WindowManager::GetInstance().SetProcessWatermark(
|
int32_t resultCode = static_cast<int32_t>(WindowManager::GetInstance().SetProcessWatermark(
|
||||||
appRecord->GetPriorityObject()->GetPid(), watermarkBusinessName, isWatermarkEnabled));
|
appRecord->GetPid(), watermarkBusinessName, isWatermarkEnabled));
|
||||||
if (resultCode != ERR_OK) {
|
if (resultCode != ERR_OK) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "setting watermark fails with result code:%{public}d", resultCode);
|
TAG_LOGE(AAFwkTag::APPMGR, "setting watermark fails with result code:%{public}d", resultCode);
|
||||||
return resultCode;
|
return resultCode;
|
||||||
}
|
}
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "setting watermark succeeds, start setting snapshot skip");
|
TAG_LOGI(AAFwkTag::APPMGR, "setting watermark succeeds, start setting snapshot skip");
|
||||||
resultCode = static_cast<int32_t>(WindowManager::GetInstance().SkipSnapshotForAppProcess(
|
resultCode = static_cast<int32_t>(WindowManager::GetInstance().SkipSnapshotForAppProcess(
|
||||||
appRecord->GetPriorityObject()->GetPid(), isWatermarkEnabled));
|
appRecord->GetPid(), isWatermarkEnabled));
|
||||||
if (resultCode != ERR_OK) {
|
if (resultCode != ERR_OK) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "setting snapshot skip fails with result code:%{public}d", resultCode);
|
TAG_LOGE(AAFwkTag::APPMGR, "setting snapshot skip fails with result code:%{public}d", resultCode);
|
||||||
return resultCode;
|
return resultCode;
|
||||||
@ -636,10 +636,8 @@ void AppMgrServiceInner::LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (abilityInfo->type == AbilityType::PAGE) {
|
if (abilityInfo->type == AbilityType::PAGE) {
|
||||||
AbilityRuntime::FreezeUtil::LifecycleFlow flow = {loadParam->token,
|
std::string entry = "AppMgrServiceInner::LoadAbility";
|
||||||
AbilityRuntime::FreezeUtil::TimeoutState::LOAD};
|
AbilityRuntime::FreezeUtil::GetInstance().AddLifecycleEvent(loadParam->token, entry);
|
||||||
std::string entry = "AppMgrServiceInner::LoadAbility; the load lifecycle.";
|
|
||||||
AbilityRuntime::FreezeUtil::GetInstance().AddLifecycleEvent(flow, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!appRunningManager_) {
|
if (!appRunningManager_) {
|
||||||
@ -808,7 +806,7 @@ void AppMgrServiceInner::AddUIExtensionLauncherItem(std::shared_ptr<AAFwk::Want>
|
|||||||
auto hostPid = want->GetIntParam(UIEXTENSION_ROOT_HOST_PID, -1);
|
auto hostPid = want->GetIntParam(UIEXTENSION_ROOT_HOST_PID, -1);
|
||||||
pid_t providerPid = -1;
|
pid_t providerPid = -1;
|
||||||
if (appRecord->GetPriorityObject() != nullptr) {
|
if (appRecord->GetPriorityObject() != nullptr) {
|
||||||
providerPid = appRecord->GetPriorityObject()->GetPid();
|
providerPid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
if (uiExtensionAbilityId == -1 || hostPid == -1 || providerPid == -1) {
|
if (uiExtensionAbilityId == -1 || hostPid == -1 || providerPid == -1) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid want params");
|
TAG_LOGE(AAFwkTag::APPMGR, "invalid want params");
|
||||||
@ -1154,7 +1152,7 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr<IAppSched
|
|||||||
sceneBoardAttachFlag_ = true;
|
sceneBoardAttachFlag_ = true;
|
||||||
SubmitCacheLoadAbilityTask();
|
SubmitCacheLoadAbilityTask();
|
||||||
}
|
}
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
eventInfo.processName = appRecord->GetProcessName();
|
eventInfo.processName = appRecord->GetProcessName();
|
||||||
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_ATTACH, HiSysEventType::BEHAVIOR, eventInfo);
|
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_ATTACH, HiSysEventType::BEHAVIOR, eventInfo);
|
||||||
}
|
}
|
||||||
@ -1352,7 +1350,7 @@ void AppMgrServiceInner::ApplicationBackgrounded(const int32_t recordId)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Prevent forged requests from changing the app's state.
|
// Prevent forged requests from changing the app's state.
|
||||||
appRecord->AddAppLifecycleEvent("ServiceInner::ForeForegrounded");
|
appRecord->AddAppLifecycleEvent("ServiceInner::AppBackgrounded");
|
||||||
if (appRecord->GetApplicationScheduleState() != ApplicationScheduleState::SCHEDULE_BACKGROUNDING) {
|
if (appRecord->GetApplicationScheduleState() != ApplicationScheduleState::SCHEDULE_BACKGROUNDING) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "app is not scheduling to background");
|
TAG_LOGE(AAFwkTag::APPMGR, "app is not scheduling to background");
|
||||||
return;
|
return;
|
||||||
@ -1398,7 +1396,7 @@ AAFwk::EventInfo AppMgrServiceInner::BuildEventInfo(std::shared_ptr<AppRunningRe
|
|||||||
eventInfo.bundleType = static_cast<int32_t>(applicationInfo->bundleType);
|
eventInfo.bundleType = static_cast<int32_t>(applicationInfo->bundleType);
|
||||||
}
|
}
|
||||||
if (appRecord->GetPriorityObject() != nullptr) {
|
if (appRecord->GetPriorityObject() != nullptr) {
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
eventInfo.processName = appRecord->GetProcessName();
|
eventInfo.processName = appRecord->GetProcessName();
|
||||||
eventInfo.processType = static_cast<int32_t>(appRecord->GetProcessType());
|
eventInfo.processType = static_cast<int32_t>(appRecord->GetProcessType());
|
||||||
@ -1441,7 +1439,7 @@ void AppMgrServiceInner::ApplicationTerminated(const int32_t recordId)
|
|||||||
eventInfo.versionCode = applicationInfo->versionCode;
|
eventInfo.versionCode = applicationInfo->versionCode;
|
||||||
}
|
}
|
||||||
ClearAppRunningDataForKeepAlive(appRecord);
|
ClearAppRunningDataForKeepAlive(appRecord);
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
eventInfo.processName = appRecord->GetProcessName();
|
eventInfo.processName = appRecord->GetProcessName();
|
||||||
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_TERMINATE, HiSysEventType::BEHAVIOR, eventInfo);
|
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_TERMINATE, HiSysEventType::BEHAVIOR, eventInfo);
|
||||||
|
|
||||||
@ -1648,7 +1646,7 @@ void AppMgrServiceInner::SendProcessExitEventTask(
|
|||||||
TAG_LOGE(AAFwkTag::APPMGR, "priority object null");
|
TAG_LOGE(AAFwkTag::APPMGR, "priority object null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto pid = appRecord->GetPriorityObject()->GetPid();
|
auto pid = appRecord->GetPid();
|
||||||
auto exitResult = !ProcessExist(pid);
|
auto exitResult = !ProcessExist(pid);
|
||||||
constexpr int32_t EXIT_SUCESS = 0;
|
constexpr int32_t EXIT_SUCESS = 0;
|
||||||
constexpr int32_t EXIT_FAILED = -1;
|
constexpr int32_t EXIT_FAILED = -1;
|
||||||
@ -2398,7 +2396,7 @@ void AppMgrServiceInner::GetRunningProcess(const std::shared_ptr<AppRunningRecor
|
|||||||
RunningProcessInfo &info)
|
RunningProcessInfo &info)
|
||||||
{
|
{
|
||||||
info.processName_ = appRecord->GetProcessName();
|
info.processName_ = appRecord->GetProcessName();
|
||||||
info.pid_ = appRecord->GetPriorityObject()->GetPid();
|
info.pid_ = appRecord->GetPid();
|
||||||
info.uid_ = appRecord->GetUid();
|
info.uid_ = appRecord->GetUid();
|
||||||
info.state_ = static_cast<AppProcessState>(appRecord->GetState());
|
info.state_ = static_cast<AppProcessState>(appRecord->GetState());
|
||||||
info.isContinuousTask = appRecord->IsContinuousTask();
|
info.isContinuousTask = appRecord->IsContinuousTask();
|
||||||
@ -2459,7 +2457,7 @@ void AppMgrServiceInner::GetChildrenProcesses(const std::shared_ptr<AppRunningRe
|
|||||||
if (retCode != ERR_OK) {
|
if (retCode != ERR_OK) {
|
||||||
TAG_LOGW(
|
TAG_LOGW(
|
||||||
AAFwkTag::APPMGR, "GetChildProcessInfo failed. host pid=%{public}d, child pid=%{public}d",
|
AAFwkTag::APPMGR, "GetChildProcessInfo failed. host pid=%{public}d, child pid=%{public}d",
|
||||||
appRecord->GetPriorityObject()->GetPid(), childProcessRecord->GetPid());
|
appRecord->GetPid(), childProcessRecord->GetPid());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
info.emplace_back(childProcessInfo);
|
info.emplace_back(childProcessInfo);
|
||||||
@ -2518,7 +2516,7 @@ int32_t AppMgrServiceInner::KillProcessByPidInner(const pid_t pid, const std::st
|
|||||||
killedProcessMap_.emplace(killTime, appRecord->GetProcessName());
|
killedProcessMap_.emplace(killTime, appRecord->GetProcessName());
|
||||||
}
|
}
|
||||||
DelayedSingleton<CacheProcessManager>::GetInstance()->OnProcessKilled(appRecord);
|
DelayedSingleton<CacheProcessManager>::GetInstance()->OnProcessKilled(appRecord);
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
eventInfo.processName = appRecord->GetProcessName();
|
eventInfo.processName = appRecord->GetProcessName();
|
||||||
std::string newReason = appRecord->GetKillReason().empty() ? killReason : appRecord->GetKillReason();
|
std::string newReason = appRecord->GetKillReason().empty() ? killReason : appRecord->GetKillReason();
|
||||||
bool foreground = appRecord->GetState() == ApplicationState::APP_STATE_FOREGROUND ||
|
bool foreground = appRecord->GetState() == ApplicationState::APP_STATE_FOREGROUND ||
|
||||||
@ -2692,8 +2690,9 @@ void AppMgrServiceInner::UpdateAbilityState(const sptr<IRemoteObject> &token, co
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbilityRuntime::FreezeUtil::LifecycleFlow flow{token, AbilityRuntime::FreezeUtil::TimeoutState::FOREGROUND};
|
if (state == AbilityState::ABILITY_STATE_BACKGROUND) {
|
||||||
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow, "ServiceInner::UpdateAbilityState");
|
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(token, "ServiceInner::UpdateAbilityState");
|
||||||
|
}
|
||||||
auto appRecord = GetAppRunningRecordByAbilityToken(token);
|
auto appRecord = GetAppRunningRecordByAbilityToken(token);
|
||||||
if (!appRecord) {
|
if (!appRecord) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "app unexist");
|
TAG_LOGE(AAFwkTag::APPMGR, "app unexist");
|
||||||
@ -2874,7 +2873,7 @@ void AppMgrServiceInner::KillProcessByAbilityToken(const sptr<IRemoteObject> &to
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
std::list<pid_t> pids;
|
std::list<pid_t> pids;
|
||||||
pids.push_back(pid);
|
pids.push_back(pid);
|
||||||
@ -2972,7 +2971,7 @@ void AppMgrServiceInner::AttachPidToParent(const sptr<IRemoteObject> &token, con
|
|||||||
TAG_LOGE(AAFwkTag::APPMGR, "abilityRecord null");
|
TAG_LOGE(AAFwkTag::APPMGR, "abilityRecord null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto pid = appRecord->GetPriorityObject()->GetPid();
|
auto pid = appRecord->GetPid();
|
||||||
if (pid <= 0) {
|
if (pid <= 0) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid pid");
|
TAG_LOGE(AAFwkTag::APPMGR, "invalid pid");
|
||||||
return;
|
return;
|
||||||
@ -3138,7 +3137,7 @@ void AppMgrServiceInner::OnAppStarted(const std::shared_ptr<AppRunningRecord> &a
|
|||||||
}
|
}
|
||||||
|
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "OnAppStarted begin, bundleName is %{public}s, pid:%{public}d",
|
TAG_LOGD(AAFwkTag::APPMGR, "OnAppStarted begin, bundleName is %{public}s, pid:%{public}d",
|
||||||
appRecord->GetBundleName().c_str(), appRecord->GetPriorityObject()->GetPid());
|
appRecord->GetBundleName().c_str(), appRecord->GetPid());
|
||||||
|
|
||||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppStarted(appRecord);
|
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppStarted(appRecord);
|
||||||
}
|
}
|
||||||
@ -3158,7 +3157,7 @@ void AppMgrServiceInner::OnAppStopped(const std::shared_ptr<AppRunningRecord> &a
|
|||||||
}
|
}
|
||||||
|
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "OnAppStopped begin, bundleName is %{public}s, pid:%{public}d",
|
TAG_LOGD(AAFwkTag::APPMGR, "OnAppStopped begin, bundleName is %{public}s, pid:%{public}d",
|
||||||
appRecord->GetBundleName().c_str(), appRecord->GetPriorityObject()->GetPid());
|
appRecord->GetBundleName().c_str(), appRecord->GetPid());
|
||||||
|
|
||||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppStopped(appRecord);
|
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppStopped(appRecord);
|
||||||
}
|
}
|
||||||
@ -3175,7 +3174,7 @@ AppProcessData AppMgrServiceInner::WrapAppProcessData(const std::shared_ptr<AppR
|
|||||||
processData.appDatas.push_back(data);
|
processData.appDatas.push_back(data);
|
||||||
}
|
}
|
||||||
processData.processName = appRecord->GetProcessName();
|
processData.processName = appRecord->GetProcessName();
|
||||||
processData.pid = appRecord->GetPriorityObject()->GetPid();
|
processData.pid = appRecord->GetPid();
|
||||||
processData.appState = state;
|
processData.appState = state;
|
||||||
processData.isFocused = appRecord->GetFocusFlag();
|
processData.isFocused = appRecord->GetFocusFlag();
|
||||||
processData.appIndex = appRecord->GetAppIndex();
|
processData.appIndex = appRecord->GetAppIndex();
|
||||||
@ -3846,7 +3845,7 @@ void AppMgrServiceInner::SendAppStartupTypeEvent(const std::shared_ptr<AppRunnin
|
|||||||
if (appRecord->GetPriorityObject() == nullptr) {
|
if (appRecord->GetPriorityObject() == nullptr) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "priorityObject null");
|
TAG_LOGE(AAFwkTag::APPMGR, "priorityObject null");
|
||||||
} else {
|
} else {
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
eventInfo.startType = static_cast<int32_t>(startType);
|
eventInfo.startType = static_cast<int32_t>(startType);
|
||||||
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_STARTUP_TYPE, HiSysEventType::BEHAVIOR, eventInfo);
|
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_STARTUP_TYPE, HiSysEventType::BEHAVIOR, eventInfo);
|
||||||
@ -4023,7 +4022,7 @@ void AppMgrServiceInner::TerminateApplication(const std::shared_ptr<AppRunningRe
|
|||||||
appRecord->RemoveAppDeathRecipient();
|
appRecord->RemoveAppDeathRecipient();
|
||||||
appRecord->SetProcessChangeReason(ProcessChangeReason::REASON_APP_TERMINATED_TIMEOUT);
|
appRecord->SetProcessChangeReason(ProcessChangeReason::REASON_APP_TERMINATED_TIMEOUT);
|
||||||
OnAppStateChanged(appRecord, ApplicationState::APP_STATE_TERMINATED, false, false);
|
OnAppStateChanged(appRecord, ApplicationState::APP_STATE_TERMINATED, false, false);
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
int32_t uid = appRecord->GetUid();
|
int32_t uid = appRecord->GetUid();
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
auto timeoutTask = [appRecord, pid, uid, innerService = shared_from_this()]() {
|
auto timeoutTask = [appRecord, pid, uid, innerService = shared_from_this()]() {
|
||||||
@ -4227,7 +4226,7 @@ void AppMgrServiceInner::StartEmptyResidentProcess(
|
|||||||
}
|
}
|
||||||
appRecord->AddModules(appInfo, hapModuleInfos);
|
appRecord->AddModules(appInfo, hapModuleInfos);
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "StartEmptyResidentProcess of pid : [%{public}d], ",
|
TAG_LOGI(AAFwkTag::APPMGR, "StartEmptyResidentProcess of pid : [%{public}d], ",
|
||||||
appRecord->GetPriorityObject()->GetPid());
|
appRecord->GetPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppMgrServiceInner::CheckRemoteClient()
|
bool AppMgrServiceInner::CheckRemoteClient()
|
||||||
@ -4554,7 +4553,7 @@ int AppMgrServiceInner::StartEmptyProcess(const AAFwk::Want &want, const sptr<IR
|
|||||||
appRecord->SetTaskHandler(taskHandler_);
|
appRecord->SetTaskHandler(taskHandler_);
|
||||||
appRecord->SetEventHandler(eventHandler_);
|
appRecord->SetEventHandler(eventHandler_);
|
||||||
appRecord->AddModules(appInfo, info.hapModuleInfos);
|
appRecord->AddModules(appInfo, info.hapModuleInfos);
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "startEmptyProcess pid: [%{public}d]", appRecord->GetPriorityObject()->GetPid());
|
TAG_LOGI(AAFwkTag::APPMGR, "startEmptyProcess pid: [%{public}d]", appRecord->GetPid());
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
@ -4994,7 +4993,7 @@ void AppMgrServiceInner::KillApplicationByRecord(const std::shared_ptr<AppRunnin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pid = appRecord->GetPriorityObject()->GetPid();
|
auto pid = appRecord->GetPid();
|
||||||
appRecord->SetTerminating();
|
appRecord->SetTerminating();
|
||||||
if (!appRunningManager_) {
|
if (!appRunningManager_) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ null");
|
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ null");
|
||||||
@ -5040,7 +5039,7 @@ void AppMgrServiceInner::SendHiSysEvent(int32_t innerEventId, std::shared_ptr<Ap
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string eventName = GetEventName(innerEventId);
|
std::string eventName = GetEventName(innerEventId);
|
||||||
int32_t pid = appRecord->GetPriorityObject()->GetPid();
|
int32_t pid = appRecord->GetPid();
|
||||||
int32_t uid = appRecord->GetUid();
|
int32_t uid = appRecord->GetUid();
|
||||||
std::string packageName = appRecord->GetBundleName();
|
std::string packageName = appRecord->GetBundleName();
|
||||||
std::string processName = appRecord->GetProcessName();
|
std::string processName = appRecord->GetProcessName();
|
||||||
@ -7511,7 +7510,7 @@ void AppMgrServiceInner::KillAttachedChildProcess(const std::shared_ptr<AppRunni
|
|||||||
}
|
}
|
||||||
auto parentAppRecord = appRecord->GetParentAppRecord();
|
auto parentAppRecord = appRecord->GetParentAppRecord();
|
||||||
if (parentAppRecord) {
|
if (parentAppRecord) {
|
||||||
parentAppRecord->RemoveChildAppRecord(appRecord->GetPriorityObject()->GetPid());
|
parentAppRecord->RemoveChildAppRecord(appRecord->GetPid());
|
||||||
}
|
}
|
||||||
std::vector<pid_t> pids;
|
std::vector<pid_t> pids;
|
||||||
std::queue<std::shared_ptr<AppRunningRecord>> queue;
|
std::queue<std::shared_ptr<AppRunningRecord>> queue;
|
||||||
@ -7653,7 +7652,7 @@ void AppMgrServiceInner::SendAppLaunchEvent(const std::shared_ptr<AppRunningReco
|
|||||||
eventInfo.versionCode = applicationInfo->versionCode;
|
eventInfo.versionCode = applicationInfo->versionCode;
|
||||||
}
|
}
|
||||||
if (appRecord->GetPriorityObject() != nullptr) {
|
if (appRecord->GetPriorityObject() != nullptr) {
|
||||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
eventInfo.pid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
eventInfo.processName = appRecord->GetProcessName();
|
eventInfo.processName = appRecord->GetProcessName();
|
||||||
int32_t callerPid = appRecord->GetCallerPid() == -1 ?
|
int32_t callerPid = appRecord->GetCallerPid() == -1 ?
|
||||||
@ -8141,7 +8140,7 @@ void AppMgrServiceInner::OnAppCacheStateChanged(const std::shared_ptr<AppRunning
|
|||||||
}
|
}
|
||||||
|
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "OnAppCacheStateChanged begin, bundleName is %{public}s, pid:%{public}d",
|
TAG_LOGD(AAFwkTag::APPMGR, "OnAppCacheStateChanged begin, bundleName is %{public}s, pid:%{public}d",
|
||||||
appRecord->GetBundleName().c_str(), appRecord->GetPriorityObject()->GetPid());
|
appRecord->GetBundleName().c_str(), appRecord->GetPid());
|
||||||
|
|
||||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppCacheStateChanged(appRecord, state);
|
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnAppCacheStateChanged(appRecord, state);
|
||||||
}
|
}
|
||||||
@ -8263,7 +8262,7 @@ void AppMgrServiceInner::KillProcessDependedOnWeb()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string bundleName = appRecord->GetBundleName();
|
std::string bundleName = appRecord->GetBundleName();
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
if (appRecord->IsKeepAliveApp()) {
|
if (appRecord->IsKeepAliveApp()) {
|
||||||
ExitResidentProcessManager::GetInstance().RecordExitResidentBundleDependedOnWeb(bundleName,
|
ExitResidentProcessManager::GetInstance().RecordExitResidentBundleDependedOnWeb(bundleName,
|
||||||
appRecord->GetUid());
|
appRecord->GetUid());
|
||||||
@ -8375,7 +8374,7 @@ void AppMgrServiceInner::CheckCleanAbilityByUserRequest(const std::shared_ptr<Ap
|
|||||||
|
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
if (appRecord->GetPriorityObject()) {
|
if (appRecord->GetPriorityObject()) {
|
||||||
pid = appRecord->GetPriorityObject()->GetPid();
|
pid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "clean ability set up bg, force kill, pid:%{public}d", pid);
|
TAG_LOGI(AAFwkTag::APPMGR, "clean ability set up bg, force kill, pid:%{public}d", pid);
|
||||||
KillProcessByPid(pid, KILL_REASON_USER_REQUEST);
|
KillProcessByPid(pid, KILL_REASON_USER_REQUEST);
|
||||||
@ -8405,7 +8404,7 @@ void AppMgrServiceInner::GetPidsByAccessTokenId(const uint32_t accessTokenId, st
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (accessTokenId == applicationInfo->accessTokenId) {
|
if (accessTokenId == applicationInfo->accessTokenId) {
|
||||||
pid_t curPid = appRecord->GetPriorityObject()->GetPid();
|
pid_t curPid = appRecord->GetPid();
|
||||||
if (appRecord->GetState() == ApplicationState::APP_STATE_FOREGROUND) {
|
if (appRecord->GetState() == ApplicationState::APP_STATE_FOREGROUND) {
|
||||||
foregroundPid = curPid;
|
foregroundPid = curPid;
|
||||||
continue;
|
continue;
|
||||||
@ -8518,7 +8517,7 @@ int32_t AppMgrServiceInner::GetSupportedProcessCachePids(const std::string &bund
|
|||||||
osAccountMgr->GetOsAccountLocalIdFromUid(appRecord->GetUid(), procUserId) == 0 &&
|
osAccountMgr->GetOsAccountLocalIdFromUid(appRecord->GetUid(), procUserId) == 0 &&
|
||||||
procUserId == callderUserId && cachePrcoMgr->IsAppSupportProcessCache(appRecord) &&
|
procUserId == callderUserId && cachePrcoMgr->IsAppSupportProcessCache(appRecord) &&
|
||||||
appRecord->GetPriorityObject() != nullptr) {
|
appRecord->GetPriorityObject() != nullptr) {
|
||||||
pidList.push_back(appRecord->GetPriorityObject()->GetPid());
|
pidList.push_back(appRecord->GetPid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
|
@ -248,7 +248,7 @@ std::shared_ptr<AppRunningRecord> AppRunningManager::GetAppRunningRecordByPid(co
|
|||||||
{
|
{
|
||||||
std::lock_guard guard(runningRecordMapMutex_);
|
std::lock_guard guard(runningRecordMapMutex_);
|
||||||
auto iter = std::find_if(appRunningRecordMap_.begin(), appRunningRecordMap_.end(), [&pid](const auto &pair) {
|
auto iter = std::find_if(appRunningRecordMap_.begin(), appRunningRecordMap_.end(), [&pid](const auto &pair) {
|
||||||
return pair.second->GetPriorityObject()->GetPid() == pid;
|
return pair.second->GetPid() == pid;
|
||||||
});
|
});
|
||||||
return ((iter == appRunningRecordMap_.end()) ? nullptr : iter->second);
|
return ((iter == appRunningRecordMap_.end()) ? nullptr : iter->second);
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ bool AppRunningManager::ProcessExitByBundleName(
|
|||||||
// Before using this method, consider whether you need.
|
// Before using this method, consider whether you need.
|
||||||
if (appRecord && (!appRecord->IsKeepAliveApp() ||
|
if (appRecord && (!appRecord->IsKeepAliveApp() ||
|
||||||
!ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient())) {
|
!ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient())) {
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
auto appInfoList = appRecord->GetAppInfoList();
|
auto appInfoList = appRecord->GetAppInfoList();
|
||||||
auto isExist = [&bundleName](const std::shared_ptr<ApplicationInfo> &appInfo) {
|
auto isExist = [&bundleName](const std::shared_ptr<ApplicationInfo> &appInfo) {
|
||||||
return appInfo->bundleName == bundleName;
|
return appInfo->bundleName == bundleName;
|
||||||
@ -306,7 +306,7 @@ bool AppRunningManager::GetPidsByUserId(int32_t userId, std::list<pid_t> &pids)
|
|||||||
int32_t id = -1;
|
int32_t id = -1;
|
||||||
if ((DelayedSingleton<OsAccountManagerWrapper>::GetInstance()->
|
if ((DelayedSingleton<OsAccountManagerWrapper>::GetInstance()->
|
||||||
GetOsAccountLocalIdFromUid(appRecord->GetUid(), id) == 0) && (id == userId)) {
|
GetOsAccountLocalIdFromUid(appRecord->GetUid(), id) == 0) && (id == userId)) {
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
pids.push_back(pid);
|
pids.push_back(pid);
|
||||||
appRecord->ScheduleProcessSecurityExit();
|
appRecord->ScheduleProcessSecurityExit();
|
||||||
@ -352,7 +352,7 @@ bool AppRunningManager::ProcessExitByBundleNameAndUid(
|
|||||||
return appInfo->bundleName == bundleName && appInfo->uid == uid;
|
return appInfo->bundleName == bundleName && appInfo->uid == uid;
|
||||||
};
|
};
|
||||||
auto iter = std::find_if(appInfoList.begin(), appInfoList.end(), isExist);
|
auto iter = std::find_if(appInfoList.begin(), appInfoList.end(), isExist);
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
if (iter == appInfoList.end() || pid <= 0) {
|
if (iter == appInfoList.end() || pid <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ bool AppRunningManager::ProcessExitByBundleNameAndAppIndex(const std::string &bu
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (appInfo->bundleName == bundleName && appRecord->GetAppIndex() == appIndex) {
|
if (appInfo->bundleName == bundleName && appRecord->GetAppIndex() == appIndex) {
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
if (pid <= 0) {
|
if (pid <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ bool AppRunningManager::ProcessExitByTokenIdAndInstance(uint32_t accessTokenId,
|
|||||||
if (appRecord->GetPriorityObject() == nullptr) {
|
if (appRecord->GetPriorityObject() == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
if (pid <= 0) {
|
if (pid <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ bool AppRunningManager::GetPidsByBundleNameUserIdAndAppIndex(const std::string &
|
|||||||
appInfo->appIndex == appIndex;
|
appInfo->appIndex == appIndex;
|
||||||
};
|
};
|
||||||
auto iter = std::find_if(appInfoList.begin(), appInfoList.end(), isExist);
|
auto iter = std::find_if(appInfoList.begin(), appInfoList.end(), isExist);
|
||||||
pid_t pid = appRecord->GetPriorityObject()->GetPid();
|
pid_t pid = appRecord->GetPid();
|
||||||
if (iter == appInfoList.end() || pid <= 0) {
|
if (iter == appInfoList.end() || pid <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -523,7 +523,7 @@ std::shared_ptr<AppRunningRecord> AppRunningManager::OnRemoteDied(const wptr<IRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (appRecord != nullptr && appRecord->GetPriorityObject() != nullptr) {
|
if (appRecord != nullptr && appRecord->GetPriorityObject() != nullptr) {
|
||||||
RemoveUIExtensionLauncherItem(appRecord->GetPriorityObject()->GetPid());
|
RemoveUIExtensionLauncherItem(appRecord->GetPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
return appRecord;
|
return appRecord;
|
||||||
@ -552,8 +552,8 @@ void AppRunningManager::RemoveAppRunningRecordById(const int32_t recordId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (appRecord != nullptr && appRecord->GetPriorityObject() != nullptr) {
|
if (appRecord != nullptr && appRecord->GetPriorityObject() != nullptr) {
|
||||||
RemoveUIExtensionLauncherItem(appRecord->GetPriorityObject()->GetPid());
|
RemoveUIExtensionLauncherItem(appRecord->GetPid());
|
||||||
AbilityRuntime::FreezeUtil::GetInstance().DeleteAppLifecycleEvent(appRecord->GetPriorityObject()->GetPid());
|
AbilityRuntime::FreezeUtil::GetInstance().DeleteAppLifecycleEvent(appRecord->GetPid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -782,7 +782,7 @@ void AppRunningManager::NotifyAppPreCache(const std::shared_ptr<AppRunningRecord
|
|||||||
appRecord->GetPriorityObject() == nullptr) {
|
appRecord->GetPriorityObject() == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int32_t pid = appRecord->GetPriorityObject()->GetPid();
|
int32_t pid = appRecord->GetPid();
|
||||||
int32_t userId = appRecord->GetUid() / BASE_USER_RANGE;
|
int32_t userId = appRecord->GetUid() / BASE_USER_RANGE;
|
||||||
auto notifyAppPreCache = [pid, userId, inner = appMgrServiceInner]() {
|
auto notifyAppPreCache = [pid, userId, inner = appMgrServiceInner]() {
|
||||||
if (inner == nullptr) {
|
if (inner == nullptr) {
|
||||||
@ -821,7 +821,7 @@ int32_t AppRunningManager::AssignRunningProcessInfoByAppRecord(
|
|||||||
}
|
}
|
||||||
|
|
||||||
info.processName_ = appRecord->GetProcessName();
|
info.processName_ = appRecord->GetProcessName();
|
||||||
info.pid_ = appRecord->GetPriorityObject()->GetPid();
|
info.pid_ = appRecord->GetPid();
|
||||||
info.uid_ = appRecord->GetUid();
|
info.uid_ = appRecord->GetUid();
|
||||||
info.bundleNames.emplace_back(appRecord->GetBundleName());
|
info.bundleNames.emplace_back(appRecord->GetBundleName());
|
||||||
info.state_ = static_cast<AppExecFwk::AppProcessState>(appRecord->GetState());
|
info.state_ = static_cast<AppExecFwk::AppProcessState>(appRecord->GetState());
|
||||||
@ -877,7 +877,7 @@ void AppRunningManager::GetForegroundApplications(std::vector<AppStateData> &lis
|
|||||||
AppStateData appData;
|
AppStateData appData;
|
||||||
appData.bundleName = appRecord->GetBundleName();
|
appData.bundleName = appRecord->GetBundleName();
|
||||||
appData.uid = appRecord->GetUid();
|
appData.uid = appRecord->GetUid();
|
||||||
appData.pid = appRecord->GetPriorityObject()->GetPid();
|
appData.pid = appRecord->GetPid();
|
||||||
appData.state = static_cast<int32_t>(ApplicationState::APP_STATE_FOREGROUND);
|
appData.state = static_cast<int32_t>(ApplicationState::APP_STATE_FOREGROUND);
|
||||||
auto appInfo = appRecord->GetApplicationInfo();
|
auto appInfo = appRecord->GetApplicationInfo();
|
||||||
appData.accessTokenId = appInfo ? appInfo->accessTokenId : 0;
|
appData.accessTokenId = appInfo ? appInfo->accessTokenId : 0;
|
||||||
@ -1131,7 +1131,7 @@ bool AppRunningManager::GetAppRunningStateByBundleName(const std::string &bundle
|
|||||||
TAG_LOGD(AAFwkTag::APPMGR, "Process of [%{public}s] is running, processName: %{public}s.",
|
TAG_LOGD(AAFwkTag::APPMGR, "Process of [%{public}s] is running, processName: %{public}s.",
|
||||||
bundleName.c_str(), appRecord->GetProcessName().c_str());
|
bundleName.c_str(), appRecord->GetProcessName().c_str());
|
||||||
if (IPCSkeleton::GetCallingUid() == QUICKFIX_UID && appRecord->GetPriorityObject() != nullptr) {
|
if (IPCSkeleton::GetCallingUid() == QUICKFIX_UID && appRecord->GetPriorityObject() != nullptr) {
|
||||||
TAG_LOGI(AAFwkTag::APPMGR, "pid: %{public}d", appRecord->GetPriorityObject()->GetPid());
|
TAG_LOGI(AAFwkTag::APPMGR, "pid: %{public}d", appRecord->GetPid());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1575,7 +1575,7 @@ int AppRunningManager::DumpIpcAllStart(std::string& result)
|
|||||||
for (const auto &item : GetAppRunningRecordMap()) {
|
for (const auto &item : GetAppRunningRecordMap()) {
|
||||||
const auto &appRecord = item.second;
|
const auto &appRecord = item.second;
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "AppRunningManager::DumpIpcAllStart::pid:%{public}d",
|
TAG_LOGD(AAFwkTag::APPMGR, "AppRunningManager::DumpIpcAllStart::pid:%{public}d",
|
||||||
appRecord->GetPriorityObject()->GetPid());
|
appRecord->GetPid());
|
||||||
std::string currentResult;
|
std::string currentResult;
|
||||||
errCode = appRecord->DumpIpcStart(currentResult);
|
errCode = appRecord->DumpIpcStart(currentResult);
|
||||||
result += currentResult + "\n";
|
result += currentResult + "\n";
|
||||||
@ -1593,7 +1593,7 @@ int AppRunningManager::DumpIpcAllStop(std::string& result)
|
|||||||
for (const auto &item : GetAppRunningRecordMap()) {
|
for (const auto &item : GetAppRunningRecordMap()) {
|
||||||
const auto &appRecord = item.second;
|
const auto &appRecord = item.second;
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "AppRunningManager::DumpIpcAllStop::pid:%{public}d",
|
TAG_LOGD(AAFwkTag::APPMGR, "AppRunningManager::DumpIpcAllStop::pid:%{public}d",
|
||||||
appRecord->GetPriorityObject()->GetPid());
|
appRecord->GetPid());
|
||||||
std::string currentResult;
|
std::string currentResult;
|
||||||
errCode = appRecord->DumpIpcStop(currentResult);
|
errCode = appRecord->DumpIpcStop(currentResult);
|
||||||
result += currentResult + "\n";
|
result += currentResult + "\n";
|
||||||
@ -1611,7 +1611,7 @@ int AppRunningManager::DumpIpcAllStat(std::string& result)
|
|||||||
for (const auto &item : GetAppRunningRecordMap()) {
|
for (const auto &item : GetAppRunningRecordMap()) {
|
||||||
const auto &appRecord = item.second;
|
const auto &appRecord = item.second;
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "AppRunningManager::DumpIpcAllStat::pid:%{public}d",
|
TAG_LOGD(AAFwkTag::APPMGR, "AppRunningManager::DumpIpcAllStat::pid:%{public}d",
|
||||||
appRecord->GetPriorityObject()->GetPid());
|
appRecord->GetPid());
|
||||||
std::string currentResult;
|
std::string currentResult;
|
||||||
errCode = appRecord->DumpIpcStat(currentResult);
|
errCode = appRecord->DumpIpcStat(currentResult);
|
||||||
result += currentResult + "\n";
|
result += currentResult + "\n";
|
||||||
@ -1725,7 +1725,7 @@ bool AppRunningManager::HandleUserRequestClean(const sptr<IRemoteObject> &abilit
|
|||||||
|
|
||||||
appRecord->SetUserRequestCleaning();
|
appRecord->SetUserRequestCleaning();
|
||||||
if (appRecord->GetPriorityObject()) {
|
if (appRecord->GetPriorityObject()) {
|
||||||
pid = appRecord->GetPriorityObject()->GetPid();
|
pid = appRecord->GetPid();
|
||||||
}
|
}
|
||||||
uid = appRecord->GetUid();
|
uid = appRecord->GetUid();
|
||||||
return true;
|
return true;
|
||||||
@ -1805,7 +1805,7 @@ bool AppRunningManager::CheckAppRunningRecordIsLast(const std::shared_ptr<AppRun
|
|||||||
auto appIndex = appRecord->GetAppIndex();
|
auto appIndex = appRecord->GetAppIndex();
|
||||||
auto appRecordId = appRecord->GetRecordId();
|
auto appRecordId = appRecord->GetRecordId();
|
||||||
auto userId = appRecord->GetUserId();
|
auto userId = appRecord->GetUserId();
|
||||||
|
|
||||||
for (const auto &item : appRunningRecordMap_) {
|
for (const auto &item : appRunningRecordMap_) {
|
||||||
const auto &itemAppRecord = item.second;
|
const auto &itemAppRecord = item.second;
|
||||||
if (itemAppRecord != nullptr &&
|
if (itemAppRecord != nullptr &&
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ability_window_configuration.h"
|
#include "ability_window_configuration.h"
|
||||||
#include "app_exception_manager.h"
|
|
||||||
#include "app_running_record.h"
|
#include "app_running_record.h"
|
||||||
#include "app_mgr_service_inner.h"
|
#include "app_mgr_service_inner.h"
|
||||||
|
#include "error_msg_util.h"
|
||||||
#include "event_report.h"
|
#include "event_report.h"
|
||||||
#include "exit_resident_process_manager.h"
|
#include "exit_resident_process_manager.h"
|
||||||
#include "freeze_util.h"
|
#include "freeze_util.h"
|
||||||
@ -469,8 +469,10 @@ void AppRunningRecord::LaunchApplication(const Configuration &config)
|
|||||||
TAG_LOGE(AAFwkTag::APPMGR, "null appLifeCycleDeal_");
|
TAG_LOGE(AAFwkTag::APPMGR, "null appLifeCycleDeal_");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!appLifeCycleDeal_->GetApplicationClient()) {
|
auto scheduler = appLifeCycleDeal_->GetApplicationClient();
|
||||||
|
if (!scheduler) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "null appThread");
|
TAG_LOGE(AAFwkTag::APPMGR, "null appThread");
|
||||||
|
AddAppLifecycleEvent("AppRunningRecord::LaunchApplication; null scheduler");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppLaunchData launchData;
|
AppLaunchData launchData;
|
||||||
@ -481,7 +483,7 @@ void AppRunningRecord::LaunchApplication(const Configuration &config)
|
|||||||
launchData.SetApplicationInfo(*(moduleRecords->second));
|
launchData.SetApplicationInfo(*(moduleRecords->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProcessInfo processInfo(processName_, GetPriorityObject()->GetPid());
|
ProcessInfo processInfo(processName_, GetPid());
|
||||||
processInfo.SetProcessType(processType_);
|
processInfo.SetProcessType(processType_);
|
||||||
launchData.SetProcessInfo(processInfo);
|
launchData.SetProcessInfo(processInfo);
|
||||||
launchData.SetRecordId(appRecordId_);
|
launchData.SetRecordId(appRecordId_);
|
||||||
@ -501,6 +503,8 @@ void AppRunningRecord::LaunchApplication(const Configuration &config)
|
|||||||
|
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "%{public}s called,app is %{public}s.", __func__, GetName().c_str());
|
TAG_LOGD(AAFwkTag::APPMGR, "%{public}s called,app is %{public}s.", __func__, GetName().c_str());
|
||||||
AddAppLifecycleEvent("AppRunningRecord::LaunchApplication");
|
AddAppLifecycleEvent("AppRunningRecord::LaunchApplication");
|
||||||
|
AbilityRuntime::ErrorMsgGuard errorMsgGuard(GetPid(), reinterpret_cast<uintptr_t>(scheduler.GetRefPtr()),
|
||||||
|
"LaunchApplication");
|
||||||
appLifeCycleDeal_->LaunchApplication(launchData, config);
|
appLifeCycleDeal_->LaunchApplication(launchData, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,6 +671,13 @@ bool AppRunningRecord::ScheduleForegroundRunning()
|
|||||||
SetApplicationScheduleState(ApplicationScheduleState::SCHEDULE_FOREGROUNDING);
|
SetApplicationScheduleState(ApplicationScheduleState::SCHEDULE_FOREGROUNDING);
|
||||||
if (appLifeCycleDeal_) {
|
if (appLifeCycleDeal_) {
|
||||||
AddAppLifecycleEvent("AppRunningRecord::ScheduleForegroundRunning");
|
AddAppLifecycleEvent("AppRunningRecord::ScheduleForegroundRunning");
|
||||||
|
auto scheduler = appLifeCycleDeal_->GetApplicationClient();
|
||||||
|
if (!scheduler) {
|
||||||
|
AddAppLifecycleEvent("AppRunningRecord::ScheduleForegroundRunning; null scheduler");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
AbilityRuntime::ErrorMsgGuard errorMsgGuard(GetPid(), reinterpret_cast<uintptr_t>(scheduler.GetRefPtr()),
|
||||||
|
"ScheduleForegroundRunning");
|
||||||
return appLifeCycleDeal_->ScheduleForegroundRunning();
|
return appLifeCycleDeal_->ScheduleForegroundRunning();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -845,7 +856,7 @@ void AppRunningRecord::StateChangedNotifyObserver(const std::shared_ptr<AbilityR
|
|||||||
abilityStateData.bundleName = abilityInfo->applicationInfo.bundleName;
|
abilityStateData.bundleName = abilityInfo->applicationInfo.bundleName;
|
||||||
abilityStateData.moduleName = abilityInfo->moduleName;
|
abilityStateData.moduleName = abilityInfo->moduleName;
|
||||||
abilityStateData.abilityName = ability->GetName();
|
abilityStateData.abilityName = ability->GetName();
|
||||||
abilityStateData.pid = GetPriorityObject()->GetPid();
|
abilityStateData.pid = GetPid();
|
||||||
abilityStateData.abilityState = state;
|
abilityStateData.abilityState = state;
|
||||||
abilityStateData.uid = abilityInfo->applicationInfo.uid;
|
abilityStateData.uid = abilityInfo->applicationInfo.uid;
|
||||||
abilityStateData.token = ability->GetToken();
|
abilityStateData.token = ability->GetToken();
|
||||||
@ -1020,10 +1031,9 @@ void AppRunningRecord::AbilityForeground(const std::shared_ptr<AbilityRunningRec
|
|||||||
SetApplicationPendingState(ApplicationPendingState::FOREGROUNDING);
|
SetApplicationPendingState(ApplicationPendingState::FOREGROUNDING);
|
||||||
if (pendingState == ApplicationPendingState::READY) {
|
if (pendingState == ApplicationPendingState::READY) {
|
||||||
if (!ScheduleForegroundRunning()) {
|
if (!ScheduleForegroundRunning()) {
|
||||||
AppExceptionManager::GetInstance().ForegroundAppFailed(ability->GetToken(), "schedule failed");
|
AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(ability->GetToken(),
|
||||||
|
"ScheduleForegroundRunning fail");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
AppExceptionManager::GetInstance().ForegroundAppWait(ability->GetToken(), "pendingState not ready");
|
|
||||||
}
|
}
|
||||||
foregroundingAbilityTokens_.insert(ability->GetToken());
|
foregroundingAbilityTokens_.insert(ability->GetToken());
|
||||||
TAG_LOGD(AAFwkTag::APPMGR, "foregroundingAbility size: %{public}d",
|
TAG_LOGD(AAFwkTag::APPMGR, "foregroundingAbility size: %{public}d",
|
||||||
@ -1325,7 +1335,7 @@ void AppRunningRecord::SendAppStartupTypeEvent(const std::shared_ptr<AbilityRunn
|
|||||||
if (GetPriorityObject() == nullptr) {
|
if (GetPriorityObject() == nullptr) {
|
||||||
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
||||||
} else {
|
} else {
|
||||||
eventInfo.pid = GetPriorityObject()->GetPid();
|
eventInfo.pid = GetPid();
|
||||||
}
|
}
|
||||||
eventInfo.startType = static_cast<int32_t>(startType);
|
eventInfo.startType = static_cast<int32_t>(startType);
|
||||||
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_STARTUP_TYPE, HiSysEventType::BEHAVIOR, eventInfo);
|
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_STARTUP_TYPE, HiSysEventType::BEHAVIOR, eventInfo);
|
||||||
@ -2005,7 +2015,7 @@ void AppRunningRecord::ChangeWindowVisibility(const sptr<OHOS::Rosen::WindowVisi
|
|||||||
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
TAG_LOGE(AAFwkTag::APPMGR, "null priorityObject");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (info->pid_ != GetPriorityObject()->GetPid()) {
|
if (info->pid_ != GetPid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2039,7 +2049,7 @@ void AppRunningRecord::OnWindowVisibilityChanged(
|
|||||||
TAG_LOGE(AAFwkTag::APPMGR, "null info");
|
TAG_LOGE(AAFwkTag::APPMGR, "null info");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (info->pid_ != GetPriorityObject()->GetPid()) {
|
if (info->pid_ != GetPid()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::lock_guard windowIdsLock(windowIdsLock_);
|
std::lock_guard windowIdsLock(windowIdsLock_);
|
||||||
@ -2487,6 +2497,15 @@ pid_t AppRunningRecord::GetGPUPid()
|
|||||||
return gpuPid_;
|
return gpuPid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid_t AppRunningRecord::GetPid()
|
||||||
|
{
|
||||||
|
auto prioObj = GetPriorityObject();
|
||||||
|
if (prioObj) {
|
||||||
|
return prioObj->GetPid();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void AppRunningRecord::SetAttachedToStatusBar(bool isAttached)
|
void AppRunningRecord::SetAttachedToStatusBar(bool isAttached)
|
||||||
{
|
{
|
||||||
isAttachedToStatusBar = isAttached;
|
isAttachedToStatusBar = isAttached;
|
||||||
|
@ -816,7 +816,7 @@ ProcessData AppStateObserverManager::WrapProcessData(const std::shared_ptr<AppRu
|
|||||||
{
|
{
|
||||||
ProcessData processData;
|
ProcessData processData;
|
||||||
processData.bundleName = appRecord->GetBundleName();
|
processData.bundleName = appRecord->GetBundleName();
|
||||||
processData.pid = appRecord->GetPriorityObject()->GetPid();
|
processData.pid = appRecord->GetPid();
|
||||||
processData.uid = appRecord->GetUid();
|
processData.uid = appRecord->GetUid();
|
||||||
auto applicationInfo = appRecord->GetApplicationInfo();
|
auto applicationInfo = appRecord->GetApplicationInfo();
|
||||||
if (applicationInfo) {
|
if (applicationInfo) {
|
||||||
@ -1025,7 +1025,7 @@ AppStateData AppStateObserverManager::WrapAppStateData(const std::shared_ptr<App
|
|||||||
const ApplicationState state)
|
const ApplicationState state)
|
||||||
{
|
{
|
||||||
AppStateData appStateData;
|
AppStateData appStateData;
|
||||||
appStateData.pid = appRecord->GetPriorityObject()->GetPid();
|
appStateData.pid = appRecord->GetPid();
|
||||||
appStateData.bundleName = appRecord->GetBundleName();
|
appStateData.bundleName = appRecord->GetBundleName();
|
||||||
appStateData.state = static_cast<int32_t>(state);
|
appStateData.state = static_cast<int32_t>(state);
|
||||||
appStateData.uid = appRecord->GetUid();
|
appStateData.uid = appRecord->GetUid();
|
||||||
|
@ -144,7 +144,7 @@ bool CacheProcessManager::CheckAndCacheProcess(const std::shared_ptr<AppRunningR
|
|||||||
};
|
};
|
||||||
std::string taskName = "DELAY_CACHED_STATE_NOTIFY";
|
std::string taskName = "DELAY_CACHED_STATE_NOTIFY";
|
||||||
if (appRecord->GetPriorityObject()) {
|
if (appRecord->GetPriorityObject()) {
|
||||||
taskName += std::to_string(appRecord->GetPriorityObject()->GetPid());
|
taskName += std::to_string(appRecord->GetPid());
|
||||||
}
|
}
|
||||||
auto res = appRecord->CancelTask(taskName);
|
auto res = appRecord->CancelTask(taskName);
|
||||||
if (res) {
|
if (res) {
|
||||||
@ -301,7 +301,7 @@ void CacheProcessManager::CheckAndSetProcessCacheEnable(const std::shared_ptr<Ap
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool forceKillProcess =
|
bool forceKillProcess =
|
||||||
AAFwk::ResSchedUtil::GetInstance().CheckShouldForceKillProcess(appRecord->GetPriorityObject()->GetPid());
|
AAFwk::ResSchedUtil::GetInstance().CheckShouldForceKillProcess(appRecord->GetPid());
|
||||||
if (forceKillProcess) {
|
if (forceKillProcess) {
|
||||||
appRecord->SetProcessCacheBlocked(true);
|
appRecord->SetProcessCacheBlocked(true);
|
||||||
return;
|
return;
|
||||||
|
@ -49,7 +49,6 @@ sptr<Token> GetFuzzAbilityToken()
|
|||||||
|
|
||||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow;
|
|
||||||
std::string JsonStr(data, size);
|
std::string JsonStr(data, size);
|
||||||
FreezeUtil::GetInstance();
|
FreezeUtil::GetInstance();
|
||||||
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
sptr<IRemoteObject> token = GetFuzzAbilityToken();
|
||||||
@ -57,11 +56,9 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
|||||||
std::cout << "Get ability token failed." << std::endl;
|
std::cout << "Get ability token failed." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, JsonStr);
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, JsonStr);
|
||||||
FreezeUtil::GetInstance().GetLifecycleEvent(flow);
|
FreezeUtil::GetInstance().GetLifecycleEvent(token);
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(token);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token);
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEventInner(flow);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,15 +51,14 @@ void FreezeUtilTest::TearDown()
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(FreezeUtilTest, FreezeUtilTest_001, TestSize.Level1)
|
HWTEST_F(FreezeUtilTest, FreezeUtilTest_001, TestSize.Level1)
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow;
|
sptr<IPCObjectStub> token(new IPCObjectStub(u"testStub"));
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "");
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token), "");
|
||||||
flow.state = FreezeUtil::TimeoutState::FOREGROUND;
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, "firstEntry");
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, "firstEntry");
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token),
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow),
|
|
||||||
TimeUtil::DefaultCurrentTimeStr() + "; " + "firstEntry");
|
TimeUtil::DefaultCurrentTimeStr() + "; " + "firstEntry");
|
||||||
|
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, "secondEntry");
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, "secondEntry");
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), TimeUtil::DefaultCurrentTimeStr() + "; " +
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token), TimeUtil::DefaultCurrentTimeStr() + "; " +
|
||||||
"firstEntry\n" + TimeUtil::DefaultCurrentTimeStr() + "; " + "secondEntry");
|
"firstEntry\n" + TimeUtil::DefaultCurrentTimeStr() + "; " + "secondEntry");
|
||||||
TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_001 is end");
|
TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_001 is end");
|
||||||
}
|
}
|
||||||
@ -71,13 +70,12 @@ HWTEST_F(FreezeUtilTest, FreezeUtilTest_001, TestSize.Level1)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(FreezeUtilTest, FreezeUtilTest_002, TestSize.Level1)
|
HWTEST_F(FreezeUtilTest, FreezeUtilTest_002, TestSize.Level1)
|
||||||
{
|
{
|
||||||
FreezeUtil::LifecycleFlow flow;
|
sptr<IPCObjectStub> token(new IPCObjectStub(u"testStub"));
|
||||||
flow.state = FreezeUtil::TimeoutState::LOAD;
|
FreezeUtil::GetInstance().AddLifecycleEvent(token, "testDeleteEntry");
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(flow, "testDeleteEntry");
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token),
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow),
|
|
||||||
TimeUtil::DefaultCurrentTimeStr() + "; " + "testDeleteEntry");
|
TimeUtil::DefaultCurrentTimeStr() + "; " + "testDeleteEntry");
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(flow);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token);
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "");
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token), "");
|
||||||
TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_002 is end");
|
TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_002 is end");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,20 +86,21 @@ HWTEST_F(FreezeUtilTest, FreezeUtilTest_002, TestSize.Level1)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(FreezeUtilTest, FreezeUtilTest_003, TestSize.Level1)
|
HWTEST_F(FreezeUtilTest, FreezeUtilTest_003, TestSize.Level1)
|
||||||
{
|
{
|
||||||
sptr<IRemoteObject> token_(new IPCObjectStub());
|
sptr<IRemoteObject> token1(new IPCObjectStub());
|
||||||
FreezeUtil::LifecycleFlow foregroundFlow = { token_, FreezeUtil::TimeoutState::FOREGROUND };
|
FreezeUtil::GetInstance().AddLifecycleEvent(token1, "testDeleteLifecyleEventForground");
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(foregroundFlow, "testDeleteLifecyleEventForground");
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token1),
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(foregroundFlow),
|
|
||||||
TimeUtil::DefaultCurrentTimeStr() + "; " + "testDeleteLifecyleEventForground");
|
TimeUtil::DefaultCurrentTimeStr() + "; " + "testDeleteLifecyleEventForground");
|
||||||
|
|
||||||
FreezeUtil::LifecycleFlow backgroundFlow = { token_, FreezeUtil::TimeoutState::BACKGROUND };
|
sptr<IRemoteObject> token2(new IPCObjectStub());
|
||||||
FreezeUtil::GetInstance().AddLifecycleEvent(backgroundFlow, "testDeleteLifecyleEventBackground");
|
FreezeUtil::GetInstance().AddLifecycleEvent(token2, "testDeleteLifecyleEventBackground");
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(backgroundFlow),
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token2),
|
||||||
TimeUtil::DefaultCurrentTimeStr() + "; " + "testDeleteLifecyleEventBackground");
|
TimeUtil::DefaultCurrentTimeStr() + "; " + "testDeleteLifecyleEventBackground");
|
||||||
|
|
||||||
FreezeUtil::GetInstance().DeleteLifecycleEvent(token_);
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token1);
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(foregroundFlow), "");
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token1), "");
|
||||||
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(backgroundFlow), "");
|
FreezeUtil::GetInstance().DeleteLifecycleEvent(token2);
|
||||||
|
EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(token2), "");
|
||||||
|
|
||||||
TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_003 is end");
|
TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_003 is end");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,10 @@ ohos_shared_library("freeze_util") {
|
|||||||
"${ability_runtime_services_path}/common/include",
|
"${ability_runtime_services_path}/common/include",
|
||||||
]
|
]
|
||||||
|
|
||||||
sources = [ "src/freeze_util.cpp" ]
|
sources = [
|
||||||
|
"src/error_msg_util.cpp",
|
||||||
|
"src/freeze_util.cpp",
|
||||||
|
]
|
||||||
|
|
||||||
public_configs = [ ":freeze_util_config" ]
|
public_configs = [ ":freeze_util_config" ]
|
||||||
|
|
||||||
|
58
utils/global/freeze/include/error_msg_util.h
Normal file
58
utils/global/freeze/include/error_msg_util.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024 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
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OHOS_ABILITY_RUNTIME_ERROR_MSG_UTIL_H
|
||||||
|
#define OHOS_ABILITY_RUNTIME_ERROR_MSG_UTIL_H
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "iremote_object.h"
|
||||||
|
|
||||||
|
namespace OHOS::AbilityRuntime {
|
||||||
|
class ErrorMsgGuard {
|
||||||
|
public:
|
||||||
|
ErrorMsgGuard(sptr<IRemoteObject> token, uintptr_t scheduler, const std::string &name); // for ability
|
||||||
|
ErrorMsgGuard(pid_t pid, uintptr_t scheduler, const std::string &name); // for app
|
||||||
|
~ErrorMsgGuard();
|
||||||
|
|
||||||
|
ErrorMsgGuard(const ErrorMsgGuard &) = delete;
|
||||||
|
void operator=(const ErrorMsgGuard &) = delete;
|
||||||
|
private:
|
||||||
|
sptr<IRemoteObject> token_; // token, determines ability or app
|
||||||
|
pid_t pid_ = 0;
|
||||||
|
std::string errorKey_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ErrorMgsUtil {
|
||||||
|
public:
|
||||||
|
ErrorMgsUtil& operator=(const ErrorMgsUtil&) = delete;
|
||||||
|
ErrorMgsUtil(const ErrorMgsUtil&) = delete;
|
||||||
|
virtual ~ErrorMgsUtil() = default;
|
||||||
|
static ErrorMgsUtil& GetInstance();
|
||||||
|
static std::string BuildErrorKey(uintptr_t scheduler, const std::string &name);
|
||||||
|
|
||||||
|
void AddErrorMsg(const std::string &key, const std::string &errorMsg);
|
||||||
|
bool UpdateErrorMsg(const std::string &key, const std::string &errorMsg);
|
||||||
|
std::string DeleteErrorMsg(const std::string &key);
|
||||||
|
private:
|
||||||
|
ErrorMgsUtil() = default;
|
||||||
|
|
||||||
|
std::mutex errorMsgMapMutex_;
|
||||||
|
std::unordered_map<std::string, std::string> errorMsgMap_;
|
||||||
|
};
|
||||||
|
} // namespace OHOS::AbilityRuntime
|
||||||
|
#endif // OHOS_ABILITY_RUNTIME_ERROR_MSG_UTIL_H
|
@ -16,6 +16,7 @@
|
|||||||
#ifndef OHOS_ABILITY_RUNTIME_FREEZE_UTIL_H
|
#ifndef OHOS_ABILITY_RUNTIME_FREEZE_UTIL_H
|
||||||
#define OHOS_ABILITY_RUNTIME_FREEZE_UTIL_H
|
#define OHOS_ABILITY_RUNTIME_FREEZE_UTIL_H
|
||||||
|
|
||||||
|
#include <list>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@ -34,11 +35,6 @@ public:
|
|||||||
struct LifecycleFlow {
|
struct LifecycleFlow {
|
||||||
sptr<IRemoteObject> token;
|
sptr<IRemoteObject> token;
|
||||||
TimeoutState state = TimeoutState::UNKNOWN;
|
TimeoutState state = TimeoutState::UNKNOWN;
|
||||||
|
|
||||||
bool operator==(const LifecycleFlow &other) const
|
|
||||||
{
|
|
||||||
return token == other.token && state == other.state;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FreezeUtil& operator=(const FreezeUtil&) = delete;
|
FreezeUtil& operator=(const FreezeUtil&) = delete;
|
||||||
@ -46,10 +42,9 @@ public:
|
|||||||
virtual ~FreezeUtil() = default;
|
virtual ~FreezeUtil() = default;
|
||||||
static FreezeUtil& GetInstance();
|
static FreezeUtil& GetInstance();
|
||||||
|
|
||||||
void AddLifecycleEvent(const LifecycleFlow &flow, const std::string &entry);
|
void AddLifecycleEvent(sptr<IRemoteObject> token, const std::string &entry);
|
||||||
bool AppendLifecycleEvent(const LifecycleFlow &flow, const std::string &entry);
|
bool AppendLifecycleEvent(sptr<IRemoteObject> token, const std::string &entry);
|
||||||
std::string GetLifecycleEvent(const LifecycleFlow &flow);
|
std::string GetLifecycleEvent(sptr<IRemoteObject> token);
|
||||||
void DeleteLifecycleEvent(const LifecycleFlow &flow);
|
|
||||||
void DeleteLifecycleEvent(sptr<IRemoteObject> token);
|
void DeleteLifecycleEvent(sptr<IRemoteObject> token);
|
||||||
|
|
||||||
void AddAppLifecycleEvent(pid_t pid, const std::string &entry);
|
void AddAppLifecycleEvent(pid_t pid, const std::string &entry);
|
||||||
@ -57,19 +52,18 @@ public:
|
|||||||
std::string GetAppLifecycleEvent(pid_t pid);
|
std::string GetAppLifecycleEvent(pid_t pid);
|
||||||
private:
|
private:
|
||||||
FreezeUtil() = default;
|
FreezeUtil() = default;
|
||||||
void DeleteLifecycleEventInner(const LifecycleFlow &flow);
|
|
||||||
|
|
||||||
class LifecycleFlowObjHash {
|
class RemoteObjHash {
|
||||||
public:
|
public:
|
||||||
size_t operator() (const LifecycleFlow &flow) const
|
size_t operator() (const sptr<IRemoteObject> &obj) const
|
||||||
{
|
{
|
||||||
return reinterpret_cast<size_t>(flow.token.GetRefPtr()) + std::hash<int>()(static_cast<int>(flow.state));
|
return std::hash<IRemoteObject*>()(obj.GetRefPtr());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
std::unordered_map<LifecycleFlow, std::string, LifecycleFlowObjHash> lifecycleFlow_;
|
std::unordered_map<sptr<IRemoteObject>, std::list<std::string>, RemoteObjHash> lifecycleFlow_;
|
||||||
std::unordered_map<pid_t, std::string> appLifeCycleFlow_;
|
std::unordered_map<pid_t, std::list<std::string>> appLifeCycleFlow_;
|
||||||
};
|
};
|
||||||
} // namespace OHOS::AbilityRuntime
|
} // namespace OHOS::AbilityRuntime
|
||||||
#endif // OHOS_ABILITY_RUNTIME_FREEZE_UTIL_H
|
#endif // OHOS_ABILITY_RUNTIME_FREEZE_UTIL_H
|
87
utils/global/freeze/src/error_msg_util.cpp
Normal file
87
utils/global/freeze/src/error_msg_util.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024 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
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "error_msg_util.h"
|
||||||
|
|
||||||
|
#include "freeze_util.h"
|
||||||
|
|
||||||
|
namespace OHOS::AbilityRuntime {
|
||||||
|
ErrorMsgGuard::ErrorMsgGuard(sptr<IRemoteObject> token, uintptr_t scheduler, const std::string &name)
|
||||||
|
: token_(token), errorKey_(ErrorMgsUtil::BuildErrorKey(scheduler, name))
|
||||||
|
{
|
||||||
|
if (token != nullptr) {
|
||||||
|
ErrorMgsUtil::GetInstance().AddErrorMsg(errorKey_, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorMsgGuard::ErrorMsgGuard(pid_t pid, uintptr_t scheduler, const std::string &name)
|
||||||
|
: pid_(pid), errorKey_(ErrorMgsUtil::BuildErrorKey(scheduler, name))
|
||||||
|
{
|
||||||
|
ErrorMgsUtil::GetInstance().AddErrorMsg(errorKey_, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorMsgGuard::~ErrorMsgGuard()
|
||||||
|
{
|
||||||
|
auto errorMsg = ErrorMgsUtil::GetInstance().DeleteErrorMsg(errorKey_);
|
||||||
|
if (errorMsg.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (token_) {
|
||||||
|
FreezeUtil::GetInstance().AppendLifecycleEvent(token_, errorMsg);
|
||||||
|
} else {
|
||||||
|
FreezeUtil::GetInstance().AddAppLifecycleEvent(pid_, errorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorMgsUtil &ErrorMgsUtil::GetInstance()
|
||||||
|
{
|
||||||
|
static ErrorMgsUtil instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ErrorMgsUtil::BuildErrorKey(uintptr_t scheduler, const std::string &name)
|
||||||
|
{
|
||||||
|
return std::to_string(scheduler) + "#" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ErrorMgsUtil::AddErrorMsg(const std::string &key, const std::string &errorMsg)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(errorMsgMapMutex_);
|
||||||
|
errorMsgMap_[key] = errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ErrorMgsUtil::UpdateErrorMsg(const std::string &key, const std::string &errorMsg)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(errorMsgMapMutex_);
|
||||||
|
auto it = errorMsgMap_.find(key);
|
||||||
|
if (it == errorMsgMap_.end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
it->second = errorMsg;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ErrorMgsUtil::DeleteErrorMsg(const std::string &key)
|
||||||
|
{
|
||||||
|
std::lock_guard lock(errorMsgMapMutex_);
|
||||||
|
auto it = errorMsgMap_.find(key);
|
||||||
|
if (it == errorMsgMap_.end()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
auto result = std::move(it->second);
|
||||||
|
errorMsgMap_.erase(it);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} // namespace OHOS::AbilityRuntime
|
@ -19,82 +19,90 @@
|
|||||||
#include "time_util.h"
|
#include "time_util.h"
|
||||||
|
|
||||||
namespace OHOS::AbilityRuntime {
|
namespace OHOS::AbilityRuntime {
|
||||||
|
namespace {
|
||||||
|
constexpr int32_t MAX_ENTRY_COUNT = 20;
|
||||||
|
std::string ConcatStr(const std::list<std::string> &strList, const std::string &split)
|
||||||
|
{
|
||||||
|
if (strList.empty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (strList.size() == 1) {
|
||||||
|
return strList.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t reserveSize = 0;
|
||||||
|
for (const auto &item : strList) {
|
||||||
|
reserveSize += split.size() + item.size();
|
||||||
|
}
|
||||||
|
reserveSize -= split.size();
|
||||||
|
std::string result;
|
||||||
|
if (reserveSize > 0) {
|
||||||
|
result.reserve(reserveSize);
|
||||||
|
}
|
||||||
|
result.append(strList.front());
|
||||||
|
auto iter = strList.begin();
|
||||||
|
for (++iter; iter != strList.end(); ++iter) {
|
||||||
|
result.append(split).append(*iter);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FreezeUtil& FreezeUtil::GetInstance()
|
FreezeUtil& FreezeUtil::GetInstance()
|
||||||
{
|
{
|
||||||
static FreezeUtil instance;
|
static FreezeUtil instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreezeUtil::AddLifecycleEvent(const LifecycleFlow &flow, const std::string &entry)
|
void FreezeUtil::AddLifecycleEvent(sptr<IRemoteObject> token, const std::string &entry)
|
||||||
{
|
{
|
||||||
auto newEntry = TimeUtil::DefaultCurrentTimeStr() + "; " + entry;
|
auto newEntry = TimeUtil::DefaultCurrentTimeStr() + "; " + entry;
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
auto iter = lifecycleFlow_.find(flow);
|
auto &entryList = lifecycleFlow_[token];
|
||||||
if (iter != lifecycleFlow_.end()) {
|
entryList.emplace_back(TimeUtil::DefaultCurrentTimeStr() + "; " + entry);
|
||||||
iter->second += "\n" + newEntry;
|
if (entryList.size() > MAX_ENTRY_COUNT) {
|
||||||
} else {
|
entryList.pop_front();
|
||||||
lifecycleFlow_.emplace(flow, newEntry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FreezeUtil::AppendLifecycleEvent(const LifecycleFlow &flow, const std::string &entry)
|
bool FreezeUtil::AppendLifecycleEvent(sptr<IRemoteObject> token, const std::string &entry)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
auto iter = lifecycleFlow_.find(flow);
|
auto iter = lifecycleFlow_.find(token);
|
||||||
if (iter == lifecycleFlow_.end()) {
|
if (iter == lifecycleFlow_.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto newEntry = TimeUtil::DefaultCurrentTimeStr() + "; " + entry;
|
auto &entryList = iter->second;
|
||||||
iter->second += "\n" + newEntry;
|
entryList.emplace_back(TimeUtil::DefaultCurrentTimeStr() + "; " + entry);
|
||||||
|
if (entryList.size() > MAX_ENTRY_COUNT) {
|
||||||
|
entryList.pop_front();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FreezeUtil::GetLifecycleEvent(const LifecycleFlow &flow)
|
std::string FreezeUtil::GetLifecycleEvent(sptr<IRemoteObject> token)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
auto search = lifecycleFlow_.find(flow);
|
auto search = lifecycleFlow_.find(token);
|
||||||
if (search != lifecycleFlow_.end()) {
|
if (search != lifecycleFlow_.end()) {
|
||||||
return search->second;
|
return ConcatStr(search->second, "\n");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreezeUtil::DeleteLifecycleEvent(const LifecycleFlow &flow)
|
|
||||||
{
|
|
||||||
std::lock_guard lock(mutex_);
|
|
||||||
DeleteLifecycleEventInner(flow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreezeUtil::DeleteLifecycleEvent(sptr<IRemoteObject> token)
|
void FreezeUtil::DeleteLifecycleEvent(sptr<IRemoteObject> token)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
if (lifecycleFlow_.empty()) {
|
lifecycleFlow_.erase(token);
|
||||||
return;
|
|
||||||
}
|
|
||||||
LifecycleFlow foregroundFlow = { token, TimeoutState::FOREGROUND };
|
|
||||||
DeleteLifecycleEventInner(foregroundFlow);
|
|
||||||
|
|
||||||
LifecycleFlow backgroundFlow = { token, TimeoutState::BACKGROUND };
|
|
||||||
DeleteLifecycleEventInner(backgroundFlow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FreezeUtil::DeleteLifecycleEventInner(const LifecycleFlow &flow)
|
|
||||||
{
|
|
||||||
if (lifecycleFlow_.count(flow)) {
|
|
||||||
lifecycleFlow_.erase(flow);
|
|
||||||
}
|
|
||||||
TAG_LOGD(AAFwkTag::DEFAULT, "lifecycleFlow size: %{public}zu", lifecycleFlow_.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreezeUtil::AddAppLifecycleEvent(pid_t pid, const std::string &entry)
|
void FreezeUtil::AddAppLifecycleEvent(pid_t pid, const std::string &entry)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
auto newEntry = TimeUtil::DefaultCurrentTimeStr() + "; " + entry;
|
auto &entryList = appLifeCycleFlow_[pid];
|
||||||
auto iter = appLifeCycleFlow_.find(pid);
|
entryList.emplace_back(TimeUtil::DefaultCurrentTimeStr() + "; " + entry);
|
||||||
if (iter != appLifeCycleFlow_.end()) {
|
if (entryList.size() > MAX_ENTRY_COUNT) {
|
||||||
iter->second += "\n" + newEntry;
|
entryList.pop_front();
|
||||||
} else {
|
|
||||||
appLifeCycleFlow_.emplace(pid, newEntry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +117,7 @@ std::string FreezeUtil::GetAppLifecycleEvent(pid_t pid)
|
|||||||
std::lock_guard lock(mutex_);
|
std::lock_guard lock(mutex_);
|
||||||
auto search = appLifeCycleFlow_.find(pid);
|
auto search = appLifeCycleFlow_.find(pid);
|
||||||
if (search != appLifeCycleFlow_.end()) {
|
if (search != appLifeCycleFlow_.end()) {
|
||||||
return search->second;
|
return ConcatStr(search->second, "\n");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user