mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
intent background
Signed-off-by: zhuhan <zhuhan10@huawei.com> Change-Id: Ic7b444ca7c4729f80a3041386ce02e9d78d33207
This commit is contained in:
parent
bd91691600
commit
45b4534cb0
@ -851,13 +851,52 @@ void JsUIAbility::ExecuteInsightIntentMoveToForeground(const Want &want,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JsUIAbility::ExecuteInsightIntentBackground(const Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("called.");
|
||||||
|
if (executeParam == nullptr) {
|
||||||
|
HILOG_WARN("Intent execute param invalid.");
|
||||||
|
InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback), ERR_OK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abilityInfo_) {
|
||||||
|
jsRuntime_.UpdateModuleNameAndAssetPath(abilityInfo_->moduleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
InsightIntentExecutorInfo executeInfo;
|
||||||
|
auto ret = GetInsightIntentExecutorInfo(want, executeParam, executeInfo);
|
||||||
|
if (!ret) {
|
||||||
|
HILOG_ERROR("Get Intent executor failed.");
|
||||||
|
InsightIntentExecutorMgr::TriggerCallbackInner(std::move(callback),
|
||||||
|
static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = DelayedSingleton<InsightIntentExecutorMgr>::GetInstance()->ExecuteInsightIntent(
|
||||||
|
jsRuntime_, executeInfo, std::move(callback));
|
||||||
|
if (!ret) {
|
||||||
|
// callback has removed, release in insight intent executor.
|
||||||
|
HILOG_ERROR("Execute insight intent failed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool JsUIAbility::GetInsightIntentExecutorInfo(const Want &want,
|
bool JsUIAbility::GetInsightIntentExecutorInfo(const Want &want,
|
||||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
InsightIntentExecutorInfo& executeInfo)
|
InsightIntentExecutorInfo& executeInfo)
|
||||||
{
|
{
|
||||||
HILOG_DEBUG("called.");
|
HILOG_DEBUG("called.");
|
||||||
|
|
||||||
auto context = GetAbilityContext();
|
auto context = GetAbilityContext();
|
||||||
if (executeParam == nullptr || context == nullptr || abilityInfo_ == nullptr || jsWindowStageObj_ == nullptr) {
|
if (executeParam == nullptr || context == nullptr || abilityInfo_ == nullptr) {
|
||||||
|
HILOG_ERROR("Param invalid.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (executeParam->executeMode_ == AppExecFwk::ExecuteMode::UI_ABILITY_FOREGROUND
|
||||||
|
&& jsWindowStageObj_ == nullptr) {
|
||||||
HILOG_ERROR("Param invalid.");
|
HILOG_ERROR("Param invalid.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -868,7 +907,9 @@ bool JsUIAbility::GetInsightIntentExecutorInfo(const Want &want,
|
|||||||
executeInfo.esmodule = abilityInfo_->compileMode == AppExecFwk::CompileMode::ES_MODULE;
|
executeInfo.esmodule = abilityInfo_->compileMode == AppExecFwk::CompileMode::ES_MODULE;
|
||||||
executeInfo.windowMode = windowMode_;
|
executeInfo.windowMode = windowMode_;
|
||||||
executeInfo.token = context->GetToken();
|
executeInfo.token = context->GetToken();
|
||||||
executeInfo.pageLoader = jsWindowStageObj_;
|
if (jsWindowStageObj_ != nullptr) {
|
||||||
|
executeInfo.pageLoader = jsWindowStageObj_;
|
||||||
|
}
|
||||||
executeInfo.executeParam = executeParam;
|
executeInfo.executeParam = executeParam;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -264,6 +264,11 @@ void AbilityThread::CallRequest()
|
|||||||
HILOG_DEBUG("called");
|
HILOG_DEBUG("called");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbilityThread::OnExecuteIntent(const Want &want)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("called");
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> AbilityThread::ExecuteBatch(
|
std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> AbilityThread::ExecuteBatch(
|
||||||
const std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> &operations)
|
const std::vector<std::shared_ptr<AppExecFwk::DataAbilityOperation>> &operations)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ bool InsightIntentExecutorMgr::ExecuteInsightIntent(Runtime& runtime, const Insi
|
|||||||
TriggerCallbackInner(std::move(callback), static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
TriggerCallbackInner(std::move(callback), static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
HILOG_DEBUG("AddInsightIntentExecutor.");
|
||||||
AddInsightIntentExecutor(executeParam->insightIntentId_, intentExecutor);
|
AddInsightIntentExecutor(executeParam->insightIntentId_, intentExecutor);
|
||||||
|
|
||||||
bool isAsync = false;
|
bool isAsync = false;
|
||||||
|
@ -132,6 +132,7 @@ bool JsInsightIntentExecutor::HandleExecuteIntent(
|
|||||||
ReplyFailedInner();
|
ReplyFailedInner();
|
||||||
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
||||||
}
|
}
|
||||||
|
HILOG_DEBUG("ExecuteInsightIntentUIAbilityBackground");
|
||||||
successful = ExecuteInsightIntentUIAbilityBackground(name, param);
|
successful = ExecuteInsightIntentUIAbilityBackground(name, param);
|
||||||
break;
|
break;
|
||||||
case InsightIntentExecuteMode::UIEXTENSION_ABILITY:
|
case InsightIntentExecuteMode::UIEXTENSION_ABILITY:
|
||||||
|
@ -990,6 +990,13 @@ void UIAbility::ExecuteInsightIntentMoveToForeground(const AAFwk::Want &want,
|
|||||||
{
|
{
|
||||||
HILOG_DEBUG("called");
|
HILOG_DEBUG("called");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIAbility::ExecuteInsightIntentBackground(const AAFwk::Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("called");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} // namespace AbilityRuntime
|
} // namespace AbilityRuntime
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -584,7 +584,12 @@ bool UIAbilityImpl::AbilityTransaction(const AAFwk::Want &want, const AAFwk::Lif
|
|||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
#ifdef SUPPORT_GRAPHICS
|
#ifdef SUPPORT_GRAPHICS
|
||||||
Background();
|
if (!InsightIntentExecuteParam::IsInsightIntentExecute(want)) {
|
||||||
|
Background();
|
||||||
|
} else {
|
||||||
|
HILOG_DEBUG("HandleExecuteInsightIntentBackground");
|
||||||
|
HandleExecuteInsightIntentBackground(want);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -733,6 +738,82 @@ void UIAbilityImpl::PostForegroundInsightIntent()
|
|||||||
AbilityTransactionCallback(AAFwk::ABILITY_STATE_FOREGROUND_NEW);
|
AbilityTransactionCallback(AAFwk::ABILITY_STATE_FOREGROUND_NEW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIAbilityImpl::HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent)
|
||||||
|
{
|
||||||
|
HILOG_INFO("Execute insight intent in background mode.");
|
||||||
|
auto executeParam = std::make_shared<InsightIntentExecuteParam>();
|
||||||
|
auto ret = InsightIntentExecuteParam::GenerateFromWant(want, *executeParam);
|
||||||
|
if (!ret && !onlyExecuteIntent) {
|
||||||
|
HILOG_ERROR("Generate execute param failed.");
|
||||||
|
Background();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HILOG_DEBUG("Insight intent bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s"
|
||||||
|
"insightIntentName: %{public}s, executeMode: %{public}d, intentId: %{public}" PRIu64"",
|
||||||
|
executeParam->bundleName_.c_str(), executeParam->moduleName_.c_str(), executeParam->abilityName_.c_str(),
|
||||||
|
executeParam->insightIntentName_.c_str(), executeParam->executeMode_, executeParam->insightIntentId_);
|
||||||
|
|
||||||
|
auto intentCb = std::make_unique<InsightIntentExecutorAsyncCallback>();
|
||||||
|
intentCb.reset(InsightIntentExecutorAsyncCallback::Create());
|
||||||
|
if (intentCb == nullptr && !onlyExecuteIntent) {
|
||||||
|
HILOG_ERROR("Create async callback failed.");
|
||||||
|
Background();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HILOG_DEBUG("lifecycleState_: %{public}d", lifecycleState_);
|
||||||
|
if (lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL
|
||||||
|
|| lifecycleState_ == AAFwk::ABILITY_STATE_STARTED_NEW) {
|
||||||
|
ExecuteInsightIntentBackgroundByColdBoot(want, executeParam, std::move(intentCb));
|
||||||
|
} else {
|
||||||
|
ExecuteInsightIntentBackgroundAlreadyStart(want, executeParam, std::move(intentCb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAbilityImpl::ExecuteInsightIntentBackgroundByColdBoot(const Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("called.");
|
||||||
|
auto asyncCallback =
|
||||||
|
[weak = weak_from_this(), intentId = executeParam->insightIntentId_](InsightIntentExecuteResult result) {
|
||||||
|
HILOG_DEBUG("Execute insight intent finshed, intentId %{public}" PRIu64"", intentId);
|
||||||
|
auto abilityImpl = weak.lock();
|
||||||
|
if (abilityImpl == nullptr) {
|
||||||
|
HILOG_ERROR("Ability impl is nullptr.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
abilityImpl->Background();
|
||||||
|
abilityImpl->ExecuteInsightIntentDone(intentId, result);
|
||||||
|
};
|
||||||
|
callback->Push(asyncCallback);
|
||||||
|
|
||||||
|
// private function, no need check ability_ validity.
|
||||||
|
ability_->ExecuteInsightIntentBackground(want, executeParam, std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIAbilityImpl::ExecuteInsightIntentBackgroundAlreadyStart(const Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("called.");
|
||||||
|
|
||||||
|
auto asyncCallback =
|
||||||
|
[weak = weak_from_this(), intentId = executeParam->insightIntentId_](InsightIntentExecuteResult result) {
|
||||||
|
HILOG_DEBUG("Execute insight intent finshed, intentId %{public}" PRIu64"", intentId);
|
||||||
|
auto abilityImpl = weak.lock();
|
||||||
|
if (abilityImpl == nullptr) {
|
||||||
|
HILOG_ERROR("Ability impl is nullptr.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
abilityImpl->ExecuteInsightIntentDone(intentId, result);
|
||||||
|
};
|
||||||
|
callback->Push(asyncCallback);
|
||||||
|
|
||||||
|
// private function, no need check ability_ validity.
|
||||||
|
ability_->ExecuteInsightIntentBackground(want, executeParam, std::move(callback));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} // namespace AbilityRuntime
|
} // namespace AbilityRuntime
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -644,6 +644,34 @@ void UIAbilityThread::CallRequest()
|
|||||||
HILOG_DEBUG("End.");
|
HILOG_DEBUG("End.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIAbilityThread::OnExecuteIntent(const Want &want)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("Begin.");
|
||||||
|
if (abilityImpl_ == nullptr) {
|
||||||
|
HILOG_ERROR("abilityImpl_ is nullptr.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abilityHandler_ == nullptr) {
|
||||||
|
HILOG_ERROR("abilityHandler_ is nullptr.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wptr<UIAbilityThread> weak = this;
|
||||||
|
auto task = [weak, want]() {
|
||||||
|
auto abilityThread = weak.promote();
|
||||||
|
if (abilityThread == nullptr) {
|
||||||
|
HILOG_ERROR("AbilityThread is nullptr.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (abilityThread->abilityImpl_ != nullptr) {
|
||||||
|
abilityThread->abilityImpl_->HandleExecuteInsightIntentBackground(want, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
abilityHandler_->PostTask(task, "UIAbilityThread:OnExecuteIntent");
|
||||||
|
}
|
||||||
|
|
||||||
void UIAbilityThread::HandlePrepareTermianteAbility()
|
void UIAbilityThread::HandlePrepareTermianteAbility()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
std::unique_lock<std::mutex> lock(mutex_);
|
||||||
|
@ -293,6 +293,8 @@ public:
|
|||||||
|
|
||||||
virtual void DumpAbilityInfo(const std::vector<std::string> ¶ms, std::vector<std::string> &info) = 0;
|
virtual void DumpAbilityInfo(const std::vector<std::string> ¶ms, std::vector<std::string> &info) = 0;
|
||||||
|
|
||||||
|
virtual void OnExecuteIntent(const Want &want) = 0;
|
||||||
|
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
virtual int BlockAbility() = 0;
|
virtual int BlockAbility() = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -391,7 +393,9 @@ public:
|
|||||||
SCHEDULE_SHARE_DATA,
|
SCHEDULE_SHARE_DATA,
|
||||||
|
|
||||||
// ipc id for scheduling service ability to prepare terminate (30)
|
// ipc id for scheduling service ability to prepare terminate (30)
|
||||||
SCHEDULE_ABILITY_PREPARE_TERMINATE
|
SCHEDULE_ABILITY_PREPARE_TERMINATE,
|
||||||
|
|
||||||
|
SCHEDULE_ONEXECUTE_INTENT,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace AAFwk
|
} // namespace AAFwk
|
||||||
|
@ -260,6 +260,17 @@ public:
|
|||||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback) override;
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Execute insight intent when an ability didn't started, schedule it to background.
|
||||||
|
*
|
||||||
|
* @param want Want.
|
||||||
|
* @param executeParam insight intent execute param.
|
||||||
|
* @param callback insight intent async callback.
|
||||||
|
*/
|
||||||
|
virtual void ExecuteInsightIntentBackground(const AAFwk::Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DoOnForeground(const Want &want) override;
|
void DoOnForeground(const Want &want) override;
|
||||||
void ContinuationRestore(const Want &want) override;
|
void ContinuationRestore(const Want &want) override;
|
||||||
|
@ -335,6 +335,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void CallRequest() override;
|
void CallRequest() override;
|
||||||
|
|
||||||
|
void OnExecuteIntent(const Want &want) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Execute Batch
|
* @brief Execute Batch
|
||||||
* @param operations Indicates the operations
|
* @param operations Indicates the operations
|
||||||
|
@ -483,6 +483,17 @@ public:
|
|||||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback);
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Execute insight intent when an ability didn't started, schedule it to background.
|
||||||
|
*
|
||||||
|
* @param want Want.
|
||||||
|
* @param executeParam insight intent execute param.
|
||||||
|
* @param callback insight intent async callback.
|
||||||
|
*/
|
||||||
|
virtual void ExecuteInsightIntentBackground(const AAFwk::Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class UIAbilityDisplayListener : public OHOS::Rosen::DisplayManager::IDisplayListener {
|
class UIAbilityDisplayListener : public OHOS::Rosen::DisplayManager::IDisplayListener {
|
||||||
public:
|
public:
|
||||||
|
@ -155,6 +155,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void HandleShareData(int32_t uniqueId);
|
void HandleShareData(int32_t uniqueId);
|
||||||
|
|
||||||
|
void HandleExecuteInsightIntentBackground(const AAFwk::Want &want, bool onlyExecuteIntent = false);
|
||||||
|
|
||||||
#ifdef SUPPORT_GRAPHICS
|
#ifdef SUPPORT_GRAPHICS
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -226,6 +228,12 @@ private:
|
|||||||
inline void ExecuteInsightIntentMoveToForeground(const Want &want,
|
inline void ExecuteInsightIntentMoveToForeground(const Want &want,
|
||||||
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback);
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback);
|
||||||
|
inline void ExecuteInsightIntentBackgroundByColdBoot(const Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback);
|
||||||
|
inline void ExecuteInsightIntentBackgroundAlreadyStart(const Want &want,
|
||||||
|
const std::shared_ptr<InsightIntentExecuteParam> &executeParam,
|
||||||
|
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback);
|
||||||
|
|
||||||
class WindowLifeCycleImpl : public Rosen::IWindowLifeCycle {
|
class WindowLifeCycleImpl : public Rosen::IWindowLifeCycle {
|
||||||
public:
|
public:
|
||||||
|
@ -138,6 +138,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void CallRequest() override;
|
void CallRequest() override;
|
||||||
|
|
||||||
|
void OnExecuteIntent(const Want &want) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DumpAbilityInfoInner(const std::vector<std::string> ¶ms, std::vector<std::string> &info);
|
void DumpAbilityInfoInner(const std::vector<std::string> ¶ms, std::vector<std::string> &info);
|
||||||
void DumpOtherInfo(std::vector<std::string> &info);
|
void DumpOtherInfo(std::vector<std::string> &info);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||||
|
|
||||||
abilityms_files = [
|
abilityms_files = [
|
||||||
|
"src/ability_background_connection.cpp",
|
||||||
"src/ability_connect_manager.cpp",
|
"src/ability_connect_manager.cpp",
|
||||||
"src/ability_debug_deal.cpp",
|
"src/ability_debug_deal.cpp",
|
||||||
"src/ability_event_handler.cpp",
|
"src/ability_event_handler.cpp",
|
||||||
|
59
services/abilitymgr/include/ability_background_connection.h
Normal file
59
services/abilitymgr/include/ability_background_connection.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023 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_ABILITY_BACKGROUND_CONNECTION_H
|
||||||
|
#define OHOS_ABILITY_RUNTIME_ABILITY_BACKGROUND_CONNECTION_H
|
||||||
|
|
||||||
|
#include "ability_connect_callback_interface.h"
|
||||||
|
#include "iremote_object.h"
|
||||||
|
#include "iremote_stub.h"
|
||||||
|
#include "nocopyable.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AAFwk {
|
||||||
|
/**
|
||||||
|
* @class AbilityBackgroundConnection
|
||||||
|
* Ability Background Connection Stub.
|
||||||
|
*/
|
||||||
|
class AbilityBackgroundConnection : public IRemoteStub<IAbilityConnection> {
|
||||||
|
public:
|
||||||
|
AbilityBackgroundConnection() = default;
|
||||||
|
virtual ~AbilityBackgroundConnection() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect.
|
||||||
|
* @param element service ability's ElementName.
|
||||||
|
* @param remoteObject the session proxy of service ability.
|
||||||
|
* @param resultCode ERR_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
void OnAbilityConnectDone(
|
||||||
|
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OnAbilityDisconnectDone, AbilityMs notify caller ability the result of disconnect.
|
||||||
|
*
|
||||||
|
* @param element, service ability's ElementName.
|
||||||
|
* @param resultCode, ERR_OK on success, others on failure.
|
||||||
|
*/
|
||||||
|
void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DISALLOW_COPY_AND_MOVE(AbilityBackgroundConnection);
|
||||||
|
};
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // ABILITY_BACKGROUND_CONNECTION_H
|
@ -1363,9 +1363,18 @@ public:
|
|||||||
int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken,
|
int32_t ExecuteIntent(uint64_t key, const sptr<IRemoteObject> &callerToken,
|
||||||
const InsightIntentExecuteParam ¶m) override;
|
const InsightIntentExecuteParam ¶m) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Execute intent.
|
||||||
|
* @param abilityRequest The abilityRequest.
|
||||||
|
*/
|
||||||
|
int32_t OnExecuteIntent(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord);
|
||||||
|
|
||||||
int32_t StartAbilityWithInsightIntent(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE,
|
int32_t StartAbilityWithInsightIntent(const Want &want, int32_t userId = DEFAULT_INVAL_VALUE,
|
||||||
int requestCode = DEFAULT_INVAL_VALUE);
|
int requestCode = DEFAULT_INVAL_VALUE);
|
||||||
|
|
||||||
|
int32_t StartAbilityByCallWithInsightIntent(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||||
|
const InsightIntentExecuteParam ¶m);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if ability controller can start.
|
* @brief Check if ability controller can start.
|
||||||
* @param want The want of ability to start.
|
* @param want The want of ability to start.
|
||||||
@ -1812,6 +1821,9 @@ private:
|
|||||||
int32_t StartExtensionAbilityWithInsightIntent(const Want &want,
|
int32_t StartExtensionAbilityWithInsightIntent(const Want &want,
|
||||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED);
|
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED);
|
||||||
|
|
||||||
|
bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord,
|
||||||
|
const int32_t oriValidUserId);
|
||||||
|
|
||||||
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
||||||
constexpr static int WAITING_BOOT_ANIMATION_TIMER = 5;
|
constexpr static int WAITING_BOOT_ANIMATION_TIMER = 5;
|
||||||
|
|
||||||
|
@ -322,6 +322,8 @@ public:
|
|||||||
void DumpAbilityInfo(const std::vector<std::string> ¶ms, std::vector<std::string> &info) override;
|
void DumpAbilityInfo(const std::vector<std::string> ¶ms, std::vector<std::string> &info) override;
|
||||||
void CallRequest() override;
|
void CallRequest() override;
|
||||||
|
|
||||||
|
void OnExecuteIntent(const Want &want) override;
|
||||||
|
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
int BlockAbility() override;
|
int BlockAbility() override;
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,6 +66,7 @@ private:
|
|||||||
int NotifyContinuationResultInner(MessageParcel &data, MessageParcel &reply);
|
int NotifyContinuationResultInner(MessageParcel &data, MessageParcel &reply);
|
||||||
int DumpAbilityInfoInner(MessageParcel& data, MessageParcel& reply);
|
int DumpAbilityInfoInner(MessageParcel& data, MessageParcel& reply);
|
||||||
int CallRequestInner(MessageParcel &data, MessageParcel &reply);
|
int CallRequestInner(MessageParcel &data, MessageParcel &reply);
|
||||||
|
int OnExecuteIntentInner(MessageParcel &data, MessageParcel &reply);
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
int BlockAbilityInner(MessageParcel &data, MessageParcel &reply);
|
int BlockAbilityInner(MessageParcel &data, MessageParcel &reply);
|
||||||
#endif
|
#endif
|
||||||
|
@ -348,6 +348,8 @@ public:
|
|||||||
const AAFwk::ContinueState &state);
|
const AAFwk::ContinueState &state);
|
||||||
|
|
||||||
int32_t MoveMissionToBackground(int32_t missionId);
|
int32_t MoveMissionToBackground(int32_t missionId);
|
||||||
|
|
||||||
|
bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord);
|
||||||
#ifdef SUPPORT_GRAPHICS
|
#ifdef SUPPORT_GRAPHICS
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
@ -295,6 +295,9 @@ public:
|
|||||||
|
|
||||||
void SetDevice(std::string deviceType);
|
void SetDevice(std::string deviceType);
|
||||||
|
|
||||||
|
bool IsAbilityStarted(AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetRecord,
|
||||||
|
const int32_t oriValidUserId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token) const;
|
std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token) const;
|
||||||
int32_t GetPersistentIdByAbilityRequest(const AbilityRequest &abilityRequest, bool &reuse, int32_t userId) const;
|
int32_t GetPersistentIdByAbilityRequest(const AbilityRequest &abilityRequest, bool &reuse, int32_t userId) const;
|
||||||
|
38
services/abilitymgr/src/ability_background_connection.cpp
Normal file
38
services/abilitymgr/src/ability_background_connection.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023 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 "ability_background_connection.h"
|
||||||
|
|
||||||
|
#include "hilog_wrapper.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace AAFwk {
|
||||||
|
void AbilityBackgroundConnection::OnAbilityConnectDone(
|
||||||
|
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||||
|
{
|
||||||
|
if (resultCode != ERR_OK) {
|
||||||
|
HILOG_ERROR("%{public}s, abilityName:%{public}s, resultCode:%{public}d",
|
||||||
|
__func__, element.GetAbilityName().c_str(), resultCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbilityBackgroundConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("OnAbilityDisconnectDone");
|
||||||
|
}
|
||||||
|
} // namespace AppExecFwk
|
||||||
|
} // namespace OHOS
|
@ -30,6 +30,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
#include "ability_background_connection.h"
|
||||||
#include "ability_debug_deal.h"
|
#include "ability_debug_deal.h"
|
||||||
#include "ability_info.h"
|
#include "ability_info.h"
|
||||||
#include "ability_interceptor.h"
|
#include "ability_interceptor.h"
|
||||||
@ -8857,8 +8858,8 @@ int32_t AbilityManagerService::ExecuteIntent(uint64_t key, const sptr<IRemoteObj
|
|||||||
ret = StartAbilityWithInsightIntent(want);
|
ret = StartAbilityWithInsightIntent(want);
|
||||||
break;
|
break;
|
||||||
case ExecuteMode::UI_ABILITY_BACKGROUND: {
|
case ExecuteMode::UI_ABILITY_BACKGROUND: {
|
||||||
HILOG_WARN("ExecuteMode UI_ABILITY_BACKGROUND not supported.");
|
HILOG_DEBUG("ExecuteMode UI_ABILITY_BACKGROUND.");
|
||||||
ret = ERR_INVALID_OPERATION;
|
ret = StartAbilityByCallWithInsightIntent(want, callerToken, param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ExecuteMode::UI_EXTENSION_ABILITY:
|
case ExecuteMode::UI_EXTENSION_ABILITY:
|
||||||
@ -8886,6 +8887,36 @@ int32_t AbilityManagerService::ExecuteIntent(uint64_t key, const sptr<IRemoteObj
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AbilityManagerService::IsAbilityStarted(AbilityRequest &abilityRequest,
|
||||||
|
std::shared_ptr<AbilityRecord> &targetRecord, const int32_t oriValidUserId)
|
||||||
|
{
|
||||||
|
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||||
|
HILOG_INFO("scene board is enable");
|
||||||
|
if (uiAbilityLifecycleManager_ == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return uiAbilityLifecycleManager_->IsAbilityStarted(abilityRequest, targetRecord, oriValidUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto missionListMgr = GetListManagerByUserId(oriValidUserId);
|
||||||
|
if (missionListMgr == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return missionListMgr->IsAbilityStarted(abilityRequest, targetRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t AbilityManagerService::OnExecuteIntent(AbilityRequest &abilityRequest,
|
||||||
|
std::shared_ptr<AbilityRecord> &targetRecord)
|
||||||
|
{
|
||||||
|
HILOG_INFO("OnExecuteIntent");
|
||||||
|
if (targetRecord == nullptr || targetRecord->GetScheduler() == nullptr) {
|
||||||
|
return ERR_INVALID_VALUE;
|
||||||
|
}
|
||||||
|
targetRecord->GetScheduler()->OnExecuteIntent(abilityRequest.want);
|
||||||
|
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t AbilityManagerService::StartAbilityWithInsightIntent(const Want &want, int32_t userId, int requestCode)
|
int32_t AbilityManagerService::StartAbilityWithInsightIntent(const Want &want, int32_t userId, int requestCode)
|
||||||
{
|
{
|
||||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||||
@ -8911,6 +8942,42 @@ int32_t AbilityManagerService::StartExtensionAbilityWithInsightIntent(const Want
|
|||||||
return StartExtensionAbilityInner(want, nullptr, DEFAULT_INVAL_VALUE, extensionType, true);
|
return StartExtensionAbilityInner(want, nullptr, DEFAULT_INVAL_VALUE, extensionType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t AbilityManagerService::StartAbilityByCallWithInsightIntent(const Want &want,
|
||||||
|
const sptr<IRemoteObject> &callerToken, const InsightIntentExecuteParam ¶m)
|
||||||
|
{
|
||||||
|
HILOG_INFO("call StartAbilityByCallWithInsightIntent.");
|
||||||
|
sptr<IAbilityConnection> connect = sptr<AbilityBackgroundConnection>::MakeSptr();
|
||||||
|
if (connect == nullptr) {
|
||||||
|
HILOG_ERROR("Invalid connect.");
|
||||||
|
return ERR_INVALID_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbilityRequest abilityRequest;
|
||||||
|
abilityRequest.callType = AbilityCallType::CALL_REQUEST_TYPE;
|
||||||
|
abilityRequest.callerUid = IPCSkeleton::GetCallingUid();
|
||||||
|
abilityRequest.callerToken = callerToken;
|
||||||
|
abilityRequest.startSetting = nullptr;
|
||||||
|
abilityRequest.want = want;
|
||||||
|
abilityRequest.connect = connect;
|
||||||
|
int32_t result = GenerateAbilityRequest(want, -1, abilityRequest, callerToken, GetUserId());
|
||||||
|
if (result != ERR_OK) {
|
||||||
|
HILOG_ERROR("Generate ability request error.");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
std::shared_ptr<AbilityRecord> targetRecord;
|
||||||
|
int32_t oriValidUserId = GetValidUserId(DEFAULT_INVAL_VALUE);
|
||||||
|
auto missionListMgr = GetListManagerByUserId(oriValidUserId);
|
||||||
|
if (IsAbilityStarted(abilityRequest, targetRecord, oriValidUserId)) {
|
||||||
|
HILOG_INFO("ability has already started");
|
||||||
|
result = OnExecuteIntent(abilityRequest, targetRecord);
|
||||||
|
} else {
|
||||||
|
result = StartAbilityByCall(want, connect, callerToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
HILOG_INFO("StartAbilityByCallWithInsightIntent %{public}d", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool AbilityManagerService::IsAbilityControllerStart(const Want &want)
|
bool AbilityManagerService::IsAbilityControllerStart(const Want &want)
|
||||||
{
|
{
|
||||||
auto callingUid = IPCSkeleton::GetCallingUid();
|
auto callingUid = IPCSkeleton::GetCallingUid();
|
||||||
|
@ -1088,6 +1088,25 @@ void AbilitySchedulerProxy::CallRequest()
|
|||||||
HILOG_INFO("AbilitySchedulerProxy::CallRequest end");
|
HILOG_INFO("AbilitySchedulerProxy::CallRequest end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbilitySchedulerProxy::OnExecuteIntent(const Want &want)
|
||||||
|
{
|
||||||
|
HILOG_INFO("AbilitySchedulerProxy::OnExecuteIntent start");
|
||||||
|
|
||||||
|
MessageParcel data;
|
||||||
|
MessageParcel reply;
|
||||||
|
MessageOption option(MessageOption::TF_ASYNC);
|
||||||
|
if (!WriteInterfaceToken(data)) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
data.WriteParcelable(&want);
|
||||||
|
int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ONEXECUTE_INTENT, data, reply, option);
|
||||||
|
if (err != NO_ERROR) {
|
||||||
|
HILOG_ERROR("ScheduleAbilityTransaction fail to SendRequest. err: %{public}d", err);
|
||||||
|
}
|
||||||
|
|
||||||
|
HILOG_INFO("AbilitySchedulerProxy::OnExecuteIntent end");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
int AbilitySchedulerProxy::BlockAbility()
|
int AbilitySchedulerProxy::BlockAbility()
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,7 @@ AbilitySchedulerStub::AbilitySchedulerStub()
|
|||||||
requestFuncMap_[CONTINUE_ABILITY] = &AbilitySchedulerStub::ContinueAbilityInner;
|
requestFuncMap_[CONTINUE_ABILITY] = &AbilitySchedulerStub::ContinueAbilityInner;
|
||||||
requestFuncMap_[DUMP_ABILITY_RUNNER_INNER] = &AbilitySchedulerStub::DumpAbilityInfoInner;
|
requestFuncMap_[DUMP_ABILITY_RUNNER_INNER] = &AbilitySchedulerStub::DumpAbilityInfoInner;
|
||||||
requestFuncMap_[SCHEDULE_SHARE_DATA] = &AbilitySchedulerStub::ShareDataInner;
|
requestFuncMap_[SCHEDULE_SHARE_DATA] = &AbilitySchedulerStub::ShareDataInner;
|
||||||
|
requestFuncMap_[SCHEDULE_ONEXECUTE_INTENT] = &AbilitySchedulerStub::OnExecuteIntentInner;
|
||||||
|
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
requestFuncMap_[BLOCK_ABILITY_INNER] = &AbilitySchedulerStub::BlockAbilityInner;
|
requestFuncMap_[BLOCK_ABILITY_INNER] = &AbilitySchedulerStub::BlockAbilityInner;
|
||||||
@ -640,6 +641,18 @@ int AbilitySchedulerStub::CallRequestInner(MessageParcel &data, MessageParcel &r
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AbilitySchedulerStub::OnExecuteIntentInner(MessageParcel &data, MessageParcel &reply)
|
||||||
|
{
|
||||||
|
HILOG_INFO("AbilitySchedulerStub::OnExecuteIntentInner start");
|
||||||
|
std::shared_ptr<Want> want(data.ReadParcelable<Want>());
|
||||||
|
if (want == nullptr) {
|
||||||
|
HILOG_ERROR("AbilitySchedulerStub want is nullptr");
|
||||||
|
return ERR_INVALID_VALUE;
|
||||||
|
}
|
||||||
|
OnExecuteIntent(*want);
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
int AbilitySchedulerStub::BlockAbilityInner(MessageParcel &data, MessageParcel &reply)
|
int AbilitySchedulerStub::BlockAbilityInner(MessageParcel &data, MessageParcel &reply)
|
||||||
{
|
{
|
||||||
|
@ -3116,6 +3116,14 @@ int MissionListManager::ResolveLocked(const AbilityRequest &abilityRequest)
|
|||||||
return CallAbilityLocked(abilityRequest);
|
return CallAbilityLocked(abilityRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MissionListManager::IsAbilityStarted(AbilityRequest &abilityRequest,
|
||||||
|
std::shared_ptr<AbilityRecord> &targetRecord)
|
||||||
|
{
|
||||||
|
std::shared_ptr<Mission> targetMission;
|
||||||
|
|
||||||
|
return HandleReusedMissionAndAbility(abilityRequest, targetMission, targetRecord);
|
||||||
|
}
|
||||||
|
|
||||||
int MissionListManager::CallAbilityLocked(const AbilityRequest &abilityRequest)
|
int MissionListManager::CallAbilityLocked(const AbilityRequest &abilityRequest)
|
||||||
{
|
{
|
||||||
HILOG_INFO("call ability.");
|
HILOG_INFO("call ability.");
|
||||||
|
@ -588,6 +588,24 @@ int UIAbilityLifecycleManager::ResolveLocked(const AbilityRequest &abilityReques
|
|||||||
return CallAbilityLocked(abilityRequest, userId);
|
return CallAbilityLocked(abilityRequest, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UIAbilityLifecycleManager::IsAbilityStarted(AbilityRequest &abilityRequest,
|
||||||
|
std::shared_ptr<AbilityRecord> &targetRecord, const int32_t oriValidUserId)
|
||||||
|
{
|
||||||
|
HILOG_DEBUG("Call.");
|
||||||
|
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||||
|
bool reuse = false;
|
||||||
|
auto persistentId = GetPersistentIdByAbilityRequest(abilityRequest, reuse, oriValidUserId);
|
||||||
|
if (persistentId == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
targetRecord = sessionAbilityMap_.at(persistentId);
|
||||||
|
if (targetRecord) {
|
||||||
|
targetRecord->AddCallerRecord(abilityRequest.callerToken, abilityRequest.requestCode);
|
||||||
|
targetRecord->SetLaunchReason(LaunchReason::LAUNCHREASON_CALL);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRequest, int32_t userId)
|
int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRequest, int32_t userId)
|
||||||
{
|
{
|
||||||
HILOG_DEBUG("Call.");
|
HILOG_DEBUG("Call.");
|
||||||
@ -606,7 +624,6 @@ int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRe
|
|||||||
} else {
|
} else {
|
||||||
uiAbilityRecord = sessionAbilityMap_.at(persistentId);
|
uiAbilityRecord = sessionAbilityMap_.at(persistentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiAbilityRecord->AddCallerRecord(abilityRequest.callerToken, abilityRequest.requestCode);
|
uiAbilityRecord->AddCallerRecord(abilityRequest.callerToken, abilityRequest.requestCode);
|
||||||
uiAbilityRecord->SetLaunchReason(LaunchReason::LAUNCHREASON_CALL);
|
uiAbilityRecord->SetLaunchReason(LaunchReason::LAUNCHREASON_CALL);
|
||||||
NotifyAbilityToken(uiAbilityRecord->GetToken(), abilityRequest);
|
NotifyAbilityToken(uiAbilityRecord->GetToken(), abilityRequest);
|
||||||
|
@ -146,6 +146,8 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void OnExecuteIntent(const Want &want) override
|
||||||
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t GetU32Data(const char* ptr)
|
uint32_t GetU32Data(const char* ptr)
|
||||||
|
@ -144,6 +144,7 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
virtual void OnExecuteIntent(const Want &want) {};
|
||||||
virtual void ScheduleShareData(const int32_t &uniqueId) {};
|
virtual void ScheduleShareData(const int32_t &uniqueId) {};
|
||||||
virtual bool SchedulePrepareTerminateAbility()
|
virtual bool SchedulePrepareTerminateAbility()
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,11 @@ public:
|
|||||||
virtual void CallRequest()
|
virtual void CallRequest()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
virtual void OnExecuteIntent(const Want &want)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace AppExecFwk
|
} // namespace AppExecFwk
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -108,6 +108,8 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
virtual void OnExecuteIntent(const Want &want) override
|
||||||
|
{};
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
virtual int BlockAbility() override
|
virtual int BlockAbility() override
|
||||||
{
|
{
|
||||||
|
@ -152,6 +152,10 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnExecuteIntent(const Want &want)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
virtual int BlockAbility()
|
virtual int BlockAbility()
|
||||||
{
|
{
|
||||||
|
@ -120,6 +120,10 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
virtual void OnExecuteIntent(const Want &want) override
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
virtual int BlockAbility() override
|
virtual int BlockAbility() override
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,8 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void OnExecuteIntent(const Want &want) override
|
||||||
|
{};
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
virtual int BlockAbility() override
|
virtual int BlockAbility() override
|
||||||
{
|
{
|
||||||
|
@ -104,6 +104,7 @@ config("test_exception_config") {
|
|||||||
|
|
||||||
ohos_source_set("abilityms_test_source") {
|
ohos_source_set("abilityms_test_source") {
|
||||||
sources = [
|
sources = [
|
||||||
|
"${ability_runtime_services_path}/abilitymgr/src/ability_background_connection.cpp",
|
||||||
"${ability_runtime_services_path}/abilitymgr/src/ability_bundle_event_callback.cpp",
|
"${ability_runtime_services_path}/abilitymgr/src/ability_bundle_event_callback.cpp",
|
||||||
"${ability_runtime_services_path}/abilitymgr/src/ability_connect_callback_stub.cpp",
|
"${ability_runtime_services_path}/abilitymgr/src/ability_connect_callback_stub.cpp",
|
||||||
"${ability_runtime_services_path}/abilitymgr/src/ability_connect_manager.cpp",
|
"${ability_runtime_services_path}/abilitymgr/src/ability_connect_manager.cpp",
|
||||||
|
@ -151,6 +151,8 @@ public:
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void OnExecuteIntent(const Want &want) override
|
||||||
|
{}
|
||||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||||
int BlockAbility() override
|
int BlockAbility() override
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user