新增startUIAbilities and TDD1

Signed-off-by: 朱菲墨 <zhufeimo1@huawei.com>
This commit is contained in:
朱菲墨
2025-07-04 12:47:57 +08:00
parent 0b3a92e335
commit bb5c28a5c0
67 changed files with 2655 additions and 116 deletions
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -79,6 +79,11 @@ class ServiceExtensionContext extends ExtensionContext {
return this.__context_impl__.startServiceExtensionAbilityWithAccount(want, accountId, callback);
}
startUIAbilities(wantList) {
hilog.sLogI(domainID, TAG, 'startUIAbilities');
return this.__context_impl__.startUIAbilities(wantList);
}
stopServiceExtensionAbility(want, callback) {
hilog.sLogI(domainID, TAG, 'stopServiceExtensionAbility');
return this.__context_impl__.stopServiceExtensionAbility(want, callback);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
* Copyright (c) 2023-2025 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
@@ -71,6 +71,11 @@ class UIExtensionContext extends ExtensionContext {
return this.__context_impl__.startAbilityForResultAsCaller(want, options, callback);
}
startUIAbilities(wantList) {
hilog.sLogI(domainID, TAG, 'startUIAbilities');
return this.__context_impl__.startUIAbilities(wantList);
}
terminateSelfWithResult(abilityResult, callback) {
hilog.sLogI(domainID, TAG, 'terminateSelfWithResult');
return this.__context_impl__.terminateSelfWithResult(abilityResult, callback);
@@ -313,8 +313,10 @@ ohos_shared_library("abilitykit_native") {
"${ability_runtime_native_path}/ability/native/free_install_observer_proxy.cpp",
"${ability_runtime_native_path}/ability/native/free_install_observer_stub.cpp",
"${ability_runtime_native_path}/ability/native/insight_intent_host_client.cpp",
"${ability_runtime_native_path}/ability/native/js_deferred_callback.cpp",
"${ability_runtime_native_path}/ability/native/js_free_install_observer.cpp",
"${ability_runtime_native_path}/ability/native/js_query_erms_observer.cpp",
"${ability_runtime_native_path}/ability/native/js_start_abilities_observer.cpp",
"${ability_runtime_native_path}/ability/native/new_ability_impl.cpp",
"${ability_runtime_native_path}/ability/native/query_erms_observer_proxy.cpp",
"${ability_runtime_native_path}/ability/native/query_erms_observer_stub.cpp",
@@ -131,6 +131,19 @@ constexpr const char* ERROR_MSG_ALREADY_MASTER_PROCESS =
"The current process is already a master process and does not support cancellation.";
constexpr const char* ERROR_MSG_NOT_CANDIDATE_MASTER_PROCESS =
"The current process is not a candidate master process and does not support cancellation.";
constexpr const char* ERROR_MSG_EXCEEDS_WANT_LIST_MAXIMUM_SIZE =
"A maximum of four UIAbility instances can be started simultaneously."
"The current parameter exceeds the maximum number.";
constexpr const char* ERROR_MSG_TARGET_TYPE_NOT_UI_ABILITY = "The target component type is not a UIAbility.";
constexpr const char* ERROR_MSG_TARGET_BLOCKED_BY_SYSTEM_MODULE =
"The target component is blocked by the system module and does not support startup.";
constexpr const char* ERROR_MSG_NOT_SUPPORT_IMPLICIT_START = "Implicit startup is not supported.";
constexpr const char* ERROR_MSG_NOT_SUPPORT_START_REMOTE_UI_ABILITY =
"Starting a remote UIAbility is not supported.";
constexpr const char* ERROR_MSG_NOT_SUPPORT_START_PLUGIN_UI_ABILITY =
"Starting a plugin UIAbility is not supported.";
constexpr const char* ERROR_MSG_NOT_SUPPORT_START_DLP_FILES =
"Starting DLP files is not supported.";
// follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework
constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220;
@@ -225,6 +238,13 @@ static std::unordered_map<AbilityErrorCode, const char*> ERR_CODE_MAP = {
{ AbilityErrorCode::ERROR_CODE_NOT_ISOLATION_PROCESS, ERROR_MSG_NOT_ISOLATION_PROCESS},
{ AbilityErrorCode::ERROR_CODE_ALREADY_MASTER_PROCESS, ERROR_MSG_ALREADY_MASTER_PROCESS},
{ AbilityErrorCode::ERROR_CODE_NOT_CANDIDATE_MASTER_PROCESS, ERROR_MSG_NOT_CANDIDATE_MASTER_PROCESS },
{ AbilityErrorCode::ERROR_CODE_EXCEEDS_WANT_LIST_MAXIMUM_SIZE, ERROR_MSG_EXCEEDS_WANT_LIST_MAXIMUM_SIZE },
{ AbilityErrorCode::ERROR_CODE_TARGET_TYPE_NOT_UI_ABILITY, ERROR_MSG_TARGET_TYPE_NOT_UI_ABILITY },
{ AbilityErrorCode::ERROR_CODE_TARGET_BLOCKED_BY_SYSTEM_MODULE, ERROR_MSG_TARGET_BLOCKED_BY_SYSTEM_MODULE },
{ AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_IMPLICIT_START, ERROR_MSG_NOT_SUPPORT_IMPLICIT_START },
{ AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_START_REMOTE_UI_ABILITY, ERROR_MSG_NOT_SUPPORT_START_REMOTE_UI_ABILITY },
{ AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_START_PLUGIN_UI_ABILITY, ERROR_MSG_NOT_SUPPORT_START_PLUGIN_UI_ABILITY },
{ AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_START_DLP_FILES, ERROR_MSG_NOT_SUPPORT_START_DLP_FILES },
};
static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP {
@@ -239,6 +259,7 @@ static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP
{ABILITY_VISIBLE_FALSE_DENY_REQUEST, AbilityErrorCode::ERROR_CODE_NO_INVISIBLE_PERMISSION},
{ERR_STATIC_CFG_PERMISSION, AbilityErrorCode::ERROR_CODE_STATIC_CFG_PERMISSION},
{ERR_CROSS_USER, AbilityErrorCode::ERROR_CODE_CROSS_USER},
{START_UI_ABILITIES_NOT_SUPPORT_CROSS_USER, AbilityErrorCode::ERROR_CODE_CROSS_USER},
{ERR_CROWDTEST_EXPIRED, AbilityErrorCode::ERROR_CODE_CROWDTEST_EXPIRED},
{ERR_WOULD_BLOCK, AbilityErrorCode::ERROR_CODE_WUKONG_MODE},
{ERR_INVALID_CONTINUATION_FLAG, AbilityErrorCode::ERROR_CODE_CONTINUATION_FLAG},
@@ -299,6 +320,8 @@ static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP
{ERR_UPPER_LIMIT, AbilityErrorCode::ERROR_CODE_UPPER_LIMIT},
{ERR_APP_INSTANCE_KEY_NOT_SUPPORT, AbilityErrorCode::ERROR_CODE_APP_INSTANCE_KEY_NOT_SUPPORT},
{ERR_CREATE_NEW_INSTANCE_NOT_SUPPORT, AbilityErrorCode::ERROR_CODE_CREATE_NEW_INSTANCE_NOT_SUPPORT},
{START_UI_ABILITIES_NOT_SUPPORT_CREATE_APP_INSTANCE_KEY,
AbilityErrorCode::ERROR_CODE_CREATE_NEW_INSTANCE_NOT_SUPPORT},
{ERR_UI_ABILITY_IS_STARTING, AbilityErrorCode::ERROR_CODE_UI_ABILITY_IS_STARTING},
{ERR_EXTENSION_START_ABILITY_CONTROLEED, AbilityErrorCode::ERROR_CODE_EXTENSION_START_ABILITY_CONTROLLED},
{ERR_NOT_HOOK, AbilityErrorCode::ERROR_CODE_NOT_HOOK},
@@ -321,6 +344,13 @@ static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP
{ERR_NOT_ISOLATION_PROCESS, AbilityErrorCode::ERROR_CODE_NOT_ISOLATION_PROCESS},
{ERR_ALREADY_MASTER_PROCESS, AbilityErrorCode::ERROR_CODE_ALREADY_MASTER_PROCESS},
{ERR_NOT_CANDIDATE_MASTER_PROCESS, AbilityErrorCode::ERROR_CODE_NOT_CANDIDATE_MASTER_PROCESS},
{START_UI_ABILITIES_WANT_LIST_SIZE_ERROR, AbilityErrorCode::ERROR_CODE_EXCEEDS_WANT_LIST_MAXIMUM_SIZE },
{START_UI_ABILITIES_ONLY_SUPPORT_UI_ABILITY, AbilityErrorCode::ERROR_CODE_TARGET_TYPE_NOT_UI_ABILITY },
{START_UI_ABILITIES_INTERCEPTOR_CHECK_FAILED, AbilityErrorCode::ERROR_CODE_TARGET_BLOCKED_BY_SYSTEM_MODULE },
{START_UI_ABILITIES_NOT_SUPPORT_IMPLICIT_START, AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_IMPLICIT_START },
{START_UI_ABILITIES_NOT_SUPPORT_OPERATE_REMOTE, AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_START_REMOTE_UI_ABILITY },
{START_UI_ABILITIES_NOT_SUPPORT_START_PLUGIN, AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_START_PLUGIN_UI_ABILITY },
{START_UI_ABILITIES_NOT_SUPPORT_DLP, AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_START_DLP_FILES },
};
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -301,5 +301,9 @@ void AbilityThread::ScheduleAbilityRequestSuccess(const std::string &requestId,
{
TAG_LOGD(AAFwkTag::ABILITY, "called");
}
void AbilityThread::ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode)
{
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -22,6 +22,7 @@
#include "freeze_util.h"
#include "hilog_tag_wrapper.h"
#include "hitrace_meter.h"
#include "js_start_abilities_observer.h"
#include "ui_extension_utils.h"
namespace OHOS {
@@ -576,6 +577,28 @@ void ExtensionAbilityThread::SendResult(int requestCode, int resultCode, const W
TAG_LOGD(AAFwkTag::EXT, "End");
}
void ExtensionAbilityThread::ScheduleAbilitiesRequestDone(const std::string &requestKey,
const int32_t resultCode)
{
TAG_LOGD(AAFwkTag::EXT, "ScheduleAbilitiesRequestDone");
if (abilityHandler_ == nullptr) {
TAG_LOGE(AAFwkTag::EXT, "null abilityHandler_");
return;
}
wptr<ExtensionAbilityThread> weak = this;
auto task = [weak, requestKey, resultCode]() {
auto abilityThread = weak.promote();
if (abilityThread == nullptr) {
TAG_LOGE(AAFwkTag::EXT, "null abilityThread");
return;
}
JsStartAbilitiesObserver::GetInstance().HandleFinished(requestKey, resultCode);
};
abilityHandler_->PostTask(task);
}
void ExtensionAbilityThread::NotifyMemoryLevel(int32_t level)
{
TAG_LOGD(AAFwkTag::EXT, "result: %{public}d", level);
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2025 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 "js_deferred_callback.h"
#include "ability_manager_errors.h"
#include "ability_business_error.h"
#include "hilog_tag_wrapper.h"
#include "js_error_utils.h"
#include "js_runtime_utils.h"
namespace OHOS {
namespace AbilityRuntime {
JsDeferredCallback::JsDeferredCallback(napi_env env): env_(env)
{
if (env_ == nullptr) {
TAG_LOGE(AAFwkTag::ABILITY, "null env_");
return;
}
napi_create_promise(env_, &deferred_, &result);
}
void JsDeferredCallback::operator()(int32_t resultCode)
{
if (deferred_ == nullptr) {
TAG_LOGE(AAFwkTag::ABILITY, "null deferred_");
return;
}
if (resultCode == ERR_OK) {
napi_value value = CreateJsUndefined(env_);
napi_resolve_deferred(env_, deferred_, value);
} else {
napi_value error = CreateJsError(env_, GetJsErrorCodeByNativeError(resultCode));
napi_reject_deferred(env_, deferred_, error);
}
}
} // namespace AbilityRuntime
} // namespace OHOS
@@ -24,8 +24,10 @@
#include "js_extension_context.h"
#include "js_error_utils.h"
#include "js_data_struct_converter.h"
#include "js_deferred_callback.h"
#include "js_runtime.h"
#include "js_runtime_utils.h"
#include "js_start_abilities_observer.h"
#include "napi/native_api.h"
#include "napi_common_ability.h"
#include "napi_common_want.h"
@@ -45,6 +47,7 @@ constexpr int32_t INDEX_ZERO = 0;
constexpr int32_t INDEX_ONE = 1;
constexpr int32_t INDEX_TWO = 2;
constexpr int32_t INDEX_THREE = 3;
constexpr int32_t INDEX_FOUR = 4;
constexpr int32_t ERROR_CODE_ONE = 1;
constexpr int32_t ERROR_CODE_TWO = 2;
constexpr size_t ARGC_ZERO = 0;
@@ -128,6 +131,11 @@ public:
GET_NAPI_INFO_AND_CALL(env, info, JsServiceExtensionContext, OnStartAbilityWithAccount);
}
static napi_value StartUIAbilities(napi_env env, napi_callback_info info)
{
GET_NAPI_INFO_AND_CALL(env, info, JsServiceExtensionContext, OnStartUIAbilities);
}
static napi_value ConnectAbilityWithAccount(napi_env env, napi_callback_info info)
{
GET_NAPI_INFO_AND_CALL(env, info, JsServiceExtensionContext, OnConnectAbilityWithAccount);
@@ -809,6 +817,84 @@ private:
return true;
}
napi_value OnStartUIAbilities(napi_env env, NapiCallbackInfo& info)
{
TAG_LOGI(AAFwkTag::SERVICE_EXT, "call OnStartUIAbilities");
if (info.argc < ARGC_ONE) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Too few parameters.");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::vector<AAFwk::Want> wantList;
std::string requestKey = std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::
system_clock::now().time_since_epoch()).count());
if (!UnwrapWantList(env, info, wantList)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Unwrap wantList param failed.");
return CreateJsUndefined(env);
}
TAG_LOGD(AAFwkTag::SERVICE_EXT, "startUIAbilities wantListLength: %{public}zu", wantList.size());
JsDeferredCallback callback(env);
JsStartAbilitiesObserver::GetInstance().AddObserver(requestKey, callback);
auto innerErrCode = std::make_shared<ErrCode>(ERR_OK);
NapiAsyncTask::ExecuteCallback execute = [weak = context_, wantList, requestKey, innerErrCode]() {
auto context = weak.lock();
if (!context) {
TAG_LOGW(AAFwkTag::SERVICE_EXT, "null context");
*innerErrCode = static_cast<int>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
return;
}
*innerErrCode = context->StartUIAbilities(wantList, requestKey);
};
NapiAsyncTask::CompleteCallback complete = [innerErrCode, weak = context_, requestKey]
(napi_env, NapiAsyncTask&, int32_t) {
TAG_LOGI(AAFwkTag::SERVICE_EXT, "startUIAbilities complete innerErrCode: %{public}d", *innerErrCode);
if (*innerErrCode == AAFwk::START_UI_ABILITIES_WAITING_SPECIFIED_CODE) {
TAG_LOGI(AAFwkTag::SERVICE_EXT, "startUIAbilities waiting specified.");
return;
}
JsStartAbilitiesObserver::GetInstance().HandleFinished(requestKey, *innerErrCode);
};
NapiAsyncTask::ScheduleHighQos("JSServiceExtensionContext::OnStartUIAbilities", env,
CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), nullptr));
return callback.result;
}
bool UnwrapWantList(napi_env env, NapiCallbackInfo &info, std::vector<AAFwk::Want> &wantList)
{
AppExecFwk::ComplexArrayData jsWantList;
if (!AppExecFwk::UnwrapArrayComplexFromJS(env, info.argv[INDEX_ZERO], jsWantList)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "wantList not array.");
ThrowInvalidParamError(env, "WantList is not an array.");
return false;
}
size_t jsWantSize = jsWantList.objectList.size();
if (jsWantSize < INDEX_ONE || jsWantSize > INDEX_FOUR) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "wantList size not support");
ThrowErrorByNativeErr(env, AAFwk::START_UI_ABILITIES_WANT_LIST_SIZE_ERROR);
return false;
}
for (uint32_t index = 0; index < jsWantSize; index++) {
AAFwk::Want curWant;
if (!OHOS::AppExecFwk::UnwrapWant(env, jsWantList.objectList[index], curWant)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "startUIAbilities parse want failed");
ThrowInvalidParamError(env, "Parse param want failed, want must be Want.");
return false;
}
TAG_LOGD(AAFwkTag::SERVICE_EXT, "startUIAbilities ability:%{public}s",
curWant.GetElement().GetAbilityName().c_str());
wantList.emplace_back(curWant);
}
return true;
}
bool CheckConnectAbilityWithAccountInputParam(
napi_env env, NapiCallbackInfo& info,
AAFwk::Want& want, int32_t& accountId, sptr<JSServiceExtensionConnection>& connection) const
@@ -1470,12 +1556,12 @@ napi_value CreateJsServiceExtensionContext(napi_env env, std::shared_ptr<Service
moduleName, JsServiceExtensionContext::DisconnectAbility);
BindNativeFunction(env, object, "startAbilityWithAccount",
moduleName, JsServiceExtensionContext::StartAbilityWithAccount);
BindNativeFunction(env, object, "startUIAbilities", moduleName, JsServiceExtensionContext::StartUIAbilities);
BindNativeFunction(env, object, "startAbilityByCall",
moduleName, JsServiceExtensionContext::StartAbilityByCall);
BindNativeFunction(
env, object, "connectAbilityWithAccount", moduleName, JsServiceExtensionContext::ConnectAbilityWithAccount);
BindNativeFunction(
env, object,
BindNativeFunction(env, object,
"connectServiceExtensionAbilityWithAccount", moduleName, JsServiceExtensionContext::ConnectAbilityWithAccount);
BindNativeFunction(env, object, "startServiceExtensionAbility", moduleName,
JsServiceExtensionContext::StartServiceExtensionAbility);
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2025 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 "js_start_abilities_observer.h"
#include "hilog_tag_wrapper.h"
namespace OHOS {
namespace AbilityRuntime {
JsStartAbilitiesObserver &JsStartAbilitiesObserver::GetInstance()
{
static JsStartAbilitiesObserver instance;
return instance;
}
void JsStartAbilitiesObserver::AddObserver(const std::string &requestKey, std::function<void(int32_t)> &&callback)
{
std::lock_guard lock(jsObserverObjectListLock_);
jsObserverObjectList_.emplace(requestKey, std::move(callback));
}
void JsStartAbilitiesObserver::HandleFinished(const std::string &requestKey, int32_t resultCode)
{
std::function<void(int32_t)> callback;
{
std::lock_guard lock(jsObserverObjectListLock_);
auto it = jsObserverObjectList_.find(requestKey);
if (it != jsObserverObjectList_.end()) {
callback = std::move(it->second);
jsObserverObjectList_.erase(it);
}
}
if (callback) {
callback(resultCode);
return;
}
TAG_LOGE(AAFwkTag::ABILITY, "null callback");
}
} // namespace AbilityRuntime
} // namespace OHOS
@@ -26,8 +26,10 @@
#include "js_extension_context.h"
#include "js_error_utils.h"
#include "js_data_struct_converter.h"
#include "js_deferred_callback.h"
#include "js_runtime.h"
#include "js_runtime_utils.h"
#include "js_start_abilities_observer.h"
#include "js_uiservice_uiext_connection.h"
#include "js_ui_service_proxy.h"
#include "napi/native_api.h"
@@ -51,6 +53,7 @@ constexpr int32_t INDEX_ZERO = 0;
constexpr int32_t INDEX_ONE = 1;
constexpr int32_t INDEX_TWO = 2;
constexpr int32_t INDEX_THREE = 3;
constexpr int32_t INDEX_FOUR = 4;
constexpr size_t ARGC_ZERO = 0;
constexpr size_t ARGC_ONE = 1;
constexpr size_t ARGC_TWO = 2;
@@ -144,6 +147,11 @@ napi_value JsUIExtensionContext::StartAbilityForResultAsCaller(napi_env env, nap
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContext, OnStartAbilityForResultAsCaller);
}
napi_value JsUIExtensionContext::StartUIAbilities(napi_env env, napi_callback_info info)
{
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContext, OnStartUIAbilities);
}
napi_value JsUIExtensionContext::TerminateSelfWithResult(napi_env env, napi_callback_info info)
{
GET_NAPI_INFO_AND_CALL(env, info, JsUIExtensionContext, OnTerminateSelfWithResult);
@@ -564,6 +572,84 @@ napi_value JsUIExtensionContext::OnStartAbilityForResultAsCaller(napi_env env, N
return result;
}
napi_value JsUIExtensionContext::OnStartUIAbilities(napi_env env, NapiCallbackInfo& info)
{
TAG_LOGI(AAFwkTag::UI_EXT, "call OnStartUIAbilities");
if (info.argc < ARGC_ONE) {
TAG_LOGE(AAFwkTag::UI_EXT, "Too few parameters.");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::vector<AAFwk::Want> wantList;
std::string requestKey = std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::
system_clock::now().time_since_epoch()).count());
if (!UnwrapWantList(env, info, wantList)) {
TAG_LOGE(AAFwkTag::UI_EXT, "Unwrap wantList param failed.");
return CreateJsUndefined(env);
}
TAG_LOGD(AAFwkTag::UI_EXT, "startUIAbilities wantListLength: %{public}zu", wantList.size());
JsDeferredCallback callback(env);
JsStartAbilitiesObserver::GetInstance().AddObserver(requestKey, callback);
auto innerErrCode = std::make_shared<ErrCode>(ERR_OK);
NapiAsyncTask::ExecuteCallback execute = [weak = context_, wantList, requestKey, innerErrCode]() {
auto context = weak.lock();
if (!context) {
TAG_LOGW(AAFwkTag::UI_EXT, "null context");
*innerErrCode = static_cast<int>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
return;
}
*innerErrCode = context->StartUIAbilities(wantList, requestKey);
};
NapiAsyncTask::CompleteCallback complete = [innerErrCode, weak = context_, requestKey]
(napi_env, NapiAsyncTask&, int32_t) {
TAG_LOGI(AAFwkTag::UI_EXT, "startUIAbilities complete innerErrCode: %{public}d", *innerErrCode);
if (*innerErrCode == AAFwk::START_UI_ABILITIES_WAITING_SPECIFIED_CODE) {
TAG_LOGI(AAFwkTag::UI_EXT, "startUIAbilities waiting specified.");
return;
}
JsStartAbilitiesObserver::GetInstance().HandleFinished(requestKey, *innerErrCode);
};
NapiAsyncTask::ScheduleHighQos("JSUIExtensionConnection::OnStartUIAbilities", env,
CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), nullptr));
return callback.result;
}
bool JsUIExtensionContext::UnwrapWantList(napi_env env, NapiCallbackInfo &info, std::vector<AAFwk::Want> &wantList)
{
AppExecFwk::ComplexArrayData jsWantList;
if (!AppExecFwk::UnwrapArrayComplexFromJS(env, info.argv[INDEX_ZERO], jsWantList)) {
TAG_LOGE(AAFwkTag::UI_EXT, "wantList not array.");
ThrowInvalidParamError(env, "WantList is not an array.");
return false;
}
size_t jsWantSize = jsWantList.objectList.size();
if (jsWantSize < INDEX_ONE || jsWantSize > INDEX_FOUR) {
TAG_LOGE(AAFwkTag::UI_EXT, "wantList size not support");
ThrowErrorByNativeErr(env, AAFwk::START_UI_ABILITIES_WANT_LIST_SIZE_ERROR);
return false;
}
for (uint32_t index = 0; index < jsWantSize; index++) {
AAFwk::Want curWant;
if (!OHOS::AppExecFwk::UnwrapWant(env, jsWantList.objectList[index], curWant)) {
TAG_LOGE(AAFwkTag::UI_EXT, "startUIAbilities parse want failed");
ThrowInvalidParamError(env, "Parse param want failed, want must be Want.");
return false;
}
TAG_LOGD(AAFwkTag::UI_EXT, "startUIAbilities ability:%{public}s",
curWant.GetElement().GetAbilityName().c_str());
wantList.emplace_back(curWant);
}
return true;
}
napi_value JsUIExtensionContext::OnConnectAbility(napi_env env, NapiCallbackInfo& info)
{
TAG_LOGD(AAFwkTag::UI_EXT, "called");
@@ -1331,6 +1417,7 @@ napi_value JsUIExtensionContext::CreateJsUIExtensionContext(napi_env env,
BindNativeFunction(env, objValue, "startAbilityForResult", moduleName, StartAbilityForResult);
BindNativeFunction(env, objValue, "terminateSelfWithResult", moduleName, TerminateSelfWithResult);
BindNativeFunction(env, objValue, "startAbilityForResultAsCaller", moduleName, StartAbilityForResultAsCaller);
BindNativeFunction(env, objValue, "startUIAbilities", moduleName, StartUIAbilities);
BindNativeFunction(env, objValue, "connectServiceExtensionAbility", moduleName, ConnectAbility);
BindNativeFunction(env, objValue, "disconnectServiceExtensionAbility", moduleName, DisconnectAbility);
BindNativeFunction(env, objValue, "reportDrawnCompleted", moduleName, ReportDrawnCompleted);
@@ -136,6 +136,13 @@ ErrCode UIExtensionContext::StartServiceExtensionAbility(const AAFwk::Want& want
return ret;
}
ErrCode UIExtensionContext::StartUIAbilities(const std::vector<AAFwk::Want> &wantList, const std::string &requestKey)
{
TAG_LOGD(AAFwkTag::UI_EXT, "call StartUIAbilities");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilities(wantList, requestKey, token_);
return err;
}
ErrCode UIExtensionContext::StartAbilityForResult(const AAFwk::Want &want, int requestCode, RuntimeTask &&task)
{
TAG_LOGD(AAFwkTag::UI_EXT, "begin");
@@ -154,6 +154,14 @@ ErrCode ServiceExtensionContext::StartAbilityWithAccount(
return err;
}
ErrCode ServiceExtensionContext::StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey)
{
TAG_LOGD(AAFwkTag::APPKIT, "call StartUIAbilities");
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartUIAbilities(wantList, requestKey, token_);
return err;
}
ErrCode ServiceExtensionContext::StartServiceExtensionAbility(const AAFwk::Want &want, int32_t accountId) const
{
TAG_LOGD(AAFwkTag::APPKIT, "begin");
@@ -284,6 +284,17 @@ public:
int requestCode = DEFAULT_INVAL_VALUE,
int32_t userId = DEFAULT_INVAL_VALUE);
/**
* Start UI abilities simultaneously.
*
* @param wantList a list of want to start UI abilities.
* @param requestKey, The unique key of this StartUIAbilities request.
* @param callerToken current caller ability token.
* @return Returns ERR_OK if success.
*/
ErrCode StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey, sptr<IRemoteObject> callerToken);
/**
* Start ui session ability with extension session info, send session info to ability manager service.
*
@@ -923,6 +923,36 @@ enum {
*/
ERR_NOT_CANDIDATE_MASTER_PROCESS = 2097366,
/**
* Result (2097370-2097379) for StartUIAbilities Error.
*/
START_UI_ABILITIES_NOT_SUPPORT_DLP = 2097370,
START_UI_ABILITIES_NOT_SUPPORT_START_PLUGIN = 2097371,
START_UI_ABILITIES_NOT_SUPPORT_CREATE_APP_INSTANCE_KEY = 2097372,
START_UI_ABILITIES_NOT_SUPPORT_OPERATE_REMOTE = 2097373,
START_UI_ABILITIES_NOT_SUPPORT_CROSS_USER = 2097374,
START_UI_ABILITIES_NOT_SUPPORT_IMPLICIT_START = 2097375,
START_UI_ABILITIES_ONLY_SUPPORT_UI_ABILITY = 2097376,
START_UI_ABILITIES_INTERCEPTOR_CHECK_FAILED = 2097377,
START_UI_ABILITIES_WAITING_SPECIFIED_CODE = 2097378,
START_UI_ABILITIES_WANT_LIST_SIZE_ERROR = 2097379,
/*
* Result(2097380) for IPC write Int32 failed.
*/
ERR_WRITE_INT32_FAILED = 2097380,
ERR_WRITE_STRING_FAILED = 2097381,
/**
* Native error(3000000) for target bundle not exist.
*/
@@ -304,6 +304,20 @@ public:
return 0;
}
/**
* Start UI abilities simultaneously.
*
* @param wantList a list of want to start UI abilities.
* @param requestKey, The unique key of this StartUIAbilities request.
* @param callerToken current caller ability token.
* @return Returns ERR_OK if success.
*/
virtual ErrCode StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey, sptr<IRemoteObject> callerToken)
{
return 0;
}
/**
* Start ui session ability with extension session info, send session info to ability manager service.
*
@@ -420,6 +420,9 @@ enum class AbilityManagerInterfaceCode {
SET_ON_NEW_WANT_SKIP_SCENARIOS = 1071,
// ipc id for start UI abilities
START_UI_ABILITIES = 1072,
// ipc id for continue ability(1101)
START_CONTINUATION = 1101,
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -312,6 +312,9 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId,
const AppExecFwk::ElementName &element) = 0;
virtual void ScheduleAbilitiesRequestDone(const std::string &requestKey,
int32_t resultCode) = 0;
enum {
// ipc id for scheduling ability to a state of life cycle
SCHEDULE_ABILITY_TRANSACTION = 0,
@@ -413,7 +416,9 @@ public:
SCHEDULE_ABILITY_REQUEST_FAILURE,
SCHEDULE_ABILITY_REQUEST_SUCCESS
SCHEDULE_ABILITY_REQUEST_SUCCESS,
SCHEDULE_ABILITIES_REQUEST_DONE,
};
};
} // namespace AAFwk
@@ -268,6 +268,20 @@ enum class AbilityErrorCode {
ERROR_CODE_NOT_CANDIDATE_MASTER_PROCESS = 16000117,
ERROR_CODE_EXCEEDS_WANT_LIST_MAXIMUM_SIZE = 16000120,
ERROR_CODE_TARGET_TYPE_NOT_UI_ABILITY = 16000121,
ERROR_CODE_TARGET_BLOCKED_BY_SYSTEM_MODULE = 16000122,
ERROR_CODE_NOT_SUPPORT_IMPLICIT_START = 16000123,
ERROR_CODE_NOT_SUPPORT_START_REMOTE_UI_ABILITY = 16000124,
ERROR_CODE_NOT_SUPPORT_START_PLUGIN_UI_ABILITY = 16000125,
ERROR_CODE_NOT_SUPPORT_START_DLP_FILES = 16000126,
// target bundle is not in u1
ERROR_CODE_NO_U1 = 16000204,
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -364,6 +364,8 @@ public:
void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override;
void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override;
sptr<IRemoteObject> token_;
std::shared_ptr<AbilityHandler> abilityHandler_ = nullptr;
std::shared_ptr<EventRunner> runner_ = nullptr;
@@ -135,6 +135,8 @@ public:
void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override;
void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override;
private:
/**
* @brief Dump Ability Info Inner
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2025 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_JS_DEFERRED_CALLBACK_H
#define OHOS_ABILITY_RUNTIME_JS_DEFERRED_CALLBACK_H
#include "native_engine/native_engine.h"
namespace OHOS {
namespace AbilityRuntime {
struct JsDeferredCallback {
public:
explicit JsDeferredCallback(napi_env env);
void operator()(int32_t resultCode);
napi_value result = nullptr;
private:
napi_env env_ = nullptr;
napi_deferred deferred_ = nullptr;
};
} // namespace AbilityRuntime
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_JS_DEFERRED_CALLBACK_H
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2025 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_JS_START_ABILITIES_OBSERVER_H
#define OHOS_ABILITY_RUNTIME_JS_START_ABILITIES_OBSERVER_H
#include <functional>
#include <map>
#include <mutex>
#include <string>
namespace OHOS {
namespace AbilityRuntime {
class JsStartAbilitiesObserver {
public:
static JsStartAbilitiesObserver &GetInstance();
~JsStartAbilitiesObserver() = default;
void AddObserver(const std::string &requestKey, std::function<void(int32_t)> &&callback);
void HandleFinished(const std::string &requestKey, int32_t resultCode);
protected:
JsStartAbilitiesObserver() = default;
private:
std::mutex jsObserverObjectListLock_;
std::map<std::string, std::function<void(int32_t)>> jsObserverObjectList_;
};
} // namespace AbilityRuntime
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_JS_START_ABILITIES_OBSERVER_H
@@ -40,6 +40,7 @@ public:
static napi_value CreateJsUIExtensionContext(napi_env env, std::shared_ptr<UIExtensionContext> context);
static napi_value StartAbilityForResult(napi_env env, napi_callback_info info);
static napi_value StartAbilityForResultAsCaller(napi_env env, napi_callback_info info);
static napi_value StartUIAbilities(napi_env env, napi_callback_info info);
static napi_value ConnectAbility(napi_env env, napi_callback_info info);
static napi_value DisconnectAbility(napi_env env, napi_callback_info info);
static napi_value ReportDrawnCompleted(napi_env env, napi_callback_info info);
@@ -60,6 +61,7 @@ protected:
virtual napi_value OnTerminateSelfWithResult(napi_env env, NapiCallbackInfo& info);
virtual napi_value OnStartAbilityForResult(napi_env env, NapiCallbackInfo& info);
virtual napi_value OnStartAbilityForResultAsCaller(napi_env env, NapiCallbackInfo &info);
virtual napi_value OnStartUIAbilities(napi_env env, NapiCallbackInfo& info);
virtual napi_value OnConnectAbility(napi_env env, NapiCallbackInfo& info);
virtual napi_value OnDisconnectAbility(napi_env env, NapiCallbackInfo& info);
virtual napi_value OnReportDrawnCompleted(napi_env env, NapiCallbackInfo& info);
@@ -93,6 +95,7 @@ private:
const AAFwk::StartOptions &options, size_t unwrapArgc);
void AddFreeInstallObserver(napi_env env, const AAFwk::Want &want, napi_value callback, napi_value* result,
bool isAbilityResult = false, bool isOpenLink = false);
bool UnwrapWantList(napi_env env, NapiCallbackInfo &info, std::vector<AAFwk::Want> &wantList);
bool CreateOpenLinkTask(const napi_env &env, const napi_value &lastParam,
AAFwk::Want &want, int &requestCode);
napi_value OnOpenLink(napi_env env, NapiCallbackInfo& info);
@@ -98,6 +98,8 @@ public:
*/
ErrCode StartServiceExtensionAbility(const AAFwk::Want &want, int32_t accountId = -1);
ErrCode StartUIAbilities(const std::vector<AAFwk::Want> &wantList, const std::string &requestKey);
/**
* Start other ability for result.
*
@@ -122,6 +122,8 @@ public:
ErrCode StartAbilityWithAccount(
const AAFwk::Want &want, int accountId, const AAFwk::StartOptions &startOptions) const;
ErrCode StartUIAbilities(const std::vector<AAFwk::Want> &wantList, const std::string &requestKey);
ErrCode StartServiceExtensionAbility(const AAFwk::Want &want, int32_t accountId = -1) const;
@@ -216,6 +216,17 @@ public:
int requestCode = DEFAULT_INVAL_VALUE,
int32_t userId = DEFAULT_INVAL_VALUE) override;
/**
* Start UI abilities simultaneously.
*
* @param wantList a list of want to start UI abilities.
* @param requestKey, The unique key of this StartUIAbilities request.
* @param callerToken current caller ability token.
* @return Returns ERR_OK if success.
*/
ErrCode StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey, sptr<IRemoteObject> callerToken) override;
/**
* Start ui session ability with extension session info, send session info to ability manager service.
*
@@ -335,6 +335,17 @@ public:
int requestCode = DEFAULT_INVAL_VALUE,
int32_t userId = DEFAULT_INVAL_VALUE) override;
/**
* Start UI abilities simultaneously.
*
* @param wantList a list of want to start UI abilities.
* @param requestKey, The unique key of this StartUIAbilities request.
* @param callerToken current caller ability token.
* @return Returns ERR_OK if success.
*/
ErrCode StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey, sptr<IRemoteObject> callerToken) override;
/**
* Start ui session ability with extension session info, send session info to ability manager service.
*
@@ -1262,8 +1273,6 @@ public:
void RemoveSelectorIdentity(int32_t tokenId);
void SetTargetCloneIndexInSameBundle(const Want &want, sptr<IRemoteObject> callerToken);
virtual int RegisterAbilityFirstFrameStateObserver(const sptr<IAbilityFirstFrameStateObserver> &observer,
const std::string &bundleName) override;
@@ -2545,6 +2554,11 @@ private:
virtual int RegisterSessionHandler(const sptr<IRemoteObject> &object) override;
int32_t StartUIAbilitiesHandleWant(const Want &want, sptr<IRemoteObject> callerToken,
std::vector<AbilityRequest> &abilityRequestList);
int32_t StartUIAbilitiesCheckDlp(const Want &want, sptr<IRemoteObject> callerToken, int32_t userId);
int32_t StartUIAbilitiesInterceptorCheck(const Want &want, AbilityRequest &abilityRequest,
sptr<IRemoteObject> callerToken, int32_t appIndex);
/**
* Start switch user dialog Extension ability.
*/
@@ -296,6 +296,7 @@ private:
int StartAbilityForResultAsCallerInner(MessageParcel &data, MessageParcel &reply);
int StartAbilityForResultAsCallerForOptionsInner(MessageParcel &data, MessageParcel &reply);
int32_t StartUIAbilitiesInner(MessageParcel &data, MessageParcel &reply);
int32_t StartAbilityOnlyUIAbilityInner(MessageParcel &data, MessageParcel &reply);
@@ -1182,6 +1182,7 @@ public:
const std::string &message);
void NotifyAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element);
void NotifyAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode);
void ScheduleCollaborate(const Want &want);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -338,6 +338,8 @@ public:
void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override;
void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override;
private:
bool WriteInterfaceToken(MessageParcel &data);
int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -82,6 +82,7 @@ private:
int CollaborateDataInner(MessageParcel &data);
int ScheduleAbilityRequestFailureInner(MessageParcel &data);
int ScheduleAbilityRequestSuccessInner(MessageParcel &data);
int ScheduleAbilitiesRequestDoneInner(MessageParcel &data);
};
/**
+2 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -89,6 +89,7 @@ public:
void NotifyAbilityRequestFailure(const std::string &requestId, const AppExecFwk::ElementName &element,
const std::string &message);
void NotifyAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element);
void NotifyAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode);
private:
sptr<IAbilityScheduler> GetScheduler();
@@ -46,6 +46,7 @@ struct SpecifiedRequest {
SpecifiedProcessState specifiedProcessState = SpecifiedProcessState::STATE_NONE;
int32_t requestId = 0;
int32_t persistentId = 0;
int32_t requestListId = -1;
uint32_t sceneFlag = 0;
uint32_t callingTokenId = 0;
AbilityRequest abilityRequest;
@@ -53,6 +54,14 @@ struct SpecifiedRequest {
SpecifiedRequest(int32_t requestId, AbilityRequest request) : requestId(requestId), abilityRequest(request) {}
};
struct AbilitiesRequest {
int32_t requestListId = -1;
std::string requestKey;
std::vector<std::pair<int32_t, sptr<SessionInfo>>> sessionInfoList;
uint32_t doneCount = 0;
sptr<IRemoteObject> callerToken;
};
class UIAbilityLifecycleManager : public std::enable_shared_from_this<UIAbilityLifecycleManager> {
public:
UIAbilityLifecycleManager() = default;
@@ -155,6 +164,8 @@ public:
void SetRootSceneSession(const sptr<IRemoteObject> &rootSceneSession);
int NotifySCBToStartUIAbility(AbilityRequest &abilityRequest);
int32_t NotifySCBToStartUIAbilities(std::vector<AbilityRequest> &abilityRequestList,
const std::string &requestKey);
int NotifySCBToPreStartUIAbility(const AbilityRequest &abilityRequest,
sptr<SessionInfo> &sessionInfo);
@@ -429,6 +440,8 @@ private:
sptr<SessionInfo> CreateSessionInfo(const AbilityRequest &abilityRequest) const;
int NotifySCBPendingActivation(sptr<SessionInfo> &sessionInfo,
const AbilityRequest &abilityRequest, std::string &errMsg);
int32_t BatchNotifySCBPendingActivations(const AbilitiesRequest &abilitiesRequest);
void HandleAbilitiesRequestDone(int32_t requestId, int32_t requestListId, sptr<SessionInfo> sessionInfo);
bool IsHookModule(const AbilityRequest &abilityRequest) const;
int ResolveAbility(const std::shared_ptr<AbilityRecord> &targetAbility, const AbilityRequest &abilityRequest) const;
std::vector<std::shared_ptr<AbilityRecord>> GetAbilityRecordsByNameInner(const AppExecFwk::ElementName &element);
@@ -437,11 +450,11 @@ private:
void NotifyStartSpecifiedAbility(AbilityRequest &request, const AAFwk::Want &want);
void NotifyRestartSpecifiedAbility(const AbilityRequest &request, const sptr<IRemoteObject> &token);
int MoveAbilityToFront(const AbilityRequest &abilityRequest, const std::shared_ptr<AbilityRecord> &abilityRecord,
std::shared_ptr<AbilityRecord> callerAbility, std::shared_ptr<StartOptions> startOptions, int32_t requestId);
int32_t MoveAbilityToFront(const SpecifiedRequest &specifiedRequest,
const std::shared_ptr<AbilityRecord> abilityRecord, std::shared_ptr<AbilityRecord> callerAbility);
int SendSessionInfoToSCB(std::shared_ptr<AbilityRecord> &callerAbility, sptr<SessionInfo> &sessionInfo);
int StartAbilityBySpecifed(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &callerAbility,
int32_t requestId);
int32_t StartAbilityBySpecifed(const SpecifiedRequest &specifiedRequest,
std::shared_ptr<AbilityRecord> callerAbility);
void SetLastExitReason(std::shared_ptr<AbilityRecord> &abilityRecord) const;
void SetReceiverInfo(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &abilityRecord) const;
@@ -489,7 +502,7 @@ private:
bool HandleStartSpecifiedCold(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo, uint32_t sceneFlag);
bool HandleColdAcceptWantDone(const AAFwk::Want &want, const std::string &flag,
const SpecifiedRequest &specifiedRequest);
void HandleLegacyAcceptWantDone(AbilityRequest &abilityRequest, int32_t requestId,
void HandleLegacyAcceptWantDone(SpecifiedRequest &specifiedRequest,
const std::string &flag, const AAFwk::Want &want);
std::shared_ptr<SpecifiedRequest> GetSpecifiedRequest(int32_t requestId);
bool CheckPrepareTerminateTokens(const std::vector<sptr<IRemoteObject>> &tokens,
@@ -504,7 +517,11 @@ private:
std::shared_ptr<AbilityRecord> uiAbilityRecord, bool isColdStart);
bool TryProcessHookModule(SpecifiedRequest &specifiedRequest, bool isHookModule);
bool IsStartSpecifiedProcessRequest(const AbilityRequest &abilityRequest);
int32_t StartSpecifiedProcessRequest(const AbilityRequest &abilityRequest);
int32_t StartSpecifiedProcessRequest(const AbilityRequest &abilityRequest,
std::shared_ptr<AbilitiesRequest> abilitiesRequest);
int32_t HandleUIAbilityRequestList(std::vector<AbilityRequest> &abilityRequestList);
void HandleAbilitiesNormalSessionInfo(AbilityRequest &abilityRequest,
std::shared_ptr<AbilitiesRequest> abilitiesRequest, int32_t requestId);
void RemoveInstanceKey(const AbilityRequest &abilityRequest) const;
int32_t userId_ = -1;
@@ -544,6 +561,7 @@ private:
std::vector<std::shared_ptr<PrepareTerminateByPidRecord>> prepareTerminateByPidRecords_;
std::unordered_map<int32_t, std::shared_ptr<AbilityRecord>> hookSpecifiedMap_;
std::map<int32_t, std::shared_ptr<AbilitiesRequest>> abilitiesRequestMap_;
std::mutex startingPidsMutex_;
std::vector<pid_t> startingPids_;
};
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Copyright (c) 2024-2025 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
@@ -59,6 +59,9 @@ struct StartAbilityUtils {
static std::vector<int32_t> GetCloneAppIndexes(const std::string &bundleName, int32_t userId);
static bool IsCallFromAncoShellOrBroker(const sptr<IRemoteObject> &callerToken);
static void SetTargetCloneIndexInSameBundle(const Want &want, sptr<IRemoteObject> callerToken);
static int32_t StartUIAbilitiesProcessAppIndex(Want &want,
sptr<IRemoteObject> callerToken, int32_t &appIndex);
static thread_local std::shared_ptr<StartAbilityInfo> startAbilityInfo;
static thread_local std::shared_ptr<StartAbilityInfo> callerAbilityInfo;
@@ -261,6 +261,19 @@ ErrCode AbilityManagerClient::StartAbilityForResultAsCaller(const Want &want, co
return abms->StartAbilityForResultAsCaller(want, startOptions, callerToken, requestCode, userId);
}
ErrCode AbilityManagerClient::StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey, sptr<IRemoteObject> callerToken)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGI(AAFwkTag::ABILITYMGR, "call StartUIAbilities");
auto abms = GetAbilityManager();
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
for (const Want &item : wantList) {
HandleDlpApp(const_cast<Want &>(item));
}
return abms->StartUIAbilities(wantList, requestKey, callerToken);
}
ErrCode AbilityManagerClient::StartAbilityByUIContentSession(const Want &want, const StartOptions &startOptions,
sptr<IRemoteObject> callerToken, sptr<AAFwk::SessionInfo> sessionInfo,
int requestCode, int32_t userId)
@@ -41,8 +41,11 @@ namespace {
}
using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
constexpr int32_t CYCLE_LIMIT = 1000;
constexpr int32_t INDEX_ONE = 1;
constexpr int32_t MAX_AUTO_STARTUP_COUNT = 100;
constexpr int32_t MAX_UPDATE_CONFIG_SIZE = 100;
constexpr int32_t MAX_WANT_LIST_SIZE = 4;
constexpr int32_t MAX_IPC_CAPACITY_FOR_WANT_LIST = 4 * 216 * 1024;
bool AbilityManagerProxy::WriteInterfaceToken(MessageParcel &data)
{
if (!data.WriteInterfaceToken(AbilityManagerProxy::GetDescriptor())) {
@@ -507,6 +510,58 @@ int AbilityManagerProxy::StartAbilityForResultAsCaller(const Want &want, const S
return reply.ReadInt32();
}
ErrCode AbilityManagerProxy::StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey, sptr<IRemoteObject> callerToken)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (callerToken == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
return INVALID_CALLER_TOKEN;
}
if (!WriteInterfaceToken(data)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
return ERR_WRITE_INTERFACE_TOKEN_FAILED;
}
int32_t size = static_cast<int32_t>(wantList.size());
if (size < INDEX_ONE || size > MAX_WANT_LIST_SIZE) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "vector size error");
return START_UI_ABILITIES_WANT_LIST_SIZE_ERROR;
}
(data).SetMaxCapacity(MAX_IPC_CAPACITY_FOR_WANT_LIST);
if (!data.WriteInt32(size)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write size fail");
return ERR_WRITE_INT32_FAILED;
}
for (const Want &item : wantList) {
if (!data.WriteParcelable(&item)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write want fail");
return ERR_WRITE_WANT;
}
}
if (!data.WriteString(requestKey)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestKey fail");
return ERR_WRITE_STRING_FAILED;
}
if (!data.WriteRemoteObject(callerToken)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write callerToken fail");
return ERR_WRITE_CALLER_TOKEN_FAILED;
}
auto error = SendRequest(AbilityManagerInterfaceCode::START_UI_ABILITIES, data, reply, option);
if (error != NO_ERROR) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
return error;
}
return reply.ReadInt32();
}
int AbilityManagerProxy::CheckUISessionParams(MessageParcel &data, const sptr<IRemoteObject> &callerToken,
const sptr<SessionInfo> &sessionInfo, int32_t userId, int requestCode)
{
@@ -201,6 +201,7 @@ constexpr size_t INDEX_ZERO = 0;
constexpr size_t INDEX_ONE = 1;
constexpr size_t INDEX_TWO = 2;
constexpr size_t ARGC_THREE = 3;
constexpr size_t INDEX_FOUR = 4;
constexpr static char WANT_PARAMS_VIEW_DATA_KEY[] = "ohos.ability.params.viewData";
constexpr const char* WANT_PARAMS_HOST_WINDOW_ID_KEY = "ohos.extra.param.key.hostwindowid";
@@ -1188,7 +1189,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
int32_t oriValidUserId = GetValidUserId(userId);
int32_t validUserId = oriValidUserId;
SetTargetCloneIndexInSameBundle(want, callerToken);
StartAbilityUtils::SetTargetCloneIndexInSameBundle(want, callerToken);
int32_t appIndex = 0;
if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) {
return ERR_APP_CLONE_INDEX_INVALID;
@@ -1909,7 +1910,7 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St
int32_t oriValidUserId = GetValidUserId(userId);
int32_t validUserId = oriValidUserId;
SetTargetCloneIndexInSameBundle(want, callerToken);
StartAbilityUtils::SetTargetCloneIndexInSameBundle(want, callerToken);
int32_t appIndex = 0;
if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) {
return ERR_APP_CLONE_INDEX_INVALID;
@@ -2175,6 +2176,225 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St
return ret;
}
ErrCode AbilityManagerService::StartUIAbilities(const std::vector<AAFwk::Want> &wantList,
const std::string &requestKey, sptr<IRemoteObject> callerToken)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
XCOLLIE_TIMER_DEFAULT(__PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::ABILITYMGR, "Call StartUIAbilities");
std::vector<AbilityRequest> abilityRequestList;
int32_t oriValidUserId = GetValidUserId(DEFAULT_INVAL_VALUE);
if (!AppUtils::GetInstance().IsSupportStartAbilities() ||
!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities is not supported");
return ERR_CAPABILITY_NOT_SUPPORT;
}
if (wantList.size() < INDEX_ONE || wantList.size() > INDEX_FOUR) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities wantList size not support");
return START_UI_ABILITIES_WANT_LIST_SIZE_ERROR;
}
if (callerToken == nullptr || !VerificationAllToken(callerToken)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities %{public}s verificationAllToken failed", __func__);
return ERR_INVALID_CALLER;
}
for (const Want &want : wantList) {
int32_t ret = StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities want process block");
return ret;
}
}
TAG_LOGD(AAFwkTag::ABILITYMGR, "StartUIAbilities ready to NotifySCBToStartUIAbilities");
for (AbilityRequest &abilityRequest : abilityRequestList) {
auto abilityInfo = abilityRequest.abilityInfo;
ReportEventToRSS(abilityInfo, abilityRequest.callerToken);
abilityRequest.userId = oriValidUserId;
abilityRequest.want.SetParam(ServerConstant::IS_CALL_BY_SCB, false);
}
auto uiAbilityManager = GetUIAbilityManagerByUserId(oriValidUserId);
CHECK_POINTER_AND_RETURN(uiAbilityManager, ERR_INVALID_VALUE);
return uiAbilityManager->NotifySCBToStartUIAbilities(abilityRequestList, requestKey);
}
int32_t AbilityManagerService::StartUIAbilitiesHandleWant(const Want &want, sptr<IRemoteObject> callerToken,
std::vector<AbilityRequest> &abilityRequestList)
{
int32_t userId = DEFAULT_INVAL_VALUE;
int32_t validUserId = GetValidUserId(userId);
uint32_t specifyTokenId = 0;
int32_t requestCode = DEFAULT_INVAL_VALUE;
AbilityUtil::RemoveShowModeKey(const_cast<Want &>(want));
if (!want.HasParameter(AppExecFwk::INSIGHT_INTENT_EXECUTE_OPENLINK_FLAG)) {
InsightIntentExecuteParam::RemoveInsightIntent(const_cast<Want &>(want));
}
#ifdef SUPPORT_SCREEN
DmsUtil::GetInstance().UpdateFlagForCollaboration(want);
#endif
if (AbilityRuntime::StartupUtil::IsStartPlugin(want)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities not support StartPlugin");
return START_UI_ABILITIES_NOT_SUPPORT_START_PLUGIN;
}
AbilityUtil::RemoveWindowModeKey(const_cast<Want &>(want));
if (want.GetBoolParam(Want::CREATE_APP_INSTANCE_KEY, false)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities not support CREATE_APP_INSTANCE_KEY");
return START_UI_ABILITIES_NOT_SUPPORT_CREATE_APP_INSTANCE_KEY;
}
int32_t ret = StartUIAbilitiesCheckDlp(want, callerToken, validUserId);
if (ret != ERR_OK) {
return ret;
}
int32_t appIndex = 0;
ret = StartAbilityUtils::StartUIAbilitiesProcessAppIndex(const_cast<Want &>(want), callerToken, appIndex);
if (ret != ERR_OK) {
return ret;
}
ret = AbilityPermissionUtil::GetInstance().CheckMultiInstanceAndAppClone(
const_cast<Want &>(want), validUserId, appIndex, callerToken, false);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities CheckMultiInstanceAndAppClone failed");
return ret;
}
StartAbilityInfoWrap threadLocalInfo(want, validUserId, appIndex, callerToken);
if (CheckIfOperateRemote(want)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities not support StartRemoteAbility");
return START_UI_ABILITIES_NOT_SUPPORT_OPERATE_REMOTE;
}
if (!JudgeMultiUserConcurrency(validUserId)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities multi-user non-concurrent unsatisfied");
return START_UI_ABILITIES_NOT_SUPPORT_CROSS_USER;
}
#ifdef SUPPORT_SCREEN
if (ImplicitStartProcessor::IsImplicitStartAction(want)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities not support implicit start");
return START_UI_ABILITIES_NOT_SUPPORT_IMPLICIT_START;
}
#endif
AbilityRequest abilityRequest;
auto result = GenerateAbilityRequest(want, requestCode, abilityRequest, callerToken, validUserId);
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
std::string callerBundleName = abilityRecord ? abilityRecord->GetAbilityInfo().bundleName : "";
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "generate ability request local error");
return result;
}
UpdateCallerInfoUtil::GetInstance().UpdateCallerInfo(abilityRequest.want, callerToken);
auto abilityInfo = abilityRequest.abilityInfo;
if (abilityInfo.type != AbilityType::PAGE) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities only support UIAbility");
return START_UI_ABILITIES_ONLY_SUPPORT_UI_ABILITY;
}
result = CheckStaticCfgPermission(abilityRequest, false,
abilityRequest.want.GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, 0), false, false, false);
if (result != AppExecFwk::Constants::PERMISSION_GRANTED) {
TAG_LOGE(AAFwkTag::ABILITYMGR,
"StartUIAbilities checkStaticCfgPermission error, result:%{public}d", result);
return ERR_STATIC_CFG_PERMISSION;
}
result = CheckCallPermission(want, abilityInfo, abilityRequest, false,
false, specifyTokenId, callerBundleName);
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR,
"StartUIAbilities checkCallPermission error, result:%{public}d", result);
return result;
}
result = StartUIAbilitiesInterceptorCheck(want, abilityRequest, callerToken, appIndex);
if (result != ERR_OK) {
return result;
}
Want newWant = abilityRequest.want;
bool isReplaceWantExist = newWant.GetBoolParam("queryWantFromErms", false);
newWant.RemoveParam("queryWantFromErms");
auto callerTokenId = IPCSkeleton::GetCallingTokenID();
RemoveUnauthorizedLaunchReasonMessage(want, abilityRequest, callerTokenId);
if (!IsAbilityControllerStart(want, abilityInfo.bundleName)) {
TAG_LOGE(AAFwkTag::ABILITYMGR,
"StartUIAbilities isAbilityControllerStart failed:%{public}s", abilityInfo.bundleName.c_str());
return ERR_WOULD_BLOCK;
}
abilityRequest.want.RemoveParam(SPECIFY_TOKEN_ID);
abilityRequest.want.RemoveParam(PARAM_SPECIFIED_PROCESS_FLAG);
abilityRequestList.emplace_back(abilityRequest);
return ERR_OK;
}
int32_t AbilityManagerService::StartUIAbilitiesCheckDlp(const Want &want, sptr<IRemoteObject> callerToken,
int32_t userId)
{
#ifdef WITH_DLP
if (AbilityUtil::HandleDlpApp(const_cast<Want &>(want))) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities not support Dlp");
return START_UI_ABILITIES_NOT_SUPPORT_DLP;
}
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "CHECK_DLP");
if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, want) ||
VerifyAccountPermission(userId) == CHECK_PERMISSION_FAILED ||
!DlpUtils::DlpAccessOtherAppsCheck(callerToken, want)) {
TAG_LOGE(AAFwkTag::ABILITYMGR,
"StartUIAbilities Dlp %{public}s: permission verification failed", __func__);
return CHECK_PERMISSION_FAILED;
}
#endif // WITH_DLP
return ERR_OK;
}
int32_t AbilityManagerService::StartUIAbilitiesInterceptorCheck(const Want &want, AbilityRequest &abilityRequest,
sptr<IRemoteObject> callerToken, int32_t appIndex)
{
int32_t requestCode = DEFAULT_INVAL_VALUE;
Want newWant = abilityRequest.want;
auto abilityInfo = abilityRequest.abilityInfo;
auto shouldBlockFunc = [aams = shared_from_this()]() { return aams->ShouldBlockAllAppStart(); };
AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, requestCode, GetUserId(),
true, nullptr, shouldBlockFunc);
int32_t result = interceptorExecuter_ == nullptr ? ERR_NULL_INTERCEPTOR_EXECUTER :
interceptorExecuter_->DoProcess(interceptorParam);
if (result == ERR_CROWDTEST_EXPIRED) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities ERR_CROWDTEST_EXPIRED");
return result;
}
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities interceptorExecuter_ null or DoProcess error");
return START_UI_ABILITIES_INTERCEPTOR_CHECK_FAILED;
}
AbilityInterceptorParam afterCheckParam = AbilityInterceptorParam(newWant, requestCode, GetUserId(),
true, callerToken, std::make_shared<AppExecFwk::AbilityInfo>(abilityInfo), false, appIndex);
result = afterCheckExecuter_ == nullptr ? ERR_INVALID_VALUE :
afterCheckExecuter_->DoProcess(afterCheckParam);
if (result == ERR_CROWDTEST_EXPIRED) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities ERR_CROWDTEST_EXPIRED");
return result;
}
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities afterCheckExecuter_ null or DoProcess error");
return START_UI_ABILITIES_INTERCEPTOR_CHECK_FAILED;
}
return ERR_OK;
}
int32_t AbilityManagerService::RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
@@ -12330,24 +12550,6 @@ void AbilityManagerService::RemoveSelectorIdentity(int32_t tokenId)
implicitStartProcessor_->RemoveIdentity(tokenId);
}
void AbilityManagerService::SetTargetCloneIndexInSameBundle(const Want &want, sptr<IRemoteObject> callerToken)
{
auto callerRecord = Token::GetAbilityRecordByToken(callerToken);
CHECK_POINTER(callerRecord);
if (callerRecord->GetAbilityInfo().bundleName != want.GetElement().GetBundleName()) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "not the same bundle");
return;
}
if (want.HasParameter(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY)) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "want with app clone index.");
return;
}
int32_t appIndex = callerRecord->GetApplicationInfo().appIndex;
if (appIndex >= 0 && appIndex < AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
(const_cast<Want &>(want)).SetParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, appIndex);
}
}
void AbilityManagerService::RemoveLauncherDeathRecipient(int32_t userId)
{
auto connectManager = GetConnectManagerByUserId(userId);
@@ -32,8 +32,10 @@ using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
namespace {
const std::u16string extensionDescriptor = u"ohos.aafwk.ExtensionManager";
constexpr int32_t CYCLE_LIMIT = 1000;
constexpr int32_t INDEX_ONE = 1;
constexpr int32_t MAX_KILL_PROCESS_PID_COUNT = 100;
constexpr int32_t MAX_UPDATE_CONFIG_SIZE = 100;
constexpr int32_t MAX_WANT_LIST_SIZE = 4;
} // namespace
AbilityManagerStub::AbilityManagerStub()
{}
@@ -578,6 +580,9 @@ int AbilityManagerStub::OnRemoteRequestInnerFourteenth(uint32_t code, MessagePar
if (interfaceCode == AbilityManagerInterfaceCode::CLOSE_UI_EXTENSION_ABILITY_BY_SCB) {
return CloseUIExtensionAbilityBySCBInner(data, reply);
}
if (interfaceCode == AbilityManagerInterfaceCode::START_UI_ABILITIES) {
return StartUIAbilitiesInner(data, reply);
}
return ERR_CODE_NOT_EXIST;
}
@@ -3865,6 +3870,38 @@ int AbilityManagerStub::StartAbilityForResultAsCallerInner(MessageParcel &data,
return NO_ERROR;
}
int32_t AbilityManagerStub::StartUIAbilitiesInner(MessageParcel &data, MessageParcel &reply)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "call StartUIAbilitiesInner");
std::vector<Want> wantList;
int32_t size = data.ReadInt32();
if (size < INDEX_ONE || size > MAX_WANT_LIST_SIZE) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "vector size error");
return START_UI_ABILITIES_WANT_LIST_SIZE_ERROR;
}
for (auto i = 0; i < size; i++) {
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (want == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "null want");
return ERR_NATIVE_IPC_PARCEL_FAILED;
}
wantList.emplace_back(*want);
}
std::string requestKey = data.ReadString();
sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
if (callerToken == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
return INVALID_CALLER_TOKEN;
}
int32_t result = StartUIAbilities(wantList, requestKey, callerToken);
reply.WriteInt32(result);
return NO_ERROR;
}
int AbilityManagerStub::StartAbilityForResultAsCallerForOptionsInner(MessageParcel &data, MessageParcel &reply)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
@@ -3879,6 +3879,12 @@ void AbilityRecord::NotifyAbilityRequestSuccess(const std::string &requestId, co
lifecycleDeal_->NotifyAbilityRequestSuccess(requestId, element);
}
void AbilityRecord::NotifyAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode)
{
CHECK_POINTER(lifecycleDeal_);
lifecycleDeal_->NotifyAbilitiesRequestDone(requestKey, resultCode);
}
void AbilityRecord::UpdateUIExtensionBindInfo(const WantParams &wantParams)
{
if (!UIExtensionUtils::IsUIExtension(GetAbilityInfo().extensionAbilityType)) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -1294,5 +1294,31 @@ void AbilitySchedulerProxy::ScheduleAbilityRequestSuccess(const std::string &req
}
return;
}
void AbilitySchedulerProxy::ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode)
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!WriteInterfaceToken(data)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token failed");
return;
}
if (!data.WriteString(requestKey)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestKey failed");
return;
}
if (!data.WriteInt32(resultCode)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "write resultCode failed");
return;
}
int32_t err = SendTransactCmd(IAbilityScheduler::SCHEDULE_ABILITIES_REQUEST_DONE, data, reply, option);
if (err != NO_ERROR) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, err: %{public}d", err);
}
return;
}
} // namespace AAFwk
} // namespace OHOS
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -160,6 +160,8 @@ int AbilitySchedulerStub::OnRemoteRequestInnerThird(
return ScheduleAbilityRequestFailureInner(data);
case SCHEDULE_ABILITY_REQUEST_SUCCESS:
return ScheduleAbilityRequestSuccessInner(data);
case SCHEDULE_ABILITIES_REQUEST_DONE:
return ScheduleAbilitiesRequestDoneInner(data);
}
return ERR_CODE_NOT_EXIST;
}
@@ -780,6 +782,14 @@ int AbilitySchedulerStub::ScheduleAbilityRequestSuccessInner(MessageParcel &data
return NO_ERROR;
}
int AbilitySchedulerStub::ScheduleAbilitiesRequestDoneInner(MessageParcel &data)
{
std::string requestKey = data.ReadString();
int32_t resultCode = data.ReadInt32();
ScheduleAbilitiesRequestDone(requestKey, resultCode);
return NO_ERROR;
}
void AbilitySchedulerRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
{
TAG_LOGE(AAFwkTag::ABILITYMGR, "call");
+8 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 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
@@ -215,5 +215,12 @@ void LifecycleDeal::NotifyAbilityRequestSuccess(const std::string &requestId, co
CHECK_POINTER(abilityScheduler);
abilityScheduler->ScheduleAbilityRequestSuccess(requestId, element);
}
void LifecycleDeal::NotifyAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode)
{
auto abilityScheduler = GetScheduler();
CHECK_POINTER(abilityScheduler);
abilityScheduler->ScheduleAbilitiesRequestDone(requestKey, resultCode);
}
} // namespace AAFwk
} // namespace OHOS
@@ -70,6 +70,7 @@ constexpr int32_t MAX_FIND_UIEXTENSION_CALLER_TIMES = 10;
constexpr int32_t START_UI_ABILITY_PER_SECOND_UPPER_LIMIT = 20;
constexpr int32_t API20 = 20;
constexpr int32_t API_VERSION_MOD = 100;
constexpr int32_t REQUEST_LIST_ID_INIT = -1;
constexpr const char* IS_CALLING_FROM_DMS = "supportCollaborativeCallingFromDmsInAAFwk";
constexpr int REMOVE_STARTING_BUNDLE_TIMEOUT_MICRO_SECONDS = 5000000; // 5s
@@ -594,7 +595,7 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(AbilityRequest &ability
return StartWithPersistentIdByDistributed(abilityRequest, persistentId);
}
if (IsStartSpecifiedProcessRequest(abilityRequest)) {
return StartSpecifiedProcessRequest(abilityRequest);
return StartSpecifiedProcessRequest(abilityRequest, nullptr);
}
const auto &abilityInfo = abilityRequest.abilityInfo;
auto requestId = RequestIdUtil::GetRequestId();
@@ -644,12 +645,183 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(AbilityRequest &ability
return ret;
}
int UIAbilityLifecycleManager::NotifySCBToStartUIAbilities(std::vector<AbilityRequest> &abilityRequestList,
const std::string &requestKey)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::ABILITYMGR, "Call NotifySCBToStartUIAbilities");
int32_t ret = HandleUIAbilityRequestList(abilityRequestList);
if (ret != ERR_OK) {
return ret;
}
std::lock_guard guard(sessionLock_);
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
int32_t requestListId = RequestIdUtil::GetRequestId();
abilitiesRequest->requestListId = requestListId;
abilitiesRequestMap_.emplace(requestListId, abilitiesRequest);
abilitiesRequest->requestKey = requestKey;
for (AbilityRequest &abilityRequest : abilityRequestList) {
abilitiesRequest->callerToken = abilityRequest.callerToken;
if (IsStartSpecifiedProcessRequest(abilityRequest)) {
ret = StartSpecifiedProcessRequest(abilityRequest, abilitiesRequest);
if (ret != ERR_OK) {
return ret;
}
continue;
}
const auto &abilityInfo = abilityRequest.abilityInfo;
auto requestId = RequestIdUtil::GetRequestId();
if (abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED) {
auto specifiedRequest = std::make_shared<SpecifiedRequest>(requestId, abilityRequest);
specifiedRequest->preCreateProcessName = true;
specifiedRequest->requestListId = abilitiesRequest->requestListId;
abilitiesRequest->sessionInfoList.emplace_back(requestId, nullptr);
AddSpecifiedRequest(specifiedRequest);
continue;
}
HandleAbilitiesNormalSessionInfo(abilityRequest, abilitiesRequest, requestId);
}
if (abilitiesRequest->doneCount < abilityRequestList.size()) {
return START_UI_ABILITIES_WAITING_SPECIFIED_CODE;
}
TAG_LOGI(AAFwkTag::ABILITYMGR, "StartUIAbilities normal, size: %{public}zu", abilityRequestList.size());
ret = BatchNotifySCBPendingActivations(*abilitiesRequest);
for (auto &[id, sessionInfo] : abilitiesRequest->sessionInfoList) {
sessionInfo->want.RemoveAllFd();
}
abilitiesRequestMap_.erase(requestListId);
return ret;
}
int32_t UIAbilityLifecycleManager::HandleUIAbilityRequestList(std::vector<AbilityRequest> &abilityRequestList)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "Call HandleUIAbilityRequestList");
for (AbilityRequest &abilityRequest : abilityRequestList) {
if (!AddStartCallerTimestamp(abilityRequest.want.GetIntParam(Want::PARAM_RESV_CALLER_UID, -1))) {
return ERR_INVALID_VALUE;
}
abilityRequest.want.SetParam(IS_SHELL_CALL, AAFwk::PermissionVerification::GetInstance()->IsShellCall());
std::string callerKey = std::to_string(IPCSkeleton::GetCallingPid()) + ":" +
std::to_string(IPCSkeleton::GetCallingUid());
bool isCallerKilling = IN_PROCESS_CALL(
DelayedSingleton<AppScheduler>::GetInstance()->IsCallerKilling(callerKey));
if (isCallerKilling) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities caller is killing");
return ERR_INVALID_VALUE;
}
abilityRequest.want.SetParam(Want::PARAMS_REAL_CALLER_KEY, callerKey);
}
return ERR_OK;
}
void UIAbilityLifecycleManager::HandleAbilitiesNormalSessionInfo(AbilityRequest &abilityRequest,
std::shared_ptr<AbilitiesRequest> abilitiesRequest, int32_t requestId)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "Call HandleAbilitiesNormalSessionInfo");
const auto &abilityInfo = abilityRequest.abilityInfo;
auto sessionInfo = CreateSessionInfo(abilityRequest);
sessionInfo->requestCode = abilityRequest.requestCode;
sessionInfo->requestId = requestId;
sessionInfo->persistentId = GetPersistentIdByAbilityRequest(abilityRequest, sessionInfo->reuse);
sessionInfo->userId = userId_;
sessionInfo->isAtomicService = (abilityInfo.applicationInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE);
TAG_LOGI(AAFwkTag::ABILITYMGR, "Reused sessionId: %{public}d, userId: %{public}d, requestId: %{public}d",
sessionInfo->persistentId, userId_, requestId);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
abilitiesRequest->doneCount++;
}
int32_t UIAbilityLifecycleManager::BatchNotifySCBPendingActivations(const AbilitiesRequest &abilitiesRequest)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "Call BatchNotifySCBPendingActivations");
std::vector<sptr<SessionInfo>> sessionInfoList;
for (const auto &[id, sessionInfo] : abilitiesRequest.sessionInfoList) {
if (sessionInfo == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionInfo nullptr");
continue;
}
sessionInfoList.push_back(sessionInfo);
bool hasStartWindowOption = (sessionInfo->startWindowOption != nullptr);
bool hasStartWindow = hasStartWindowOption ? sessionInfo->startWindowOption->hasStartWindow : false;
std::string backgroundColor =
hasStartWindowOption ? sessionInfo->startWindowOption->startWindowBackgroundColor : "";
TAG_LOGI(AAFwkTag::ABILITYMGR, "appCloneIndex:%{public}d, instanceKey:%{public}s, "
"hasStartWindow:%{public}d, backgroundColor:%{public}s",
(sessionInfo->want).GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0), sessionInfo->instanceKey.c_str(),
hasStartWindow, backgroundColor.c_str());
}
auto callerAbilityRecord = GetAbilityRecordByToken(abilitiesRequest.callerToken);
if (callerAbilityRecord == nullptr || callerAbilityRecord->GetRestartAppFlag()) {
auto tmpSceneSession = iface_cast<Rosen::ISession>(rootSceneSession_);
if (tmpSceneSession == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "null tmpSceneSession, scb does not exist");
return ERR_INVALID_VALUE;
}
for (auto sessionInfo : sessionInfoList) {
sessionInfo->canStartAbilityFromBackground = true;
}
TAG_LOGI(AAFwkTag::ABILITYMGR,
"scb call, StartUIAbilities BatchPendingSessionsActivation for rootSceneSession");
return static_cast<int>(tmpSceneSession->BatchPendingSessionsActivation(sessionInfoList));
}
auto callerSessionInfo = callerAbilityRecord->GetSessionInfo();
CHECK_POINTER_AND_RETURN(callerSessionInfo, ERR_INVALID_VALUE);
CHECK_POINTER_AND_RETURN(callerSessionInfo->sessionToken, ERR_INVALID_VALUE);
auto callerSession = iface_cast<Rosen::ISession>(callerSessionInfo->sessionToken);
CHECK_POINTER_AND_RETURN(callerSession, ERR_INVALID_VALUE);
for (auto sessionInfo : sessionInfoList) {
CheckCallerFromBackground(callerAbilityRecord, sessionInfo);
auto requestId = sessionInfo->want.GetStringParam(KEY_REQUEST_ID);
if (!requestId.empty()) {
callerAbilityRecord->NotifyAbilityRequestSuccess(requestId, sessionInfo->want.GetElement());
}
sessionInfo->want.RemoveParam(KEY_REQUEST_ID);
}
TAG_LOGI(AAFwkTag::ABILITYMGR, "scb call, StartUIAbilities BatchPendingSessionsActivation for callerSession");
return static_cast<int>(callerSession->BatchPendingSessionsActivation(sessionInfoList));
}
void UIAbilityLifecycleManager::HandleAbilitiesRequestDone(int32_t requestId, int32_t requestListId,
sptr<SessionInfo> sessionInfo)
{
auto it = abilitiesRequestMap_.find(requestListId);
if (it == abilitiesRequestMap_.end()) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "requestListId: %{public}d not found", requestListId);
return;
}
auto abilitiesRequest = it->second;
CHECK_POINTER_LOG(abilitiesRequest, "abilitiesUIRequest nullptr");
abilitiesRequest->doneCount++;
auto &sessionInfoList = abilitiesRequest->sessionInfoList;
for (auto &item : sessionInfoList) {
if (item.first == requestId) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "requestdone %{public}d", requestId);
item.second = sessionInfo;
}
}
if (abilitiesRequest->doneCount == sessionInfoList.size()) {
int32_t ret = BatchNotifySCBPendingActivations(*abilitiesRequest);
abilitiesRequestMap_.erase(it);
auto callerRecord = Token::GetAbilityRecordByToken(abilitiesRequest->callerToken);
if (callerRecord == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "callerRecord not exist.");
return;
}
callerRecord->NotifyAbilitiesRequestDone(abilitiesRequest->requestKey, ret);
}
}
int32_t UIAbilityLifecycleManager::NotifySCBToRecoveryAfterInterception(const AbilityRequest &abilityRequest)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
std::lock_guard<ffrt::mutex> guard(sessionLock_);
if (IsStartSpecifiedProcessRequest(abilityRequest)) {
return StartSpecifiedProcessRequest(abilityRequest);
return StartSpecifiedProcessRequest(abilityRequest, nullptr);
}
const auto &abilityInfo = abilityRequest.abilityInfo;
auto isPlugin = StartupUtil::IsStartPlugin(abilityRequest.want);
@@ -2116,13 +2288,14 @@ void UIAbilityLifecycleManager::OnAcceptWantResponse(const AAFwk::Want &want, co
}
}
HandleLegacyAcceptWantDone(request->abilityRequest, requestId, flag, want);
HandleLegacyAcceptWantDone(*request, flag, want);
}
void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(AbilityRequest &abilityRequest, int32_t requestId,
void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(SpecifiedRequest &specifiedRequest,
const std::string &flag, const AAFwk::Want &want)
{
TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s", want.GetElement().GetURI().c_str());
auto &abilityRequest = specifiedRequest.abilityRequest;
auto callerAbility = GetAbilityRecordByToken(abilityRequest.callerToken);
abilityRequest.specifiedFlag = flag;
if (!flag.empty()) {
@@ -2139,13 +2312,13 @@ void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(AbilityRequest &abili
abilityRecord = iter->second;
CHECK_POINTER_LOG(abilityRecord, "OnAcceptWantResponse abilityRecord null");
UpdateAbilityRecordLaunchReason(abilityRequest, abilityRecord);
MoveAbilityToFront(abilityRequest, abilityRecord, callerAbility, nullptr, requestId);
MoveAbilityToFront(specifiedRequest, abilityRecord, callerAbility);
NotifyRestartSpecifiedAbility(abilityRequest, abilityRecord->GetToken());
return;
}
}
NotifyStartSpecifiedAbility(abilityRequest, want);
StartAbilityBySpecifed(abilityRequest, callerAbility, requestId);
StartAbilityBySpecifed(specifiedRequest, callerAbility);
}
void UIAbilityLifecycleManager::OnStartSpecifiedAbilityTimeoutResponse(int32_t requestId)
@@ -2181,6 +2354,7 @@ void UIAbilityLifecycleManager::OnStartSpecifiedFailed(int32_t requestId)
RemoveInstanceKey(curRequest->abilityRequest);
}
HandleAbilitiesRequestDone(requestId, curRequest->requestListId, nullptr);
auto nextRequest = PopAndGetNextSpecified(requestId);
if (nextRequest) {
StartSpecifiedRequest(*nextRequest);
@@ -2224,6 +2398,10 @@ void UIAbilityLifecycleManager::OnStartSpecifiedProcessResponse(const std::strin
(abilityRequest.abilityInfo.applicationInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE);
TAG_LOGI(AAFwkTag::ABILITYMGR, "reused sessionId: %{public}d, userId: %{public}d", sessionInfo->persistentId,
abilityRequest.userId);
if (request->requestListId != REQUEST_LIST_ID_INIT) {
HandleAbilitiesRequestDone(requestId, request->requestListId, sessionInfo);
return;
}
std::string errMsg;
NotifySCBPendingActivation(sessionInfo, abilityRequest, errMsg);
}
@@ -2236,6 +2414,7 @@ void UIAbilityLifecycleManager::OnStartSpecifiedProcessTimeoutResponse(int32_t r
if (request != nullptr) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "removing instance key");
RemoveInstanceKey(request->abilityRequest);
HandleAbilitiesRequestDone(requestId, request->requestListId, nullptr);
}
auto nextRequest = PopAndGetNextSpecified(requestId);
if (nextRequest) {
@@ -2269,7 +2448,8 @@ bool UIAbilityLifecycleManager::IsStartSpecifiedProcessRequest(const AbilityRequ
return true;
}
int32_t UIAbilityLifecycleManager::StartSpecifiedProcessRequest(const AbilityRequest &abilityRequest)
int32_t UIAbilityLifecycleManager::StartSpecifiedProcessRequest(const AbilityRequest &abilityRequest,
std::shared_ptr<AbilitiesRequest> abilitiesRequest)
{
auto isCreating = abilityRequest.want.GetBoolParam(Want::CREATE_APP_INSTANCE_KEY, false);
const auto &abilityInfo = abilityRequest.abilityInfo;
@@ -2289,6 +2469,10 @@ int32_t UIAbilityLifecycleManager::StartSpecifiedProcessRequest(const AbilityReq
TAG_LOGI(AAFwkTag::ABILITYMGR, "StartSpecifiedProcess, requestId:%{public}d", requestId);
auto specifiedRequest = std::make_shared<SpecifiedRequest>(requestId, abilityRequest);
specifiedRequest->specifiedProcessState = SpecifiedProcessState::STATE_PROCESS;
if (abilitiesRequest != nullptr) {
abilitiesRequest->sessionInfoList.emplace_back(requestId, nullptr);
specifiedRequest->requestListId = abilitiesRequest->requestListId;
}
AddSpecifiedRequest(specifiedRequest);
return ERR_OK;
}
@@ -2301,7 +2485,7 @@ int32_t UIAbilityLifecycleManager::StartSpecifiedAbilityBySCB(AbilityRequest &ab
std::lock_guard guard(sessionLock_);
// support specified process mode
if (IsStartSpecifiedProcessRequest(abilityRequest)) {
return StartSpecifiedProcessRequest(abilityRequest);
return StartSpecifiedProcessRequest(abilityRequest, nullptr);
}
AddSpecifiedRequest(std::make_shared<SpecifiedRequest>(RequestIdUtil::GetRequestId(), abilityRequest));
return ERR_OK;
@@ -2348,14 +2532,16 @@ void UIAbilityLifecycleManager::NotifyStartSpecifiedAbility(AbilityRequest &abil
}
}
int UIAbilityLifecycleManager::MoveAbilityToFront(const AbilityRequest &abilityRequest,
const std::shared_ptr<AbilityRecord> &abilityRecord, std::shared_ptr<AbilityRecord> callerAbility,
std::shared_ptr<StartOptions> startOptions, int32_t requestId)
int32_t UIAbilityLifecycleManager::MoveAbilityToFront(const SpecifiedRequest &specifiedRequest,
std::shared_ptr<AbilityRecord> abilityRecord, std::shared_ptr<AbilityRecord> callerAbility)
{
if (!abilityRecord) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "ability record failed");
return ERR_INVALID_VALUE;
}
const auto &abilityRequest = specifiedRequest.abilityRequest;
int32_t requestId = specifiedRequest.requestId;
int32_t requestListId = specifiedRequest.requestListId;
sptr<SessionInfo> sessionInfo = abilityRecord->GetSessionInfo();
CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE);
sessionInfo->want = abilityRequest.want;
@@ -2372,11 +2558,12 @@ int UIAbilityLifecycleManager::MoveAbilityToFront(const AbilityRequest &abilityR
sessionInfo->specifiedFlag = abilityRequest.specifiedFlag;
TAG_LOGI(AAFwkTag::ABILITYMGR, "MoveAbilityToFront: %{public}d-%{public}s", requestId,
abilityRequest.specifiedFlag.c_str());
if (requestListId != REQUEST_LIST_ID_INIT) {
HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
return ERR_OK;
}
SendSessionInfoToSCB(callerAbility, sessionInfo);
abilityRecord->RemoveWindowMode();
if (startOptions != nullptr) {
abilityRecord->SetWindowMode(startOptions->GetWindowMode());
}
return ERR_OK;
}
@@ -2431,11 +2618,12 @@ int UIAbilityLifecycleManager::SendSessionInfoToSCB(std::shared_ptr<AbilityRecor
return ERR_OK;
}
int UIAbilityLifecycleManager::StartAbilityBySpecifed(const AbilityRequest &abilityRequest,
std::shared_ptr<AbilityRecord> &callerAbility, int32_t requestId)
int32_t UIAbilityLifecycleManager::StartAbilityBySpecifed(const SpecifiedRequest &specifiedRequest,
std::shared_ptr<AbilityRecord> callerAbility)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "call");
sptr<SessionInfo> sessionInfo = new SessionInfo();
const auto &abilityRequest = specifiedRequest.abilityRequest;
sessionInfo->callerToken = abilityRequest.callerToken;
sessionInfo->want = abilityRequest.want;
sessionInfo->requestCode = abilityRequest.requestCode;
@@ -2443,10 +2631,14 @@ int UIAbilityLifecycleManager::StartAbilityBySpecifed(const AbilityRequest &abil
sessionInfo->startWindowOption = abilityRequest.startWindowOption;
sessionInfo->instanceKey = abilityRequest.want.GetStringParam(Want::APP_INSTANCE_KEY);
sessionInfo->isFromIcon = abilityRequest.isFromIcon;
sessionInfo->requestId = requestId;
sessionInfo->requestId = specifiedRequest.requestId;
sessionInfo->specifiedFlag = abilityRequest.specifiedFlag;
TAG_LOGI(AAFwkTag::ABILITYMGR, "specified flag:%{public}s", abilityRequest.specifiedFlag.c_str());
SendSessionInfoToSCB(callerAbility, sessionInfo);
if (specifiedRequest.requestListId != REQUEST_LIST_ID_INIT) {
HandleAbilitiesRequestDone(specifiedRequest.requestId, specifiedRequest.requestListId, sessionInfo);
} else {
SendSessionInfoToSCB(callerAbility, sessionInfo);
}
return ERR_OK;
}
@@ -3629,7 +3821,7 @@ void UIAbilityLifecycleManager::StartSpecifiedRequest(SpecifiedRequest &specifie
return;
}
if (specifiedRequest.specifiedProcessState == SpecifiedProcessState::STATE_NONE &&
!IsSpecifiedModuleLoaded(request)) {
specifiedRequest.requestListId == REQUEST_LIST_ID_INIT && !IsSpecifiedModuleLoaded(request)) {
specifiedRequest.isCold = true;
auto sessionInfo = CreateSessionInfo(request);
sessionInfo->requestCode = request.requestCode;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Copyright (c) 2024-2025 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
@@ -395,5 +395,37 @@ bool StartAbilityUtils::IsCallFromAncoShellOrBroker(const sptr<IRemoteObject> &c
}
return false;
}
void StartAbilityUtils::SetTargetCloneIndexInSameBundle(const Want &want, sptr<IRemoteObject> callerToken)
{
auto callerRecord = Token::GetAbilityRecordByToken(callerToken);
CHECK_POINTER(callerRecord);
if (callerRecord->GetAbilityInfo().bundleName != want.GetElement().GetBundleName()) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "not the same bundle");
return;
}
if (want.HasParameter(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY)) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "want with app clone index.");
return;
}
int32_t appIndex = callerRecord->GetApplicationInfo().appIndex;
if (appIndex >= 0 && appIndex < AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
(const_cast<Want &>(want)).SetParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, appIndex);
}
}
int32_t StartAbilityUtils::StartUIAbilitiesProcessAppIndex(Want &want,
sptr<IRemoteObject> callerToken, int32_t &appIndex)
{
SetTargetCloneIndexInSameBundle(want, callerToken);
if (!want.HasParameter(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY)) {
want.SetParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, 0);
}
if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIAbilities GetAppIndex failed.");
return ERR_APP_CLONE_INDEX_INVALID;
}
return ERR_OK;
}
}
}
+8
View File
@@ -139,6 +139,13 @@ public:
*/
bool IsStartOptionsWithAnimation();
/**
* IsSupportStartAbilities, check whether the StartUIAbilities API is supported.
*
* @return Whether the StartUIAbilities API is supported.
*/
bool IsSupportStartAbilities();
/**
* IsStartOptionsWithAnimation, check whether it is a multi-process model.
*
@@ -424,6 +431,7 @@ private:
volatile DeviceConfiguration<bool> isConnectSupportCrossUser_ = {false, false};
volatile DeviceConfiguration<bool> isSupportAppServiceExtension_ = {false, false};
volatile DeviceConfiguration<bool> isGrantTempUriPermission_ = {false, true};
volatile DeviceConfiguration<bool> isSupportStartAbilities_ = {false, false};
DeviceConfiguration<std::vector<std::pair<std::string, std::string>>>
residentProcessInExtremeMemory_ = {false, {}};
std::mutex residentProcessInExtremeMemoryMutex_;
+11
View File
@@ -42,6 +42,7 @@ constexpr const char* LIMIT_MAXIMUM_OF_RENDER_PROCESS = "persist.sys.abilityms.l
constexpr const char* GRANT_PERSIST_URI_PERMISSION = "persist.sys.abilityms.grant_persist_uri_permission";
constexpr const char* GRANT_TEMPORARY_URI_PERMISSION = "persist.sys.abilityms.grant_temporary_uri_permission";
constexpr const char* START_OPTIONS_WITH_ANIMATION = "persist.sys.abilityms.start_options_with_animation";
constexpr const char* SUPPORT_START_ABILITIES = "persist.sys.abilityms.enable_start_abilities";
constexpr const char* MULTI_PROCESS_MODEL = "persist.sys.abilityms.multi_process_model";
constexpr const char* PARAM_ANCO_APP_IDENTIFIER = "persist.hmos_fusion_mgr.anco_identifier";
constexpr const char* ALLOW_CHILD_PROCESS_IN_MULTI_PROCESS_FEATURE_APP =
@@ -227,6 +228,16 @@ bool AppUtils::IsStartOptionsWithAnimation()
return isStartOptionsWithAnimation_.value;
}
bool AppUtils::IsSupportStartAbilities()
{
if (!isSupportStartAbilities_.isLoaded) {
isSupportStartAbilities_.value = system::GetBoolParameter(SUPPORT_START_ABILITIES, false);
isSupportStartAbilities_.isLoaded = true;
}
TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isSupportStartAbilities_.value);
return isSupportStartAbilities_.value;
}
bool AppUtils::IsMultiProcessModel()
{
if (!isMultiProcessModel_.isLoaded) {
@@ -164,6 +164,9 @@ public:
void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element) override
{}
void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override
{}
};
sptr<Token> GetFuzzAbilityToken(AbilityType type)
{
@@ -160,6 +160,9 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId, const AppExecFwk::ElementName &element)
{}
virtual void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode)
{}
};
} // namespace AppExecFwk
} // namespace OHOS
@@ -89,6 +89,9 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId,
const AppExecFwk::ElementName &element) override
{}
virtual void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override
{}
};
} // namespace AppExecFwk
} // namespace OHOS
@@ -125,6 +125,9 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId,
const AppExecFwk::ElementName &element) override
{}
virtual void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override
{}
private:
AbilityResult result_;
};
@@ -48,6 +48,7 @@ public:
MOCK_METHOD2(DumpAbilityInfo, void(const std::vector<std::string>& params, std::vector<std::string>& info));
MOCK_METHOD1(ScheduleShareData, void(const int32_t &uniqueId));
MOCK_METHOD0(SchedulePrepareTerminateAbility, bool());
MOCK_METHOD2(ScheduleAbilitiesRequestDone, void(const std::string &, int32_t));
int InvokeSendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
{
code_ = code;
@@ -488,6 +488,22 @@ HWTEST_F(AbilityManagerClientTest, StartAbilityByCallWithErrMsg_0100, TestSize.L
TAG_LOGI(AAFwkTag::TEST, "StartAbilityByCallWithErrMsg_0100 end");
}
/**
* @tc.name: AbilityManagerClient_StartUIAbilities_0100
* @tc.desc: StartUIAbilities
* @tc.type: FUNC
*/
HWTEST_F(AbilityManagerClientTest, StartUIAbilities_0100, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "StartUIAbilities_0100 start");
std::vector<Want> wantList(2);
std::string requestKey = "12345";
sptr<IRemoteObject> callToken = sptr<AbilityRuntime::MockIRemoteObject>::MakeSptr();
auto result = AbilityManagerClient::GetInstance()->StartUIAbilities(wantList, requestKey, callToken);
EXPECT_EQ(result, ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "StartUIAbilities_0100 end");
}
/**
* @tc.name: AbilityManagerClient_QueryPreLoadUIExtensionRecord_0100
* @tc.desc: QueryPreLoadUIExtensionRecord
@@ -139,6 +139,9 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId,
const AppExecFwk::ElementName &element) override
{}
virtual void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override
{}
};
} // namespace AAFwk
} // namespace OHOS
@@ -79,6 +79,9 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId,
const AppExecFwk::ElementName &element) override
{}
virtual void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override
{}
};
} // namespace AAFwk
} // namespace OHOS
@@ -445,11 +445,11 @@ private:
void NotifyStartSpecifiedAbility(AbilityRequest &request, const AAFwk::Want &want);
void NotifyRestartSpecifiedAbility(const AbilityRequest &request, const sptr<IRemoteObject> &token);
int MoveAbilityToFront(const AbilityRequest &abilityRequest, const std::shared_ptr<AbilityRecord> &abilityRecord,
std::shared_ptr<AbilityRecord> callerAbility, std::shared_ptr<StartOptions> startOptions, int32_t requestId);
int MoveAbilityToFront(const SpecifiedRequest &specifiedRequest,
const std::shared_ptr<AbilityRecord> abilityRecord, std::shared_ptr<AbilityRecord> callerAbility);
int SendSessionInfoToSCB(std::shared_ptr<AbilityRecord> &callerAbility, sptr<SessionInfo> &sessionInfo);
int StartAbilityBySpecifed(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &callerAbility,
int32_t requestId);
int StartAbilityBySpecifed(const SpecifiedRequest &specifiedRequest,
std::shared_ptr<AbilityRecord> callerAbility);
void SetLastExitReason(std::shared_ptr<AbilityRecord> &abilityRecord) const;
void SetReceiverInfo(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &abilityRecord) const;
@@ -505,7 +505,7 @@ private:
bool HandleStartSpecifiedCold(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo, uint32_t sceneFlag);
bool HandleColdAcceptWantDone(const AAFwk::Want &want, const std::string &flag,
const SpecifiedRequest &specifiedRequest);
void HandleLegacyAcceptWantDone(AbilityRequest &abilityRequest, int32_t requestId,
void HandleLegacyAcceptWantDone(SpecifiedRequest &specifiedRequest,
const std::string &flag, const AAFwk::Want &want);
std::shared_ptr<SpecifiedRequest> GetSpecifiedRequest(int32_t requestId);
bool CheckPrepareTerminateTokens(const std::vector<sptr<IRemoteObject>> &tokens,
@@ -395,7 +395,7 @@ void UIAbilityLifecycleManager::OnAcceptWantResponse(const AAFwk::Want &want, co
{
}
void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(AbilityRequest &abilityRequest, int32_t requestId,
void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(SpecifiedRequest &specifiedRequest,
const std::string &flag, const AAFwk::Want &want)
{
}
@@ -431,9 +431,8 @@ void UIAbilityLifecycleManager::NotifyStartSpecifiedAbility(AbilityRequest &abil
{
}
int UIAbilityLifecycleManager::MoveAbilityToFront(const AbilityRequest &abilityRequest,
const std::shared_ptr<AbilityRecord> &abilityRecord, std::shared_ptr<AbilityRecord> callerAbility,
std::shared_ptr<StartOptions> startOptions, int32_t requestId)
int UIAbilityLifecycleManager::MoveAbilityToFront(const SpecifiedRequest &specifiedRequest,
const std::shared_ptr<AbilityRecord> abilityRecord, std::shared_ptr<AbilityRecord> callerAbility)
{
return ERR_OK;
}
@@ -444,8 +443,8 @@ int UIAbilityLifecycleManager::SendSessionInfoToSCB(std::shared_ptr<AbilityRecor
return ERR_OK;
}
int UIAbilityLifecycleManager::StartAbilityBySpecifed(const AbilityRequest &abilityRequest,
std::shared_ptr<AbilityRecord> &callerAbility, int32_t requestId)
int UIAbilityLifecycleManager::StartAbilityBySpecifed(const SpecifiedRequest &specifiedRequest,
std::shared_ptr<AbilityRecord> callerAbility)
{
return ERR_OK;
}
@@ -29,12 +29,15 @@ using OHOS::AppExecFwk::ExtensionAbilityType;
constexpr char DEVELOPER_MODE_STATE[] = "const.security.developermode.state";
constexpr const char* DEBUG_APP = "debugApp";
constexpr const char* DLP_PARAMS_SANDBOX = "ohos.dlp.params.sandbox";
constexpr const char* DLP_INDEX = "ohos.dlp.params.index";
constexpr const char* START_ABILITY_TYPE = "ABILITY_INNER_START_WITH_ACCOUNT";
constexpr int32_t ONE = 1;
constexpr int32_t TWO = 2;
constexpr int32_t FOUNDATION_UID = 5523;
constexpr int32_t DMS_UID = 5522;
constexpr int32_t LOW_MEMORY_KILL_WHILE_STARTING = 1111;
constexpr int32_t DEFAULT_INVAL_VALUE = -1;
namespace OHOS {
namespace AAFwk {
@@ -1228,6 +1231,707 @@ HWTEST_F(AbilityManagerServiceThirteenthTest, KillProcessWithReason_002, TestSiz
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest KillProcessWithReason_002 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_001
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities CCM false SCB false
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_001 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<Want> wantList;
std::string requestKey;
sptr<IRemoteObject> callerToken = nullptr;
MyStatus::GetInstance().isSupportStartAbilities_ = false;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = false;
EXPECT_EQ(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), ERR_CAPABILITY_NOT_SUPPORT);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_001 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_002
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities CCM true SCB false
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_002, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_002 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<Want> wantList;
std::string requestKey;
sptr<IRemoteObject> callerToken = nullptr;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = false;
EXPECT_EQ(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), ERR_CAPABILITY_NOT_SUPPORT);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_002 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_003
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities CCM false SCB true
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_003, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_003 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<Want> wantList;
std::string requestKey;
sptr<IRemoteObject> callerToken = nullptr;
MyStatus::GetInstance().isSupportStartAbilities_ = false;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
EXPECT_EQ(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), ERR_CAPABILITY_NOT_SUPPORT);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_003 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_004
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities CCM true SCB true listSize = 0
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_004, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_004 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<Want> wantList(6);
std::string requestKey;
sptr<IRemoteObject> callerToken = nullptr;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
EXPECT_EQ(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), START_UI_ABILITIES_WANT_LIST_SIZE_ERROR);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_004 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_005
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities listSize > 4
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_005, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_005 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<Want> wantList(5);
std::string requestKey;
sptr<IRemoteObject> callerToken = nullptr;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
EXPECT_EQ(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), START_UI_ABILITIES_WANT_LIST_SIZE_ERROR);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_005 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_006
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities callerToken = nullptr
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_006, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_006 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
auto mockSubManagersHelper = std::make_shared<SubManagersHelper>(nullptr, nullptr);
EXPECT_NE(mockSubManagersHelper, nullptr);
auto mockCurrentUIAbilityManager = std::make_shared<UIAbilityLifecycleManager>(0);
EXPECT_NE(mockCurrentUIAbilityManager, nullptr);
abilityMs_->subManagersHelper_ = mockSubManagersHelper;
abilityMs_->subManagersHelper_->currentUIAbilityManager_ = mockCurrentUIAbilityManager;
std::vector<Want> wantList(2);
std::string requestKey;
sptr<IRemoteObject> callerToken = nullptr;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
EXPECT_EQ(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), ERR_INVALID_CALLER);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_006 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_007
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities verifyToken failed
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_007, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_007 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
auto mockSubManagersHelper = std::make_shared<SubManagersHelper>(nullptr, nullptr);
EXPECT_NE(mockSubManagersHelper, nullptr);
auto mockCurrentUIAbilityManager = std::make_shared<UIAbilityLifecycleManager>(0);
EXPECT_NE(mockCurrentUIAbilityManager, nullptr);
abilityMs_->subManagersHelper_ = mockSubManagersHelper;
abilityMs_->subManagersHelper_->currentUIAbilityManager_ = mockCurrentUIAbilityManager;
std::vector<Want> wantList(2);
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
MyStatus::GetInstance().smhVerificationAllToken_ = false;
EXPECT_EQ(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), ERR_INVALID_CALLER);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_007 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilities_008
* Function: StartUIAbilities
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilities handleWant failed
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilities_008, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_008 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
auto mockSubManagersHelper = std::make_shared<SubManagersHelper>(nullptr, nullptr);
EXPECT_NE(mockSubManagersHelper, nullptr);
auto mockCurrentUIAbilityManager = std::make_shared<UIAbilityLifecycleManager>(0);
EXPECT_NE(mockCurrentUIAbilityManager, nullptr);
abilityMs_->subManagersHelper_ = mockSubManagersHelper;
abilityMs_->subManagersHelper_->currentUIAbilityManager_ = mockCurrentUIAbilityManager;
std::vector<Want> wantList(2);
std::string requestKey;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
EXPECT_NE(abilityMs_->StartUIAbilities(wantList, requestKey, callerToken), ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilities_008 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_001
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant startPlugin
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_001 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetParam(AAFwk::Want::DESTINATION_PLUGIN_ABILITY, true);
EXPECT_EQ(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
START_UI_ABILITIES_NOT_SUPPORT_START_PLUGIN);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_001 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_002
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant createInstance
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_002, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_002 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetParam(AAFwk::Want::CREATE_APP_INSTANCE_KEY, true);
EXPECT_EQ(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
START_UI_ABILITIES_NOT_SUPPORT_CREATE_APP_INSTANCE_KEY);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_002 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_003
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant dlp failed with dlp
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_003, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_003 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetParam(DLP_PARAMS_SANDBOX, true);
want.SetElementName("com.ohos.test", "MainAbility");
EXPECT_EQ(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
START_UI_ABILITIES_NOT_SUPPORT_DLP);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_003 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_004
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant appCloneIndexError
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_004, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_004 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
want.SetParam(Want::PARAM_APP_CLONE_INDEX_KEY, -5);
EXPECT_EQ(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
ERR_APP_CLONE_INDEX_INVALID);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_004 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_005
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant multiInstanceError
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_005, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_005 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetElementName("com.ohos.test", "MainAbility");
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
want.SetParam(Want::APP_INSTANCE_KEY, 2);
MyStatus::GetInstance().isSupportMultiInstance_ = false;
EXPECT_NE(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
ERR_OK);
MyStatus::GetInstance().isSupportMultiInstance_ = true;
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_005 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_006
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant OperateRemoteError
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_006, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_006 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetElementName("com.ohos.test", "MainAbility");
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
want.SetDeviceId("deviceId");
EXPECT_NE(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_006 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_007
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant CrossUserError?
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_007, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_007 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetElementName("com.ohos.test", "MainAbility");
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
want.SetDeviceId("deviceId");
EXPECT_NE(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_007 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_008
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant ImplicitStartError
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_008, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_008 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
EXPECT_EQ(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
START_UI_ABILITIES_NOT_SUPPORT_IMPLICIT_START);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_008 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesHandleWant_009
* Function: StartUIAbilitiesHandleWant
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesHandleWant generateRequestPass
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesHandleWant_009, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_009 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
want.SetElementName("com.ohos.test", "MainAbility");
EXPECT_EQ(abilityMs_->StartUIAbilitiesHandleWant(want, callerToken, abilityRequestList),
RESOLVE_ABILITY_ERR);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesHandleWant_009 end");
}
#ifdef WITH_DLP
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesCheckDlp_001
* Function: StartUIAbilitiesCheckDlp
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesCheckDlp handleDLP == true
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesCheckDlp_001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_001 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetParam(DLP_PARAMS_SANDBOX, true);
want.SetElementName("com.ohos.test", "MainAbility");
int32_t userId = DEFAULT_INVAL_VALUE;
EXPECT_EQ(abilityMs_->StartUIAbilitiesCheckDlp(want, callerToken, userId),
START_UI_ABILITIES_NOT_SUPPORT_DLP);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_001 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesCheckDlp_002
* Function: StartUIAbilitiesCheckDlp
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesCheckDlp false false false
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesCheckDlp_002, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_002 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
EXPECT_EQ(abilityMs_->StartUIAbilitiesCheckDlp(want, callerToken, userId),
ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_002 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesCheckDlp_003
* Function: StartUIAbilitiesCheckDlp
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesCheckDlp true false false
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesCheckDlp_003, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_003 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetParam(DLP_INDEX, 1);
MyStatus::GetInstance().permPermission_ = false;
int32_t userId = DEFAULT_INVAL_VALUE;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
EXPECT_EQ(abilityMs_->StartUIAbilitiesCheckDlp(want, callerToken, userId),
CHECK_PERMISSION_FAILED);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_003 end");
}
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesCheckDlp_004
* Function: StartUIAbilitiesCheckDlp
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesCheckDlp true true false
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesCheckDlp_004, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_004 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
std::vector<AbilityRequest> abilityRequestList;
std::string requestKey;
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
Want want;
want.SetParam(DLP_INDEX, 1);
MyStatus::GetInstance().permPermission_ = false;
int32_t userId = 0;
sptr<IRemoteObject> callerToken = MockToken(AbilityType::EXTENSION);
EXPECT_EQ(abilityMs_->StartUIAbilitiesCheckDlp(want, callerToken, userId),
CHECK_PERMISSION_FAILED);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesCheckDlp_004 end");
}
#endif // WITH_DLP
/*
* Feature: AbilityManagerService
* Name: StartUIAbilitiesInterceptorCheck_001
* Function: StartUIAbilitiesInterceptorCheck
* SubFunction: NA
* FunctionPoints: AbilityManagerService StartUIAbilitiesInterceptorCheck generateRequestPass
*/
HWTEST_F(AbilityManagerServiceThirteenthTest, StartUIAbilitiesInterceptorCheck_001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesInterceptorCheck_001 start");
auto abilityMs_ = std::make_shared<AbilityManagerService>();
EXPECT_NE(abilityMs_, nullptr);
MyStatus::GetInstance().isSupportStartAbilities_ = true;
MyStatus::GetInstance().sbjIsSceneBoardEnabled_ = true;
MyStatus::GetInstance().smhVerificationAllToken_ = true;
int32_t appIndex = 0;
Want want;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
int32_t userId = DEFAULT_INVAL_VALUE;
MyStatus::GetInstance().permPermission_ = true;
want.SetElementName("com.ohos.test", "MainAbility");
EXPECT_EQ(abilityMs_->StartUIAbilitiesInterceptorCheck(want, abilityRequest, callerToken, appIndex),
START_UI_ABILITIES_INTERCEPTOR_CHECK_FAILED);
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirteenthTest StartUIAbilitiesInterceptorCheck_001 end");
}
/*
* Feature: AbilityManagerService
* Name: DelegatorDoAbilityForeground_001
@@ -132,6 +132,13 @@ public:
*/
bool IsStartOptionsWithAnimation();
/**
* IsSupportStartAbilities, check whether the StartUIAbilities API is supported.
*
* @return Whether the StartUIAbilities API is supported.
*/
bool IsSupportStartAbilities();
/**
* IsStartOptionsWithAnimation, check whether it is a multi-process model.
*
@@ -52,6 +52,8 @@ public:
bool paramGetBoolParameter_ = true;
std::shared_ptr<AbilityRecord> acmGetUIExtensionBySessionInfo_ = nullptr;
std::shared_ptr<AbilityRecord> acmGetUIExtensionBySessionFromServiceMap_ = nullptr;
bool isSupportStartAbilities_ = true;
bool isSupportMultiInstance_ = true;
};
} // namespace AAFwk
} // namespace OHOS
@@ -164,6 +164,8 @@ public:
void SetRootSceneSession(const sptr<IRemoteObject> &rootSceneSession);
int NotifySCBToStartUIAbility(AbilityRequest &abilityRequest);
int32_t NotifySCBToStartUIAbilities(std::vector<AbilityRequest> &abilityRequestList,
const std::string &requestKey);
int NotifySCBToPreStartUIAbility(const AbilityRequest &abilityRequest,
sptr<SessionInfo> &sessionInfo);
@@ -446,11 +448,11 @@ private:
void NotifyStartSpecifiedAbility(AbilityRequest &request, const AAFwk::Want &want);
void NotifyRestartSpecifiedAbility(const AbilityRequest &request, const sptr<IRemoteObject> &token);
int MoveAbilityToFront(const AbilityRequest &abilityRequest, const std::shared_ptr<AbilityRecord> &abilityRecord,
std::shared_ptr<AbilityRecord> callerAbility, std::shared_ptr<StartOptions> startOptions, int32_t requestId);
int MoveAbilityToFront(const SpecifiedRequest &specifiedRequest,
const std::shared_ptr<AbilityRecord> abilityRecord, std::shared_ptr<AbilityRecord> callerAbility);
int SendSessionInfoToSCB(std::shared_ptr<AbilityRecord> &callerAbility, sptr<SessionInfo> &sessionInfo);
int StartAbilityBySpecifed(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &callerAbility,
int32_t requestId);
int StartAbilityBySpecifed(const SpecifiedRequest &specifiedRequest,
std::shared_ptr<AbilityRecord> callerAbility);
void SetLastExitReason(std::shared_ptr<AbilityRecord> &abilityRecord) const;
void SetReceiverInfo(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &abilityRecord) const;
@@ -506,7 +508,7 @@ private:
bool HandleStartSpecifiedCold(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo, uint32_t sceneFlag);
bool HandleColdAcceptWantDone(const AAFwk::Want &want, const std::string &flag,
const SpecifiedRequest &specifiedRequest);
void HandleLegacyAcceptWantDone(AbilityRequest &abilityRequest, int32_t requestId,
void HandleLegacyAcceptWantDone(SpecifiedRequest &specifiedRequest,
const std::string &flag, const AAFwk::Want &want);
std::shared_ptr<SpecifiedRequest> GetSpecifiedRequest(int32_t requestId);
bool CheckPrepareTerminateTokens(const std::vector<sptr<IRemoteObject>> &tokens,
@@ -192,7 +192,7 @@ int32_t AppUtils::MaxChildProcess()
bool AppUtils::IsSupportMultiInstance()
{
return true;
return MyStatus::GetInstance().isSupportMultiInstance_;
}
std::string AppUtils::GetMigrateClientBundleName()
@@ -248,5 +248,9 @@ bool AppUtils::IsSupportAppServiceExtension()
return true;
}
bool AppUtils::IsSupportStartAbilities()
{
return MyStatus::GetInstance().isSupportStartAbilities_;
}
} // namespace AAFwk
} // namespace OHOS
@@ -122,6 +122,12 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(AbilityRequest &ability
return ERR_OK;
}
int32_t UIAbilityLifecycleManager::NotifySCBToStartUIAbilities(std::vector<AbilityRequest> &abilityRequestList,
const std::string &requestKey)
{
return ERR_OK;
}
int32_t UIAbilityLifecycleManager::NotifySCBToRecoveryAfterInterception(const AbilityRequest &abilityRequest)
{
return ERR_OK;
@@ -398,7 +404,7 @@ void UIAbilityLifecycleManager::OnAcceptWantResponse(const AAFwk::Want &want, co
{
}
void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(AbilityRequest &abilityRequest, int32_t requestId,
void UIAbilityLifecycleManager::HandleLegacyAcceptWantDone(SpecifiedRequest &specifiedRequest,
const std::string &flag, const AAFwk::Want &want)
{
}
@@ -434,9 +440,8 @@ void UIAbilityLifecycleManager::NotifyStartSpecifiedAbility(AbilityRequest &abil
{
}
int UIAbilityLifecycleManager::MoveAbilityToFront(const AbilityRequest &abilityRequest,
const std::shared_ptr<AbilityRecord> &abilityRecord, std::shared_ptr<AbilityRecord> callerAbility,
std::shared_ptr<StartOptions> startOptions, int32_t requestId)
int UIAbilityLifecycleManager::MoveAbilityToFront(const SpecifiedRequest &specifiedRequest,
const std::shared_ptr<AbilityRecord> abilityRecord, std::shared_ptr<AbilityRecord> callerAbility)
{
return ERR_OK;
}
@@ -447,8 +452,8 @@ int UIAbilityLifecycleManager::SendSessionInfoToSCB(std::shared_ptr<AbilityRecor
return ERR_OK;
}
int UIAbilityLifecycleManager::StartAbilityBySpecifed(const AbilityRequest &abilityRequest,
std::shared_ptr<AbilityRecord> &callerAbility, int32_t requestId)
int UIAbilityLifecycleManager::StartAbilityBySpecifed(const SpecifiedRequest &specifiedRequest,
std::shared_ptr<AbilityRecord> callerAbility)
{
return ERR_OK;
}
@@ -173,6 +173,9 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId,
const AppExecFwk::ElementName &element) override
{}
virtual void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override
{}
};
class MockDataAbilityObserverStub : public DataAbilityObserverStub {
@@ -170,6 +170,8 @@ public:
virtual void ScheduleAbilityRequestSuccess(const std::string &requestId,
const AppExecFwk::ElementName &element) override
{}
void ScheduleAbilitiesRequestDone(const std::string &requestKey, int32_t resultCode) override
{}
};
} // namespace AAFwk
} // namespace OHOS
@@ -126,11 +126,12 @@ HWTEST_F(UIAbilityLifecycleManagerSecondTest, HandleLegacyAcceptWantDone_001, Te
bool reuse = false;
std::string flag = "";
int32_t requestId = 1;
mgr->HandleLegacyAcceptWantDone(abilityRequest, requestId, flag, want);
EXPECT_EQ(abilityRequest.specifiedFlag, "");
SpecifiedRequest specifiedRequest(requestId, abilityRequest);
mgr->HandleLegacyAcceptWantDone(specifiedRequest, flag, want);
EXPECT_EQ(specifiedRequest.abilityRequest.specifiedFlag, "");
flag = "specified";
mgr->HandleLegacyAcceptWantDone(abilityRequest, requestId, flag, want);
EXPECT_EQ(abilityRequest.specifiedFlag, flag);
mgr->HandleLegacyAcceptWantDone(specifiedRequest, flag, want);
EXPECT_EQ(specifiedRequest.abilityRequest.specifiedFlag, flag);
TAG_LOGI(AAFwkTag::TEST, "HandleLegacyAcceptWantDone_001 end.");
}
@@ -26,6 +26,7 @@
#undef protected
#undef private
#include "app_mgr_client.h"
#include "hilog_tag_wrapper.h"
#include "mock_ability_info_callback_stub.h"
#include "process_options.h"
#include "session/host/include/session.h"
@@ -2576,19 +2577,19 @@ HWTEST_F(UIAbilityLifecycleManagerTest, MoveAbilityToFront_001, TestSize.Level1)
{
auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
AbilityRequest abilityRequest;
int res = uiAbilityLifecycleManager->MoveAbilityToFront(abilityRequest, nullptr, nullptr, nullptr, 0);
SpecifiedRequest specifiedRequest(0, abilityRequest);
int res = uiAbilityLifecycleManager->MoveAbilityToFront(specifiedRequest, nullptr, nullptr);
EXPECT_EQ(res, ERR_INVALID_VALUE);
abilityRequest.sessionInfo = new SessionInfo();
abilityRequest.appInfo.bundleName = "com.example.unittest";
abilityRequest.abilityInfo.name = "MainAbility";
abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::PAGE;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
res = uiAbilityLifecycleManager->MoveAbilityToFront(abilityRequest, abilityRecord, nullptr, nullptr, 0);
specifiedRequest.abilityRequest.sessionInfo = new SessionInfo();
specifiedRequest.abilityRequest.appInfo.bundleName = "com.example.unittest";
specifiedRequest.abilityRequest.abilityInfo.name = "MainAbility";
specifiedRequest.abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::PAGE;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(specifiedRequest.abilityRequest);
res = uiAbilityLifecycleManager->MoveAbilityToFront(specifiedRequest, abilityRecord, nullptr);
EXPECT_EQ(res, ERR_OK);
auto startOptions = std::make_shared<StartOptions>();
res = uiAbilityLifecycleManager->MoveAbilityToFront(abilityRequest, abilityRecord, nullptr, nullptr, 0);
res = uiAbilityLifecycleManager->MoveAbilityToFront(specifiedRequest, abilityRecord, nullptr);
EXPECT_EQ(res, ERR_OK);
uiAbilityLifecycleManager.reset();
@@ -2702,8 +2703,26 @@ HWTEST_F(UIAbilityLifecycleManagerTest, StartAbilityBySpecifed_001, TestSize.Lev
auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
AbilityRequest request;
SpecifiedRequest specifiedRequest(0, request);
std::shared_ptr<AbilityRecord> callerAbility = nullptr;
uiAbilityLifecycleManager->StartAbilityBySpecifed(request, callerAbility, 0);
uiAbilityLifecycleManager->StartAbilityBySpecifed(specifiedRequest, callerAbility);
uiAbilityLifecycleManager.reset();
}
/**
* @tc.name: UIAbilityLifecycleManager_StartAbilityBySpecifed_0200
* @tc.desc: StartAbilityBySpecifed
* @tc.type: FUNC
*/
HWTEST_F(UIAbilityLifecycleManagerTest, StartAbilityBySpecifed_0200, TestSize.Level1)
{
auto uiAbilityLifecycleManager = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(uiAbilityLifecycleManager, nullptr);
AbilityRequest request;
SpecifiedRequest specifiedRequest(0, request);
specifiedRequest.requestListId = 0;
std::shared_ptr<AbilityRecord> callerAbility = nullptr;
uiAbilityLifecycleManager->StartAbilityBySpecifed(specifiedRequest, callerAbility);
uiAbilityLifecycleManager.reset();
}
@@ -5345,6 +5364,589 @@ HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToStartUIAbility_0003, TestSize
ret = mgr->NotifySCBToStartUIAbility(request);
}
/**
* @tc.name: NotifySCBToStartUIAbilities_0001
* @tc.desc: handleListError
*/
HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToStartUIAbilities_0001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0001 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
std::vector<AbilityRequest> requestList;
std::string requestKey = "requestKey";
AbilityRequest request;
request.want.SetParam(Want::PARAM_RESV_CALLER_UID, 12345);
for (int i = 0; i < 20; ++i) {
mgr->AddStartCallerTimestamp(12345);
}
requestList.emplace_back(request);
int ret = mgr->NotifySCBToStartUIAbilities(requestList, requestKey);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0001 end");
}
/**
* @tc.name: NotifySCBToStartUIAbilities_0002
* @tc.desc: SpecifiedProcess true
*/
HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToStartUIAbilities_0002, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0002 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
std::vector<AbilityRequest> requestList;
std::string requestKey = "requestKey";
AppUtils::GetInstance().isStartSpecifiedProcess_.isLoaded = true;
AppUtils::GetInstance().isStartSpecifiedProcess_.value = true;
AbilityRequest request;
request.abilityInfo.isolationProcess = true;
request.abilityInfo.type = AppExecFwk::AbilityType::PAGE;
request.abilityInfo.isStageBasedModel = true;
requestList.emplace_back(request);
int ret = mgr->NotifySCBToStartUIAbilities(requestList, requestKey);
EXPECT_EQ(ret, START_UI_ABILITIES_WAITING_SPECIFIED_CODE);
AppUtils::GetInstance().isStartSpecifiedProcess_.isLoaded = false;
AppUtils::GetInstance().isStartSpecifiedProcess_.value = false;
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0002 end");
}
/**
* @tc.name: NotifySCBToStartUIAbilities_0003
* @tc.desc: launchMode Specified
*/
HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToStartUIAbilities_0003, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0003 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
std::vector<AbilityRequest> requestList;
std::string requestKey = "requestKey";
AbilityRequest request;
request.abilityInfo.launchMode = AppExecFwk::LaunchMode::SPECIFIED;
requestList.emplace_back(request);
int ret = mgr->NotifySCBToStartUIAbilities(requestList, requestKey);
EXPECT_EQ(ret, START_UI_ABILITIES_WAITING_SPECIFIED_CODE);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0003 end");
}
/**
* @tc.name: NotifySCBToStartUIAbilities_0004
* @tc.desc: normal
*/
HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToStartUIAbilities_0004, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0004 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
std::vector<AbilityRequest> requestList;
std::string requestKey = "requestKey";
AbilityRequest request;
request.abilityInfo.launchMode = AppExecFwk::LaunchMode::STANDARD;
request.abilityInfo.bundleName = "com.example.bundle";
request.abilityInfo.name = "AbilityA";
request.abilityInfo.moduleName = "moduleA";
request.abilityInfo.isStageBasedModel = true;
request.abilityInfo.type = AppExecFwk::AbilityType::PAGE;
requestList.emplace_back(request);
int ret = mgr->NotifySCBToStartUIAbilities(requestList, requestKey);
EXPECT_NE(ret, ERR_OK);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest NotifySCBToStartUIAbilities_0004 end");
}
/**
* @tc.name: HandleUIAbilityRequestList_0001
* @tc.desc: callerUid's timeStamps >= limit
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleUIAbilityRequestList_0001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleUIAbilityRequestList_0001 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
std::vector<AbilityRequest> requestList;
AbilityRequest request;
request.want.SetParam(Want::PARAM_RESV_CALLER_UID, 12345);
for (int i = 0; i < 20; ++i) {
mgr->AddStartCallerTimestamp(12345);
}
requestList.emplace_back(request);
int ret = mgr->HandleUIAbilityRequestList(requestList);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleUIAbilityRequestList_0001 end");
}
/**
* @tc.name: HandleUIAbilityRequestList_0002
* @tc.desc: isCallerKilling true ERR_OK
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleUIAbilityRequestList_0002, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleUIAbilityRequestList_0002 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
std::vector<AbilityRequest> requestList;
AbilityRequest request;
requestList.emplace_back(request);
int ret = mgr->HandleUIAbilityRequestList(requestList);
EXPECT_EQ(ret, ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleUIAbilityRequestList_0002 end");
}
/**
* @tc.name: HandleAbilitiesNormalSessionInfo_0001
* @tc.desc: isCallerKilling true ERR_OK
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesNormalSessionInfo_0001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesNormalSessionInfo_0001 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
AbilityRequest request;
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t requestId = 1;
mgr->HandleAbilitiesNormalSessionInfo(request, abilitiesRequest, requestId);
EXPECT_EQ(abilitiesRequest->doneCount, 1);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesNormalSessionInfo_0001 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0001
* @tc.desc: sessionInfo nullptr
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0001 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
sptr<SessionInfo> sessionInfo = nullptr;
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_NE(ret, ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0001 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0002
* @tc.desc: callerAbilityRecord nullptr rootSS null
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0002, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0002 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
Rosen::SessionInfo info;
sptr<SessionInfo> sessionInfo(new SessionInfo());
sessionInfo->sessionToken = new Rosen::Session(info);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
abilitiesRequest->callerToken = nullptr;
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0002 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0003
* @tc.desc: callerAbilityRecord restart rootSS null
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0003, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0003 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t requestId = 1;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
abilitiesRequest->callerToken = callerToken;
abilityRecord->SetRestartAppFlag(true);
Rosen::SessionInfo info;
sptr<SessionInfo> sessionInfo(new SessionInfo());
sessionInfo->sessionToken = new Rosen::Session(info);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0003 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0004
* @tc.desc: callerAbilityRecord nullptr has rootSS
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0004, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0004 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
Rosen::SessionInfo info;
sptr<SessionInfo> sessionInfo(new SessionInfo());
sessionInfo->sessionToken = new Rosen::Session(info);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
abilitiesRequest->callerToken = nullptr;
Rosen::SessionInfo rootInfo;
mgr->rootSceneSession_ = new Rosen::Session(rootInfo);
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_EQ(ret, ERR_OK);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0004 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0005
* @tc.desc: normal callerAbilityRecord callerSessionInfo nullptr
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0005, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0005 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t requestId = 1;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
abilitiesRequest->callerToken = callerToken;
Rosen::SessionInfo info;
sptr<SessionInfo> sessionInfo(new SessionInfo());
sessionInfo->sessionToken = new Rosen::Session(info);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0005 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0006
* @tc.desc: normal callerAbilityRecord callerSessionInfo->sessionToken nullptr
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0006, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0006 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t requestId = 1;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
abilitiesRequest->callerToken = callerToken;
sptr<SessionInfo> callerSessionInfo = new SessionInfo();
callerSessionInfo->sessionToken = nullptr;
abilityRecord->SetSessionInfo(callerSessionInfo);
Rosen::SessionInfo info;
sptr<SessionInfo> sessionInfo(new SessionInfo());
sessionInfo->sessionToken = new Rosen::Session(info);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0006 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0007
* @tc.desc: normal callerAbilityRecord callerSession nullptr
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0007, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0007 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t requestId = 1;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
abilitiesRequest->callerToken = callerToken;
sptr<SessionInfo> callerSessionInfo = new SessionInfo();
callerSessionInfo->sessionToken = new OHOS::IPCObjectStub(u"desc2");
abilityRecord->SetSessionInfo(callerSessionInfo);
Rosen::SessionInfo info;
sptr<SessionInfo> sessionInfo(new SessionInfo());
sessionInfo->sessionToken = new Rosen::Session(info);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0007 end");
}
/**
* @tc.name: BatchNotifySCBPendingActivations_0008
* @tc.desc: normal callerAbilityRecord ERR_OK
*/
HWTEST_F(UIAbilityLifecycleManagerTest, BatchNotifySCBPendingActivations_0008, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0008 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t requestId = 1;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
abilitiesRequest->callerToken = callerToken;
sptr<SessionInfo> callerSessionInfo = new SessionInfo();
abilityRecord->SetSessionInfo(callerSessionInfo);
Rosen::SessionInfo info;
sptr<SessionInfo> sessionInfo(new SessionInfo());
sessionInfo->sessionToken = new Rosen::Session(info);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
int32_t ret = mgr->BatchNotifySCBPendingActivations(*abilitiesRequest);
EXPECT_EQ(ret, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest BatchNotifySCBPendingActivations_0008 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0001
* @tc.desc: requestListId not found
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0001, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0001 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0001 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0002
* @tc.desc: requestListId found but nullptr
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0002, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0002 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
mgr->abilitiesRequestMap_.emplace(requestListId, nullptr);
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0002 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0003
* @tc.desc: requestListId found;requestId found;all End;callerRecord nullptr
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0003, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0003 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
abilitiesRequest->doneCount = 1;
mgr->abilitiesRequestMap_.emplace(requestListId, abilitiesRequest);
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0003 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0004
* @tc.desc: requestListId found;requestId found;all End;callerRecord exist
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0004, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0004 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
abilitiesRequest->doneCount = 1;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
abilitiesRequest->callerToken = callerToken;
mgr->abilitiesRequestMap_.emplace(requestListId, abilitiesRequest);
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0004 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0005
* @tc.desc: requestListId found;requestId found; not End
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0005, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0005 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
abilitiesRequest->sessionInfoList.emplace_back(requestId, sessionInfo);
abilitiesRequest->doneCount = 0;
mgr->abilitiesRequestMap_.emplace(requestListId, abilitiesRequest);
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0005 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0006
* @tc.desc: requestListId found;requestId not found; not End
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0006, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0006 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t otherRequestId = 2;
abilitiesRequest->sessionInfoList.emplace_back(otherRequestId, sessionInfo);
abilitiesRequest->doneCount = 0;
mgr->abilitiesRequestMap_.emplace(requestListId, abilitiesRequest);
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0006 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0007
* @tc.desc: requestListId found;requestId not found; End; caller not exist
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0007, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0007 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t otherRequestId = 2;
abilitiesRequest->sessionInfoList.emplace_back(otherRequestId, sessionInfo);
abilitiesRequest->doneCount = 1;
mgr->abilitiesRequestMap_.emplace(requestListId, abilitiesRequest);
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0007 end");
}
/**
* @tc.name: HandleAbilitiesRequestDone_0008
* @tc.desc: requestListId found;requestId not found; End; caller exist
*/
HWTEST_F(UIAbilityLifecycleManagerTest, HandleAbilitiesRequestDone_0008, TestSize.Level1)
{
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0008 start");
auto mgr = std::make_shared<UIAbilityLifecycleManager>();
EXPECT_NE(mgr, nullptr);
int32_t requestId = 1;
int32_t requestListId = 1;
sptr<SessionInfo> sessionInfo = new SessionInfo();
auto abilitiesRequest = std::make_shared<AbilitiesRequest>();
EXPECT_NE(abilitiesRequest, nullptr);
int32_t otherRequestId = 2;
abilitiesRequest->sessionInfoList.emplace_back(otherRequestId, sessionInfo);
abilitiesRequest->doneCount = 1;
AbilityRequest abilityRequest;
std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
EXPECT_NE(abilityRecord, nullptr);
sptr<IRemoteObject> callerToken = abilityRecord->GetToken();
abilitiesRequest->callerToken = callerToken;
mgr->abilitiesRequestMap_.emplace(requestListId, abilitiesRequest);
mgr->HandleAbilitiesRequestDone(requestId, requestListId, sessionInfo);
mgr->abilitiesRequestMap_.clear();
TAG_LOGI(AAFwkTag::TEST, "UIAbilityLifecycleManagerTest HandleAbilitiesRequestDone_0008 end");
}
/**
* @tc.name: NotifySCBToRecoveryAfterInterception_0001
* @tc.desc: launchMode is SPECIFIED
@@ -845,8 +845,8 @@ HWTEST_F(UIAbilityLifecycleManagerThirdTest, MoveAbilityToFront_001, TestSize.Le
abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SPECIFIED;
AppUtils::isStartOptionsWithAnimation_ = true;
uiAbilityLifecycleManager->MoveAbilityToFront(abilityRequest, abilityRecord, abilityRecord, nullptr, 0);
SpecifiedRequest specifiedRequest(0, abilityRequest);
uiAbilityLifecycleManager->MoveAbilityToFront(specifiedRequest, abilityRecord, abilityRecord);
auto sessionInfo = abilityRecord->GetSessionInfo();
EXPECT_NE(sessionInfo->processOptions, nullptr);
@@ -870,8 +870,8 @@ HWTEST_F(UIAbilityLifecycleManagerThirdTest, MoveAbilityToFront_002, TestSize.Le
abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::SPECIFIED;
AppUtils::isStartOptionsWithAnimation_ = false;
uiAbilityLifecycleManager->MoveAbilityToFront(abilityRequest, abilityRecord, abilityRecord, nullptr, 0);
SpecifiedRequest specifiedRequest(0, abilityRequest);
uiAbilityLifecycleManager->MoveAbilityToFront(specifiedRequest, abilityRecord, abilityRecord);
auto sessionInfo = abilityRecord->GetSessionInfo();
EXPECT_EQ(sessionInfo->processOptions, nullptr);
@@ -898,13 +898,12 @@ HWTEST_F(UIAbilityLifecycleManagerThirdTest, MoveAbilityToFront_003, TestSize.Le
AppUtils::isStartOptionsWithAnimation_ = false;
auto startOptions = std::make_shared<StartOptions>();
startOptions->windowMode_ = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_SECONDARY;
uiAbilityLifecycleManager->MoveAbilityToFront(abilityRequest, abilityRecord, abilityRecord, startOptions, 0);
SpecifiedRequest specifiedRequest(0, abilityRequest);
specifiedRequest.requestListId = 0;
uiAbilityLifecycleManager->MoveAbilityToFront(specifiedRequest, abilityRecord, abilityRecord);
auto ret = abilityRecord->want_.GetIntParam(Want::PARAM_RESV_WINDOW_MODE, -1);
EXPECT_EQ(ret, AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_SECONDARY);
EXPECT_EQ(ret, AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED);
}
/**
@@ -928,10 +927,8 @@ HWTEST_F(UIAbilityLifecycleManagerThirdTest, MoveAbilityToFront_004, TestSize.Le
AppUtils::isStartOptionsWithAnimation_ = false;
auto startOptions = std::make_shared<StartOptions>();
startOptions->windowMode_ = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_SECONDARY;
uiAbilityLifecycleManager->MoveAbilityToFront(abilityRequest, abilityRecord, abilityRecord, nullptr, 0);
SpecifiedRequest specifiedRequest(0, abilityRequest);
uiAbilityLifecycleManager->MoveAbilityToFront(specifiedRequest, abilityRecord, abilityRecord);
auto ret = abilityRecord->want_.GetIntParam(Want::PARAM_RESV_WINDOW_MODE, -1);
EXPECT_EQ(ret, -1);
@@ -1452,7 +1449,7 @@ HWTEST_F(UIAbilityLifecycleManagerThirdTest, StartSpecifiedAbilityBySCB_002, Tes
abilityRequest.abilityInfo.isStageBasedModel = true;
AppUtils::isStartSpecifiedProcess_ = true;
auto result = uiAbilityLifecycleManager->StartSpecifiedAbilityBySCB(abilityRequest);
EXPECT_EQ(result, uiAbilityLifecycleManager->StartSpecifiedProcessRequest(abilityRequest));
EXPECT_EQ(result, uiAbilityLifecycleManager->StartSpecifiedProcessRequest(abilityRequest, nullptr));
}
/**
@@ -1474,7 +1471,7 @@ HWTEST_F(UIAbilityLifecycleManagerThirdTest, StartSpecifiedProcessRequest_0100,
abilityRequest.abilityInfo.applicationInfo.multiAppMode.multiAppModeType =
AppExecFwk::MultiAppModeType::MULTI_INSTANCE;
abilityRequest.want.SetParam(Want::CREATE_APP_INSTANCE_KEY, true);
auto result = uiAbilityLifecycleManager->StartSpecifiedProcessRequest(abilityRequest);
auto result = uiAbilityLifecycleManager->StartSpecifiedProcessRequest(abilityRequest, nullptr);
EXPECT_EQ(result, ERR_CREATE_INSTANCE_KEY_FAILED);
}
@@ -1497,7 +1494,7 @@ HWTEST_F(UIAbilityLifecycleManagerThirdTest, StartSpecifiedProcessRequest_0200,
abilityRequest.abilityInfo.applicationInfo.multiAppMode.multiAppModeType =
AppExecFwk::MultiAppModeType::MULTI_INSTANCE;
abilityRequest.want.SetParam(Want::CREATE_APP_INSTANCE_KEY, true);
auto result = uiAbilityLifecycleManager->StartSpecifiedProcessRequest(abilityRequest);
auto result = uiAbilityLifecycleManager->StartSpecifiedProcessRequest(abilityRequest, nullptr);
EXPECT_EQ(result, ERR_OK);
}
} // namespace AAFwk