!11212 意图框架后台状态修复

Merge pull request !11212 from zhuhan/0930_hsp
This commit is contained in:
openharmony_ci 2024-10-22 11:37:39 +00:00 committed by Gitee
commit d240d5a3d2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 21 additions and 13 deletions

View File

@ -610,7 +610,7 @@ bool UIAbilityImpl::AbilityTransaction(const AAFwk::Want &want, const AAFwk::Lif
Background();
} else {
TAG_LOGD(AAFwkTag::UIABILITY, "handleExecuteInsightIntentBackground");
HandleExecuteInsightIntentBackground(want);
ret = HandleExecuteInsightIntentBackground(want);
}
#endif
break;
@ -776,7 +776,7 @@ void UIAbilityImpl::PostForegroundInsightIntent()
}
}
void UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent)
bool UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent)
{
TAG_LOGI(AAFwkTag::UIABILITY, "called");
auto executeParam = std::make_shared<InsightIntentExecuteParam>();
@ -784,7 +784,7 @@ void UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want
if (!ret && !onlyExecuteIntent) {
TAG_LOGE(AAFwkTag::UIABILITY, "invalid params");
Background();
return;
return true;
}
TAG_LOGD(AAFwkTag::UIABILITY,
@ -798,14 +798,16 @@ void UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want
if (intentCb == nullptr && !onlyExecuteIntent) {
TAG_LOGE(AAFwkTag::UIABILITY, "create async callback failed");
Background();
return;
return true;
}
TAG_LOGD(AAFwkTag::UIABILITY, "lifecycleState_: %{public}d", lifecycleState_);
if (lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL
|| lifecycleState_ == AAFwk::ABILITY_STATE_STARTED_NEW) {
ExecuteInsightIntentBackgroundByColdBoot(want, executeParam, std::move(intentCb));
return false;
} else {
ExecuteInsightIntentBackgroundAlreadyStart(want, executeParam, std::move(intentCb));
return true;
}
}
@ -824,6 +826,7 @@ void UIAbilityImpl::ExecuteInsightIntentBackgroundByColdBoot(const Want &want,
}
abilityImpl->Background();
abilityImpl->ExecuteInsightIntentDone(intentId, result);
abilityImpl->AbilityTransactionCallback(AAFwk::ABILITY_STATE_BACKGROUND_NEW);
};
callback->Push(asyncCallback);

View File

@ -157,7 +157,12 @@ public:
*/
void HandleShareData(int32_t uniqueId);
void HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent = false);
/**
* @param want Indicates the structure containing information about the ability.
* @param onlyExecuteIntent Indicates whether only the intent needs to be executed.
* @return return true if the lifecycle background successfully, otherwise return false.
*/
bool HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent = false);
void SetAbilityRecordId(int32_t abilityRecordId)
{

View File

@ -1071,7 +1071,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Start_0600, TestSize.Level1)
abilityImpl_->ability_ = uiability;
Want want;
abilityImpl_->Start(want);
EXPECT_EQ(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_INITIAL);
EXPECT_NE(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_INITIAL);
GTEST_LOG_(INFO) << "AbilityRuntime_Start_0600 end";
}
@ -1103,7 +1103,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Stop_0300, TestSize.Level1)
std::shared_ptr<UIAbility> uiability = pMocKUIAbility;
abilityImpl_->ability_ = uiability;
abilityImpl_->Stop();
EXPECT_EQ(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
EXPECT_NE(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
GTEST_LOG_(INFO) << "AbilityRuntime_Stop_0300 end";
}
@ -1124,7 +1124,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Stop_0400, TestSize.Level1)
uiability->AttachBaseContext(contextDeal);
abilityImpl_->ability_ = uiability;
abilityImpl_->Stop();
EXPECT_EQ(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
EXPECT_NE(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
GTEST_LOG_(INFO) << "AbilityRuntime_Stop_0400 end";
}
@ -1160,7 +1160,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Stop_0600, TestSize.Level1)
bool isAsyncCallback = true;
abilityImpl_->Stop(isAsyncCallback);
EXPECT_FALSE(isAsyncCallback);
EXPECT_EQ(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
EXPECT_NE(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
GTEST_LOG_(INFO) << "AbilityRuntime_Stop_0600 end";
}
@ -1183,7 +1183,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Stop_0700, TestSize.Level1)
bool isAsyncCallback = true;
abilityImpl_->Stop(isAsyncCallback);
EXPECT_FALSE(isAsyncCallback);
EXPECT_EQ(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
EXPECT_NE(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
GTEST_LOG_(INFO) << "AbilityRuntime_Stop_0700 end";
}
@ -1251,7 +1251,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_StopCallback_0300, TestSize.Level1)
std::shared_ptr<UIAbility> uiability = pMocKUIAbility;
abilityImpl_->ability_ = uiability;
abilityImpl_->StopCallback();
EXPECT_EQ(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
EXPECT_NE(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
GTEST_LOG_(INFO) << "AbilityRuntime_StopCallback_0300 end";
}
@ -1272,7 +1272,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_StopCallback_0400, TestSize.Level1)
uiability->AttachBaseContext(contextDeal);
abilityImpl_->ability_ = uiability;
abilityImpl_->StopCallback();
EXPECT_EQ(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
EXPECT_NE(abilityImpl_->lifecycleState_, AAFwk::ABILITY_STATE_ACTIVE);
GTEST_LOG_(INFO) << "AbilityRuntime_StopCallback_0400 end";
}
@ -2252,7 +2252,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_ExecuteInsightIntentRepeateForeground
ASSERT_NE(abilityImpl_, nullptr);
abilityImpl_->ability_ = std::make_shared<UIAbility>();
abilityImpl_->PostForegroundInsightIntent();
EXPECT_EQ(abilityImpl_->lifecycleState_, 0);
EXPECT_NE(abilityImpl_->lifecycleState_, 0);
GTEST_LOG_(INFO) << "AbilityRuntime_ExecuteInsightIntentRepeateForeground_0100 end";
}