!9671 abilityContext提供获取want的方法

Merge pull request !9671 from 于文泽/scb
This commit is contained in:
openharmony_ci 2024-08-02 02:42:33 +00:00 committed by Gitee
commit 0d993428ea
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 28 additions and 2 deletions

View File

@ -1049,5 +1049,15 @@ ErrCode AbilityContextImpl::OpenLink(const AAFwk::Want& want, int requestCode)
TAG_LOGD(AAFwkTag::CONTEXT, "called");
return AAFwk::AbilityManagerClient::GetInstance()->OpenLink(want, token_, -1, requestCode);
}
std::shared_ptr<AAFwk::Want> AbilityContextImpl::GetWant()
{
auto abilityCallback = abilityCallback_.lock();
if (abilityCallback == nullptr) {
TAG_LOGW(AAFwkTag::CONTEXT, "abilityCallback is nullptr.");
return nullptr;
}
return abilityCallback->GetWant();
}
} // namespace AbilityRuntime
} // namespace OHOS

View File

@ -349,6 +349,8 @@ public:
virtual void SetRestoreEnabled(bool enabled) = 0;
virtual bool GetRestoreEnabled() = 0;
virtual std::shared_ptr<AAFwk::Want> GetWant() = 0;
#ifdef SUPPORT_GRAPHICS
#ifdef SUPPORT_SCREEN
/**

View File

@ -240,6 +240,8 @@ public:
void SetRestoreEnabled(bool enabled) override;
bool GetRestoreEnabled() override;
std::shared_ptr<AAFwk::Want> GetWant() override;
#ifdef SUPPORT_SCREEN
/**
* @brief Set mission label of this ability.

View File

@ -454,7 +454,7 @@ public:
*
* @return Returns the Want object that starts this ability.
*/
std::shared_ptr<AAFwk::Want> GetWant();
std::shared_ptr<AAFwk::Want> GetWant() override;
/**
* @brief Sets the result code and data to be returned by this Page ability to the caller.

View File

@ -102,6 +102,8 @@ public:
* @param observer the lifecycle observer to be unregistered on ability.
*/
virtual void UnregisterAbilityLifecycleObserver(const std::shared_ptr<ILifecycleObserver> &observer) = 0;
virtual std::shared_ptr<AAFwk::Want> GetWant() = 0;
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -102,7 +102,7 @@ public:
* @brief Obtains the Want object that starts this ability.
* @return Returns the Want object that starts this ability.
*/
std::shared_ptr<AAFwk::Want> GetWant();
std::shared_ptr<AAFwk::Want> GetWant() override;
/**
* @brief Init the UIability

View File

@ -86,6 +86,11 @@ public:
void UnregisterAbilityLifecycleObserver(const std::shared_ptr<ILifecycleObserver> &observer)
{
}
std::shared_ptr<AAFwk::Want> GetWant()
{
return nullptr;
}
};
class AbilityContextImplTest : public testing::Test {

View File

@ -63,6 +63,11 @@ public:
void UnregisterAbilityLifecycleObserver(const std::shared_ptr<ILifecycleObserver> &observer)
{
}
std::shared_ptr<AAFwk::Want> GetWant()
{
return nullptr;
}
};
class DialogUIExtensionCallbackTest : public testing::Test {