modify comments

Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
xinking129
2023-10-23 15:01:42 +08:00
parent 19de349639
commit 04e4bf1f0e
5 changed files with 74 additions and 62 deletions
@@ -24,15 +24,17 @@
using OHOS::AAFwk::WantParams;
namespace OHOS {
namespace AppExecFwk {
const std::string ContinuationHandlerStage::ORIGINAL_DEVICE_ID("deviceId");
const std::string VERSION_CODE_KEY = "version";
ContinuationHandlerStage::ContinuationHandlerStage(
std::weak_ptr<ContinuationManagerStage> &continuationManager, std::weak_ptr<AbilityRuntime::UIAbility> &uiAbility)
namespace
{
ability_ = uiAbility;
continuationManager_ = continuationManager;
const std::string ORIGINAL_DEVICE_ID("deviceId");
const std::string VERSION_CODE_KEY = "version";
}
ContinuationHandlerStage::ContinuationHandlerStage(
std::weak_ptr<ContinuationManagerStage> &continuationManager,
std::weak_ptr<AbilityRuntime::UIAbility> &uiAbility)
: ability_(uiAbility), continuationManager_(continuationManager) {}
bool ContinuationHandlerStage::HandleStartContinuationWithStack(
const sptr<IRemoteObject> &token, const std::string &deviceId, uint32_t versionCode)
{
@@ -29,8 +29,9 @@
namespace OHOS {
namespace AppExecFwk {
const int ContinuationManagerStage::TIMEOUT_MS_WAIT_DMS_NOTIFY_CONTINUATION_COMPLETE = 25000;
const int ContinuationManagerStage::TIMEOUT_MS_WAIT_REMOTE_NOTIFY_BACK = 6000;
namespace {
constexpr int TIMEOUT_MS_WAIT_DMS_NOTIFY_CONTINUATION_COMPLETE = 25000;
constexpr int TIMEOUT_MS_WAIT_REMOTE_NOTIFY_BACK = 6000;
const std::string PAGE_STACK_PROPERTY_NAME = "pageStack";
const std::string SUPPORT_CONTINUE_PAGE_STACK_PROPERTY_NAME = "ohos.extra.param.key.supportContinuePageStack";
const int32_t CONTINUE_ABILITY_REJECTED = 29360197;
@@ -40,11 +41,10 @@ const int32_t CONTINUE_ON_CONTINUE_MISMATCH = 29360204;
#ifdef SUPPORT_GRAPHICS
const int32_t CONTINUE_GET_CONTENT_FAILED = 29360200;
#endif
ContinuationManagerStage::ContinuationManagerStage()
{
progressState_ = ProgressState::INITIAL;
}
ContinuationManagerStage::ContinuationManagerStage() : progressState_(ProgressState::INITIAL) {}
bool ContinuationManagerStage::Init(const std::shared_ptr<AbilityRuntime::UIAbility> &ability,
const sptr<IRemoteObject> &continueToken, const std::shared_ptr<AbilityInfo> &abilityInfo,
const std::shared_ptr<ContinuationHandlerStage> &continuationHandler)
@@ -105,22 +105,26 @@ bool ContinuationManagerStage::HandleContinueAbilityWithStack(const std::string
return false;
}
sptr<IRemoteObject> continueToken = continueToken_;
std::shared_ptr<ContinuationHandlerStage> continuationHandler = continuationHandler_.lock();
if (continuationHandler == nullptr) {
HILOG_ERROR("ContinuationHandler is nullptr.");
return false;
}
InitMainHandlerIfNeed();
auto task = [continuationHandler, continueToken, deviceId, versionCode]() {
wptr<IRemoteObject> continueTokenWeak(continueToken_);
auto task = [continuationHandlerWeak = continuationHandler_, continueTokenWeak, deviceId, versionCode]() {
auto continuationHandler = continuationHandlerWeak.lock();
if (continuationHandler == nullptr) {
HILOG_ERROR("ContinuationHandler is nullptr.");
return;
}
auto continueToken = continueTokenWeak.promote();
if (continueToken == nullptr) {
HILOG_ERROR("continueToken is nullptr.");
return;
}
continuationHandler->HandleStartContinuationWithStack(continueToken, deviceId, versionCode);
};
if (!mainHandler_->PostTask(task)) {
HILOG_ERROR("PostTask failed.");
return false;
}
HILOG_DEBUG("End.");
return true;
}
@@ -128,8 +132,7 @@ bool ContinuationManagerStage::HandleContinueAbilityWithStack(const std::string
int32_t ContinuationManagerStage::OnStartAndSaveData(WantParams &wantParams)
{
HILOG_DEBUG("Begin.");
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return ERR_INVALID_VALUE;
@@ -160,8 +163,7 @@ bool ContinuationManagerStage::IsContinuePageStack(const WantParams &wantParams)
int32_t ContinuationManagerStage::OnContinueAndGetContent(WantParams &wantParams)
{
HILOG_DEBUG("Begin.");
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return ERR_INVALID_VALUE;
@@ -206,17 +208,15 @@ int32_t ContinuationManagerStage::OnContinue(WantParams &wantParams)
HILOG_DEBUG("Ability isStageBasedModel %{public}d.", stageBased);
if (!stageBased) {
return OnStartAndSaveData(wantParams);
} else {
return OnContinueAndGetContent(wantParams);
}
return OnContinueAndGetContent(wantParams);
}
#ifdef SUPPORT_GRAPHICS
bool ContinuationManagerStage::GetContentInfo(WantParams &wantParams)
{
HILOG_DEBUG("Begin.");
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return false;
@@ -344,8 +344,7 @@ void ContinuationManagerStage::CompleteContinuation(int result)
return;
}
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return;
@@ -387,8 +386,7 @@ bool ContinuationManagerStage::NotifyRemoteTerminated()
continuationState_ = ContinuationState::LOCAL_RUNNING;
ChangeProcessState(ProgressState::INITIAL);
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return false;
@@ -402,8 +400,7 @@ bool ContinuationManagerStage::NotifyRemoteTerminated()
bool ContinuationManagerStage::CheckContinuationIllegal()
{
HILOG_DEBUG("Begin.");
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return false;
@@ -426,7 +423,6 @@ bool ContinuationManagerStage::HandleContinueAbility(bool reversible, const std:
return false;
}
sptr<IRemoteObject> continueToken = continueToken_;
std::shared_ptr<ContinuationHandlerStage> continuationHandler = continuationHandler_.lock();
if (continuationHandler == nullptr) {
HILOG_ERROR("ContinuationHandler is nullptr.");
@@ -435,7 +431,19 @@ bool ContinuationManagerStage::HandleContinueAbility(bool reversible, const std:
continuationHandler->SetReversible(reversible);
InitMainHandlerIfNeed();
auto task = [continuationHandler, continueToken, deviceId]() {
wptr<IRemoteObject> continueTokeWeak(continueToken_);
auto task = [continuationHandlerWeak = continuationHandler_, continueTokeWeak, deviceId]() {
auto continuationHandler = continuationHandlerWeak.lock();
if (continuationHandler == nullptr) {
HILOG_ERROR("ContinuationHandler is nullptr.");
return;
}
auto continueToken = continueTokeWeak.promote();
if (continueToken == nullptr) {
HILOG_ERROR("continueToken is nullptr.");
return;
}
continuationHandler->HandleStartContinuation(continueToken, deviceId);
};
if (!mainHandler_->PostTask(task)) {
@@ -520,8 +528,7 @@ bool ContinuationManagerStage::DoScheduleStartContinuation()
return false;
}
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return false;
@@ -542,8 +549,7 @@ bool ContinuationManagerStage::DoScheduleSaveData(WantParams &saveData)
return false;
}
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return false;
@@ -570,8 +576,7 @@ bool ContinuationManagerStage::DoScheduleRestoreData(const WantParams &restoreDa
return false;
}
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return false;
@@ -593,8 +598,7 @@ bool ContinuationManagerStage::DoScheduleRestoreData(const WantParams &restoreDa
bool ContinuationManagerStage::DoRestoreFromRemote(const WantParams &restoreData)
{
HILOG_DEBUG("Begin.");
std::shared_ptr<AbilityRuntime::UIAbility> ability = nullptr;
ability = ability_.lock();
std::shared_ptr<AbilityRuntime::UIAbility> ability = ability_.lock();
if (ability == nullptr) {
HILOG_ERROR("Ability is nullptr.");
return false;
@@ -29,7 +29,13 @@ ReverseContinuationSchedulerPrimaryStage::ReverseContinuationSchedulerPrimarySta
void ReverseContinuationSchedulerPrimaryStage::NotifyReplicaTerminated()
{
HILOG_DEBUG("Begin.");
auto task = [reverseContinuationSchedulerPrimary = this]() {
wptr<ReverseContinuationSchedulerPrimaryStage> weak = this;
auto task = [weak]() {
auto reverseContinuationSchedulerPrimary = weak.promote();
if (reverseContinuationSchedulerPrimary == nullptr) {
HILOG_ERROR("reverseContinuationSchedulerPrimary is nullptr.");
return;
}
reverseContinuationSchedulerPrimary->HandlerNotifyReplicaTerminated();
};
@@ -49,7 +55,13 @@ void ReverseContinuationSchedulerPrimaryStage::NotifyReplicaTerminated()
bool ReverseContinuationSchedulerPrimaryStage::ContinuationBack(const AAFwk::Want &want)
{
HILOG_DEBUG("Begin.");
auto task = [reverseContinuationSchedulerPrimary = this, want]() {
wptr<ReverseContinuationSchedulerPrimaryStage> weak = this;
auto task = [weak, want]() {
auto reverseContinuationSchedulerPrimary = weak.promote();
if (reverseContinuationSchedulerPrimary == nullptr) {
HILOG_ERROR("reverseContinuationSchedulerPrimary is nullptr.");
return;
}
reverseContinuationSchedulerPrimary->HandlerContinuationBack(want);
};
@@ -70,8 +82,7 @@ bool ReverseContinuationSchedulerPrimaryStage::ContinuationBack(const AAFwk::Wan
void ReverseContinuationSchedulerPrimaryStage::HandlerNotifyReplicaTerminated()
{
HILOG_DEBUG("Begin.");
std::shared_ptr<IReverseContinuationSchedulerPrimaryHandler> continuationHandler = nullptr;
continuationHandler = continuationHandler_.lock();
std::shared_ptr<IReverseContinuationSchedulerPrimaryHandler> continuationHandler = continuationHandler_.lock();
if (continuationHandler == nullptr) {
HILOG_ERROR("ContinuationHandler is nullptr.");
return;
@@ -83,8 +94,7 @@ void ReverseContinuationSchedulerPrimaryStage::HandlerNotifyReplicaTerminated()
void ReverseContinuationSchedulerPrimaryStage::HandlerContinuationBack(const AAFwk::Want &want)
{
HILOG_DEBUG("Begin.");
std::shared_ptr<IReverseContinuationSchedulerPrimaryHandler> continuationHandler = nullptr;
continuationHandler = continuationHandler_.lock();
std::shared_ptr<IReverseContinuationSchedulerPrimaryHandler> continuationHandler = continuationHandler_.lock();
if (continuationHandler == nullptr) {
HILOG_ERROR("ContinuationHandler is nullptr.");
return;
@@ -53,7 +53,7 @@ public:
* @param deviceId The device identifier. This value doesn't matter.
* @return zero if success.
*/
virtual bool HandleStartContinuation(const sptr<IRemoteObject> &token, const std::string &deviceId) override;
bool HandleStartContinuation(const sptr<IRemoteObject> &token, const std::string &deviceId) override;
/**
* @brief Receive a scheduler which could handle reverse continuation.
@@ -61,43 +61,43 @@ public:
* reversible. This method will not be called if this continuation is not reversible.
* @param remoteReplica A scheduler to handle reverse continuation request.
*/
virtual void HandleReceiveRemoteScheduler(const sptr<IRemoteObject> &remoteReplica) override;
void HandleReceiveRemoteScheduler(const sptr<IRemoteObject> &remoteReplica) override;
/**
* @brief Called by DMS when the migrate device finished.
* @param result Zero indicate the continuation is success, otherwise integer less than zero.
*/
virtual void HandleCompleteContinuation(int result) override;
void HandleCompleteContinuation(int result) override;
/**
* @brief Pass the primary reverse continuation scheduler object
* @param Primary The remote object repersenting the reverse continuation sch
*/
virtual void PassPrimary(const sptr<IRemoteObject> &Primary) override;
void PassPrimary(const sptr<IRemoteObject> &Primary) override;
/**
* @brief Indicate a reverse continuation
* @return true if the reverse continuation was successful initiated,otherwise false
*/
virtual bool ReverseContinuation() override;
bool ReverseContinuation() override;
/**
* @brief Notify the result of a reverse continuation
* @param reverseResult The result of the reverse continuation
*/
virtual void NotifyReverseResult(int reverseResult) override;
void NotifyReverseResult(int reverseResult) override;
/**
* @brief Handle the continuation back request from the primary
* @param want The want object representing the continuation back request
* @return true indicating successful handling of the continuation back request
*/
virtual bool ContinuationBack(const Want &want) override;
bool ContinuationBack(const Want &want) override;
/**
* @brief Notify Replica Terminated
*/
virtual void NotifyReplicaTerminated() override;
void NotifyReplicaTerminated() override;
/**
* @brief Notify the primary that the replica has terminated
@@ -207,10 +207,6 @@ private:
std::weak_ptr<ContinuationHandlerStage> continuationHandler_;
std::shared_ptr<EventHandler> mainHandler_ = nullptr;
std::mutex lock_;
static const int TIMEOUT_MS_WAIT_DMS_SCHEDULE_START_CONTINUATION;
static const int TIMEOUT_MS_WAIT_DMS_NOTIFY_CONTINUATION_COMPLETE;
static const int TIMEOUT_MS_WAIT_REMOTE_NOTIFY_BACK;
};
} // namespace AppExecFwk
} // namespace OHOS