From a3fd16c586983db3e9b9ba132377b57922f1a882 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Wed, 18 Jun 2025 17:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81UIExtensionAbility=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E8=BF=9B=E7=A8=8B=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- services/abilitymgr/abilitymgr.gni | 1 + .../include/ability_connect_manager.h | 21 ++++- .../extension_record_manager.h | 5 +- .../ui_ability_lifecycle_manager.h | 9 -- .../include/utils/request_id_util.h | 32 +++++++ .../src/ability_connect_manager.cpp | 87 ++++++++++++++++++- .../src/ability_manager_service.cpp | 15 ++++ .../extension_record_manager.cpp | 21 ++++- .../ui_ability_lifecycle_manager.cpp | 13 +-- .../abilitymgr/src/utils/request_id_util.cpp | 35 ++++++++ services/appmgr/src/app_mgr_service_inner.cpp | 6 ++ .../BUILD.gn | 3 +- .../BUILD.gn | 3 +- .../BUILD.gn | 3 +- .../specified_ability_service_test/BUILD.gn | 3 +- .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 3 +- .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../mock/src/mock_ability_connect_manager.cpp | 16 ++++ .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../native_child_process_test/BUILD.gn | 1 + .../status_bar_delegate_manager_test/BUILD.gn | 3 +- .../BUILD.gn | 1 + .../BUILD.gn | 3 +- utils/server/startup/src/startup_util.cpp | 3 +- 29 files changed, 260 insertions(+), 34 deletions(-) create mode 100644 services/abilitymgr/include/utils/request_id_util.h create mode 100644 services/abilitymgr/src/utils/request_id_util.cpp diff --git a/services/abilitymgr/abilitymgr.gni b/services/abilitymgr/abilitymgr.gni index 3f646c121f6..510c9014f19 100644 --- a/services/abilitymgr/abilitymgr.gni +++ b/services/abilitymgr/abilitymgr.gni @@ -152,6 +152,7 @@ abilityms_files = [ "src/exit_info_data_manager.cpp", #utils + "src/utils/request_id_util.cpp", "src/utils/ability_event_util.cpp", "src/utils/ability_permission_util.cpp", "src/utils/app_mgr_util.cpp", diff --git a/services/abilitymgr/include/ability_connect_manager.h b/services/abilitymgr/include/ability_connect_manager.h index d52b29295d9..3f85f0d74a3 100644 --- a/services/abilitymgr/include/ability_connect_manager.h +++ b/services/abilitymgr/include/ability_connect_manager.h @@ -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 @@ -63,6 +63,13 @@ public: explicit AbilityConnectManager(int userId); virtual ~AbilityConnectManager(); + struct LoadAbilityContext { + std::shared_ptr loadParam; + std::shared_ptr abilityInfo; + std::shared_ptr appInfo; + std::shared_ptr want; + }; + /** * StartAbility with request. * @@ -386,6 +393,11 @@ public: */ std::shared_ptr GetServiceRecordByAbilityRequest(const AbilityRequest &abilityRequest); + bool HasRequestIdInLoadAbilityQueue(int32_t requestId) const; + void OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId); + void OnStartSpecifiedProcessTimeoutResponse(int32_t requestId); + void StartSpecifiedProcess(const LoadAbilityContext &context, const std::shared_ptr &abilityRecord); + private: /** * StartAbilityLocked with request. @@ -428,8 +440,9 @@ private: * @param abilityRecord, the ptr of the ability to load. */ void LoadAbility(const std::shared_ptr &abilityRecord, - std::function&)> updateRecordCallback = nullptr); - + std::function &)> updateRecordCallback = nullptr); + void HandleLoadAbilityOrStartSpecifiedProcess( + const AbilityRuntime::LoadParam &loadParam, const std::shared_ptr &abilityRecord); /** * ConnectAbility.Schedule connect ability * @@ -726,6 +739,8 @@ private: std::mutex uiExtensionMapMutex_; std::mutex windowExtensionMapMutex_; std::mutex startServiceReqListLock_; + ffrt::mutex loadAbilityQueueLock_; + std::map> loadAbilityQueue_; DISALLOW_COPY_AND_MOVE(AbilityConnectManager); }; diff --git a/services/abilitymgr/include/extension_record/extension_record_manager.h b/services/abilitymgr/include/extension_record/extension_record_manager.h index f45a6c553d0..40de7760d76 100644 --- a/services/abilitymgr/include/extension_record/extension_record_manager.h +++ b/services/abilitymgr/include/extension_record/extension_record_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 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 @@ -164,7 +164,8 @@ private: std::shared_ptr &extensionRecord, bool &isLoaded); int32_t UpdateProcessName(const AAFwk::AbilityRequest &abilityRequest, std::shared_ptr &record); - + int32_t SetAbilityProcessName(const AAFwk::AbilityRequest &abilityRequest, + const std::shared_ptr &abilityRecord, std::shared_ptr &extensionRecord); bool IsHostSpecifiedProcessValid(const AAFwk::AbilityRequest &abilityRequest, std::shared_ptr &record, const std::string &process); }; diff --git a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h index c6711837da5..e01799f159b 100644 --- a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h +++ b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h @@ -496,14 +496,6 @@ private: bool HasAbilityRequest(const AbilityRequest &abilityRequest); void AddAbilityRequest(const AbilityRequest &abilityRequest, int32_t requestId); void RemoveAbilityRequest(int32_t requestId); - inline int32_t GetRequestId() - { - if (requestId_ == 0 || requestId_ == INT32_MAX) { - requestId_ = 1; - } - return requestId_++; - } - void AddSpecifiedRequest(std::shared_ptr request); void StartSpecifiedRequest(SpecifiedRequest &specifiedRequest); std::shared_ptr PopAndGetNextSpecified(int32_t requestId); @@ -536,7 +528,6 @@ private: std::unordered_map, std::list> callRequestCache_; std::list> terminateAbilityList_; sptr rootSceneSession_; - int32_t requestId_ = 0; sptr handler_; ffrt::mutex statusBarDelegateManagerLock_; std::shared_ptr statusBarDelegateManager_; diff --git a/services/abilitymgr/include/utils/request_id_util.h b/services/abilitymgr/include/utils/request_id_util.h new file mode 100644 index 00000000000..57dfb3f60d1 --- /dev/null +++ b/services/abilitymgr/include/utils/request_id_util.h @@ -0,0 +1,32 @@ +/* + * 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. + */ + +#pragma once +#include +#include + +namespace OHOS { +namespace AAFwk { + +class RequestIdUtil { +public: + static int32_t GetRequestId(); + +private: + static std::atomic requestId_; +}; + +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index a61d8618da7..6f43ac7ce2c 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -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 @@ -30,6 +30,7 @@ #include "int_wrapper.h" #include "multi_instance_utils.h" #include "param.h" +#include "request_id_util.h" #include "res_sched_util.h" #include "session/host/include/zidl/session_interface.h" #include "startup_util.h" @@ -81,6 +82,7 @@ constexpr const char* FROZEN_WHITE_DIALOG = "com.huawei.hmos.huaweicast"; constexpr char BUNDLE_NAME_DIALOG[] = "com.ohos.amsdialog"; constexpr char ABILITY_NAME_ASSERT_FAULT_DIALOG[] = "AssertFaultDialog"; constexpr const char* WANT_PARAMS_APP_RESTART_FLAG = "ohos.aafwk.app.restart"; +constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag"; constexpr int32_t HALF_TIMEOUT = 2; constexpr uint32_t PROCESS_MODE_RUN_WITH_MAIN_PROCESS = @@ -1617,10 +1619,87 @@ void AbilityConnectManager::LoadAbility(const std::shared_ptr &ab loadParam.customProcessFlag = abilityRecord->GetCustomProcessFlag(); loadParam.extensionProcessMode = abilityRecord->GetExtensionProcessMode(); SetExtensionLoadParam(loadParam, abilityRecord); - AbilityRuntime::FreezeUtil::GetInstance().AddLifecycleEvent(loadParam.token, - "AbilityConnectManager::LoadAbility"); + AbilityRuntime::FreezeUtil::GetInstance().AddLifecycleEvent(loadParam.token, "AbilityConnectManager::LoadAbility"); + HandleLoadAbilityOrStartSpecifiedProcess(loadParam, abilityRecord); +} + +void AbilityConnectManager::HandleLoadAbilityOrStartSpecifiedProcess( + const AbilityRuntime::LoadParam &loadParam, const std::shared_ptr &abilityRecord) +{ + if (abilityRecord->GetAbilityInfo().isolationProcess && + AAFwk::UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().extensionAbilityType)) { + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Is UIExtension and isolationProcess, StartSpecifiedProcess"); + LoadAbilityContext context{ std::make_shared(loadParam), + std::make_shared(abilityRecord->GetAbilityInfo()), + std::make_shared(abilityRecord->GetApplicationInfo()), + std::make_shared(abilityRecord->GetWant()) }; + StartSpecifiedProcess(context, abilityRecord); + } else { + DelayedSingleton::GetInstance()->LoadAbility( + loadParam, abilityRecord->GetAbilityInfo(), abilityRecord->GetApplicationInfo(), abilityRecord->GetWant()); + } +} + +void AbilityConnectManager::StartSpecifiedProcess( + const LoadAbilityContext &context, const std::shared_ptr &abilityRecord) +{ + std::lock_guard guard(loadAbilityQueueLock_); + auto requestId = RequestIdUtil::GetRequestId(); + loadAbilityQueue_[requestId].push_back(context); + if (loadAbilityQueue_[requestId].size() > 1) { + return; + } + DelayedSingleton::GetInstance()->StartSpecifiedProcess( + *context.want, *context.abilityInfo, requestId); +} + +void AbilityConnectManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId) +{ + std::lock_guard guard(loadAbilityQueueLock_); + auto &queue = loadAbilityQueue_[requestId]; + if (!queue.empty()) { + queue.pop_front(); + if (queue.empty()) { + loadAbilityQueue_.erase(requestId); + } else { + auto &front = queue.front(); + front.want->SetParam(PARAM_SPECIFIED_PROCESS_FLAG, flag); + TAG_LOGI(AAFwkTag::ABILITYMGR, "OnStartSpecifiedProcessResponse, requestId: %{public}d, flag: %{public}s", + requestId, flag.c_str()); + DelayedSingleton::GetInstance()->LoadAbility( + *front.loadParam, *(front.abilityInfo), *(front.appInfo), *(front.want)); + } + } +} + +void AbilityConnectManager::OnStartSpecifiedProcessTimeoutResponse(int32_t requestId) +{ + std::lock_guard guard(loadAbilityQueueLock_); + TAG_LOGI(AAFwkTag::ABILITYMGR, "OnStartSpecifiedProcessTimeout requestId: %{public}d", requestId); + + auto it = loadAbilityQueue_.find(requestId); + if (it == loadAbilityQueue_.end() || it->second.empty()) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Timeout: no queue for requestId %{public}d", requestId); + return; + } + it->second.pop_front(); + if (it->second.empty()) { + loadAbilityQueue_.erase(it); + TAG_LOGD(AAFwkTag::ABILITYMGR, "Timeout: queue empty, erase requestId %{public}d", requestId); + return; + } + + auto &front = it->second.front(); DelayedSingleton::GetInstance()->LoadAbility( - loadParam, abilityRecord->GetAbilityInfo(), abilityRecord->GetApplicationInfo(), abilityRecord->GetWant()); + *front.loadParam, *(front.abilityInfo), *(front.appInfo), *(front.want)); +} + +bool AbilityConnectManager::HasRequestIdInLoadAbilityQueue(int32_t requestId) const +{ + if (loadAbilityQueue_.find(requestId) == loadAbilityQueue_.end()) { + return false; + } + return true; } void AbilityConnectManager::SetExtensionLoadParam(AbilityRuntime::LoadParam &loadParam, diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 87192be9a16..e825264b976 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -8450,6 +8450,14 @@ void AbilityManagerService::OnStartSpecifiedAbilityTimeoutResponse(int32_t reque void AbilityManagerService::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId) { TAG_LOGD(AAFwkTag::ABILITYMGR, "flag = %{public}s", flag.c_str()); + auto connectManager = GetCurrentConnectManager(); + CHECK_POINTER(connectManager); + if (connectManager->HasRequestIdInLoadAbilityQueue(requestId)) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "uiextension StartSpecifiedProcessResponse, requestId = %{public}d", requestId); + connectManager->OnStartSpecifiedProcessResponse(flag, requestId); + return; + } + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { auto uiAbilityManager = GetCurrentUIAbilityManager(); CHECK_POINTER(uiAbilityManager); @@ -8461,6 +8469,13 @@ void AbilityManagerService::OnStartSpecifiedProcessResponse(const std::string &f void AbilityManagerService::OnStartSpecifiedProcessTimeoutResponse(int32_t requestId) { TAG_LOGI(AAFwkTag::ABILITYMGR, "OnStartSpecifiedProcessTimeoutResponse %{public}d", requestId); + auto connectManager = GetCurrentConnectManager(); + CHECK_POINTER(connectManager); + if (connectManager->HasRequestIdInLoadAbilityQueue(requestId)) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "uiextension StartSpecifiedProcessTimeoutResponse"); + connectManager->OnStartSpecifiedProcessTimeoutResponse(requestId); + return; + } if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { auto uiAbilityManager = GetCurrentUIAbilityManager(); CHECK_POINTER(uiAbilityManager); diff --git a/services/abilitymgr/src/extension_record/extension_record_manager.cpp b/services/abilitymgr/src/extension_record/extension_record_manager.cpp index a4167c102ff..c60ec32d708 100644 --- a/services/abilitymgr/src/extension_record/extension_record_manager.cpp +++ b/services/abilitymgr/src/extension_record/extension_record_manager.cpp @@ -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 @@ -456,7 +456,7 @@ int32_t ExtensionRecordManager::GetOrCreateExtensionRecordInner(const AAFwk::Abi extensionRecord->hostBundleName_ = hostBundleName; abilityRecord->SetOwnerMissionUserId(userId_); abilityRecord->SetUIExtensionAbilityId(extensionRecordId); - result = UpdateProcessName(abilityRequest, extensionRecord); + result = SetAbilityProcessName(abilityRequest, abilityRecord, extensionRecord); if (result != ERR_OK) { return result; } @@ -468,6 +468,23 @@ int32_t ExtensionRecordManager::GetOrCreateExtensionRecordInner(const AAFwk::Abi return ERR_OK; } +int32_t ExtensionRecordManager::SetAbilityProcessName(const AAFwk::AbilityRequest &abilityRequest, + const std::shared_ptr &abilityRecord, std::shared_ptr &extensionRecord) +{ + if (abilityRequest.abilityInfo.isolationProcess && + AAFwk::UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().extensionAbilityType)) { + abilityRecord->SetProcessName( + abilityRequest.abilityInfo.bundleName + abilityRequest.abilityInfo.extensionTypeName); + return ERR_OK; + } else { + int32_t result = UpdateProcessName(abilityRequest, extensionRecord); + if (result != ERR_OK) { + return result; + } + return ERR_OK; + } +} + int32_t ExtensionRecordManager::StartAbility(const AAFwk::AbilityRequest &abilityRequest) { return ERR_OK; diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index 1682b45bcf1..54607bf7f57 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -43,6 +43,7 @@ #include "ability_first_frame_state_observer_manager.h" #endif #include "hidden_start_observer_manager.h" +#include "request_id_util.h" namespace OHOS { using AbilityRuntime::FreezeUtil; @@ -592,7 +593,7 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(AbilityRequest &ability return StartSpecifiedProcessRequest(abilityRequest); } const auto &abilityInfo = abilityRequest.abilityInfo; - auto requestId = GetRequestId(); + auto requestId = RequestIdUtil::GetRequestId(); auto isPlugin = StartupUtil::IsStartPlugin(abilityRequest.want); auto isSpecified = (abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED); if (isSpecified && !isPlugin) { @@ -650,7 +651,7 @@ int32_t UIAbilityLifecycleManager::NotifySCBToRecoveryAfterInterception(const Ab auto isPlugin = StartupUtil::IsStartPlugin(abilityRequest.want); auto isSpecified = (abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED); if (isSpecified && !isPlugin) { - auto specifiedRequest = std::make_shared(GetRequestId(), abilityRequest); + auto specifiedRequest = std::make_shared(RequestIdUtil::GetRequestId(), abilityRequest); specifiedRequest->preCreateProcessName = true; AddSpecifiedRequest(specifiedRequest); return ERR_OK; @@ -1234,7 +1235,7 @@ int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRe sessionInfo->reuse = reuse; sessionInfo->uiAbilityId = uiAbilityRecord->GetAbilityRecordId(); sessionInfo->isAtomicService = (abilityInfo.applicationInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE); - sessionInfo->requestId = GetRequestId(); + sessionInfo->requestId = RequestIdUtil::GetRequestId(); if (abilityRequest.want.GetBoolParam(Want::PARAM_RESV_CALL_TO_FOREGROUND, false)) { sessionInfo->state = CallToState::FOREGROUND; } else { @@ -2262,7 +2263,7 @@ int32_t UIAbilityLifecycleManager::StartSpecifiedProcessRequest(const AbilityReq } const_cast(abilityRequest).want.SetParam(Want::APP_INSTANCE_KEY, instanceKey); } - auto requestId = GetRequestId(); + auto requestId = RequestIdUtil::GetRequestId(); TAG_LOGI(AAFwkTag::ABILITYMGR, "StartSpecifiedProcess, requestId:%{public}d", requestId); auto specifiedRequest = std::make_shared(requestId, abilityRequest); specifiedRequest->specifiedProcessState = SpecifiedProcessState::STATE_PROCESS; @@ -2281,7 +2282,7 @@ void UIAbilityLifecycleManager::StartSpecifiedAbilityBySCB(const Want &want, Abi StartSpecifiedProcessRequest(abilityRequest); return; } - AddSpecifiedRequest(std::make_shared(GetRequestId(), abilityRequest)); + AddSpecifiedRequest(std::make_shared(RequestIdUtil::GetRequestId(), abilityRequest)); } void UIAbilityLifecycleManager::NotifyRestartSpecifiedAbility(const AbilityRequest &request, @@ -3789,7 +3790,7 @@ int32_t UIAbilityLifecycleManager::RevokeDelegator(sptr token) auto abilityInfo = abilityRecord->GetAbilityInfo(); auto isSpecified = (abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED); if (isSpecified) { - auto requestId = GetRequestId(); + auto requestId = RequestIdUtil::GetRequestId(); hookSpecifiedMap_.emplace(requestId, abilityRecord); DelayedSingleton::GetInstance()->StartSpecifiedAbility(abilityRecord->GetWant(), abilityInfo, requestId); diff --git a/services/abilitymgr/src/utils/request_id_util.cpp b/services/abilitymgr/src/utils/request_id_util.cpp new file mode 100644 index 00000000000..d1ae75fd505 --- /dev/null +++ b/services/abilitymgr/src/utils/request_id_util.cpp @@ -0,0 +1,35 @@ +/* + * 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 "utils/request_id_util.h" + +namespace OHOS { +namespace AAFwk { + +std::atomic RequestIdUtil::requestId_{ 1 }; + +int32_t RequestIdUtil::GetRequestId() +{ + int32_t id = requestId_.fetch_add(1, std::memory_order_relaxed); + if (id == 0 || id == INT32_MAX) { + int32_t expect = id + 1; + requestId_.compare_exchange_strong(expect, 1); + id = requestId_.fetch_add(1, std::memory_order_relaxed); + } + return id; +} + +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index d0e90aca3f7..f2df7492b2d 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1170,6 +1170,12 @@ std::string AppMgrServiceInner::GetSpecifiedProcessFlag(const AbilityInfo &abili specifiedProcessFlag = want.GetStringParam(PARAM_SPECIFIED_PROCESS_FLAG); TAG_LOGI(AAFwkTag::APPMGR, "specifiedProcessFlag: %{public}s", specifiedProcessFlag.c_str()); } + if (abilityInfo.isolationProcess && + AAFwk::UIExtensionUtils::IsUIExtension(abilityInfo.extensionAbilityType)) { + specifiedProcessFlag = want.GetStringParam(PARAM_SPECIFIED_PROCESS_FLAG); + TAG_LOGI(AAFwkTag::APPMGR, "UIExtension process, specifiedProcessFlag: %{public}s", + specifiedProcessFlag.c_str()); + } return specifiedProcessFlag; } diff --git a/test/fuzztest/abilitymgrappexitreasonhelper_fuzzer/BUILD.gn b/test/fuzztest/abilitymgrappexitreasonhelper_fuzzer/BUILD.gn index 2d8b71bfe1f..457cf74e728 100644 --- a/test/fuzztest/abilitymgrappexitreasonhelper_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymgrappexitreasonhelper_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -48,6 +48,7 @@ ohos_fuzztest("AbilityMgrAppExitReasonHelperFuzzTest") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_services_path}/common/src/event_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/ffrt_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/queue_task_handler_wrap.cpp", diff --git a/test/fuzztest/uiabilitylifecyclemanagera_fuzzer/BUILD.gn b/test/fuzztest/uiabilitylifecyclemanagera_fuzzer/BUILD.gn index 2b186d7e573..6721a19e7eb 100644 --- a/test/fuzztest/uiabilitylifecyclemanagera_fuzzer/BUILD.gn +++ b/test/fuzztest/uiabilitylifecyclemanagera_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -38,6 +38,7 @@ ohos_fuzztest("UiAbilityLifeCycleManagerAFuzzTest") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "uiabilitylifecyclemanagera_fuzzer.cpp", ] diff --git a/test/fuzztest/uiabilitylifecyclemanagerb_fuzzer/BUILD.gn b/test/fuzztest/uiabilitylifecyclemanagerb_fuzzer/BUILD.gn index 28ea5577cf3..ebecb1b7992 100644 --- a/test/fuzztest/uiabilitylifecyclemanagerb_fuzzer/BUILD.gn +++ b/test/fuzztest/uiabilitylifecyclemanagerb_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -39,6 +39,7 @@ ohos_fuzztest("UiAbilityLifeCycleManagerBFuzzTest") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "uiabilitylifecyclemanagerb_fuzzer.cpp", ] diff --git a/test/moduletest/common/ams/specified_ability_service_test/BUILD.gn b/test/moduletest/common/ams/specified_ability_service_test/BUILD.gn index eaf02d3fcf9..e89768af579 100644 --- a/test/moduletest/common/ams/specified_ability_service_test/BUILD.gn +++ b/test/moduletest/common/ams/specified_ability_service_test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024 Huawei Device Co., Ltd. +# Copyright (c) 2022-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 @@ -28,6 +28,7 @@ ohos_moduletest("specified_ability_service_test") { "${ability_runtime_services_path}/abilitymgr/src/start_window_option.cpp", "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "specified_ability_service_test.cpp", ] diff --git a/test/unittest/ability_manager_service_eleven_test/BUILD.gn b/test/unittest/ability_manager_service_eleven_test/BUILD.gn index 6337c42c35a..81b99d53d7c 100644 --- a/test/unittest/ability_manager_service_eleven_test/BUILD.gn +++ b/test/unittest/ability_manager_service_eleven_test/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("ability_manager_service_eleven_test") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/window_options_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "ability_manager_service_eleven_test.cpp", "mock/src/mock_my_flag.cpp", "mock/src/mock_permission_verification.cpp", diff --git a/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn b/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn index 5728c0916d6..ce274a014b3 100644 --- a/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_fourteenth_test/BUILD.gn @@ -198,6 +198,7 @@ ohos_unittest("ability_manager_service_fourteenth_test") { "${ability_runtime_services_path}/abilitymgr/src/utils/uri_utils.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/want_utils.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/window_options_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/want_receiver_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/want_receiver_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/want_sender_info.cpp", diff --git a/test/unittest/ability_manager_service_sixth_test/BUILD.gn b/test/unittest/ability_manager_service_sixth_test/BUILD.gn index 5985952b21e..bb8166d642b 100644 --- a/test/unittest/ability_manager_service_sixth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_sixth_test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024 Huawei Device Co., Ltd. +# Copyright (c) 2022-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 @@ -46,6 +46,7 @@ ohos_unittest("ability_manager_service_sixth_test") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_test_path}/mock/task_handler_wrap_mock/src/mock_task_handler_wrap.cpp", "ability_manager_service_sixth_test.cpp", "mock/src/mock_my_flag.cpp", diff --git a/test/unittest/ability_manager_service_third_test/BUILD.gn b/test/unittest/ability_manager_service_third_test/BUILD.gn index f309cd0d53f..da5f3fc4c1e 100644 --- a/test/unittest/ability_manager_service_third_test/BUILD.gn +++ b/test/unittest/ability_manager_service_third_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("ability_manager_service_third_test") { "${ability_runtime_services_path}/common/src/queue_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/task_handler_wrap.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_manager_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", ] sources += abilityms_files diff --git a/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn b/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn index 0637a9d6e95..67bcc1e0f56 100644 --- a/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_thirteenth_test/BUILD.gn @@ -185,6 +185,7 @@ ohos_unittest("ability_manager_service_thirteenth_test") { "${ability_runtime_services_path}/abilitymgr/src/utils/app_mgr_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/dms_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/dump_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/extension_permissions_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/hidden_start_utils.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/keep_alive_utils.cpp", diff --git a/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp b/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp index c206a7fe0c0..79bc3b35f5e 100644 --- a/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp +++ b/test/unittest/ability_manager_service_thirteenth_test/mock/src/mock_ability_connect_manager.cpp @@ -26,6 +26,22 @@ AbilityConnectManager::AbilityConnectManager(int userId) : userId_(userId) AbilityConnectManager::~AbilityConnectManager() {} +bool AbilityConnectManager::HasRequestIdInLoadAbilityQueue(int32_t requestId) const +{ + return false; +} + +void AbilityConnectManager::OnStartSpecifiedProcessResponse(const std::string &flag, int32_t requestId) +{} + +void AbilityConnectManager::OnStartSpecifiedProcessTimeoutResponse(int32_t requestId) +{} + +void AbilityConnectManager::StartSpecifiedProcess( + const LoadAbilityContext &context, const std::shared_ptr &abilityRecord) +{} + + int AbilityConnectManager::StartAbility(const AbilityRequest &abilityRequest) { return 0; diff --git a/test/unittest/app_exit_reason_helper_fourth_test/BUILD.gn b/test/unittest/app_exit_reason_helper_fourth_test/BUILD.gn index 0893709a1e6..f94798e77b6 100644 --- a/test/unittest/app_exit_reason_helper_fourth_test/BUILD.gn +++ b/test/unittest/app_exit_reason_helper_fourth_test/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("app_exit_reason_helper_fourth_test") { "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/app_mgr_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "app_exit_reason_helper_fourth_test.cpp", "mock/src/bundle_mgr_helper.cpp", "mock/src/mock_app_scheduler.cpp", diff --git a/test/unittest/app_exit_reason_helper_second_test/BUILD.gn b/test/unittest/app_exit_reason_helper_second_test/BUILD.gn index fde875216b1..0fd6a0dcf28 100644 --- a/test/unittest/app_exit_reason_helper_second_test/BUILD.gn +++ b/test/unittest/app_exit_reason_helper_second_test/BUILD.gn @@ -43,6 +43,7 @@ ohos_unittest("app_exit_reason_helper_second_test") { "${ability_runtime_services_path}/abilitymgr/src/start_window_option.cpp", "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "app_exit_reason_helper_second_test.cpp", ] diff --git a/test/unittest/app_exit_reason_helper_third_test/BUILD.gn b/test/unittest/app_exit_reason_helper_third_test/BUILD.gn index a843849286d..d7fb3a42d71 100644 --- a/test/unittest/app_exit_reason_helper_third_test/BUILD.gn +++ b/test/unittest/app_exit_reason_helper_third_test/BUILD.gn @@ -47,6 +47,7 @@ ohos_unittest("app_exit_reason_helper_third_test") { "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", "${ability_runtime_services_path}/abilitymgr/src/ability_start_with_wait_observer_manager/ability_start_with_wait_observer_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp", "app_exit_reason_helper_third_test.cpp", ] diff --git a/test/unittest/native_child_process_test/BUILD.gn b/test/unittest/native_child_process_test/BUILD.gn index b8b179629b7..eb3c4ee3b76 100644 --- a/test/unittest/native_child_process_test/BUILD.gn +++ b/test/unittest/native_child_process_test/BUILD.gn @@ -51,6 +51,7 @@ ohos_unittest("native_child_process_test") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_services_path}/common/src/event_report.cpp", "native_child_process_test.cpp", ] diff --git a/test/unittest/status_bar_delegate_manager_test/BUILD.gn b/test/unittest/status_bar_delegate_manager_test/BUILD.gn index 53bcb6ce081..5fb460317f2 100644 --- a/test/unittest/status_bar_delegate_manager_test/BUILD.gn +++ b/test/unittest/status_bar_delegate_manager_test/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -40,6 +40,7 @@ ohos_unittest("status_bar_delegate_manager_test") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_services_path}/common/src/event_report.cpp", "status_bar_delegate_manager_test.cpp", ] diff --git a/test/unittest/ui_ability_lifecycle_manager_second_test/BUILD.gn b/test/unittest/ui_ability_lifecycle_manager_second_test/BUILD.gn index ad6b0a0c3d9..9ddaf1dc4a2 100644 --- a/test/unittest/ui_ability_lifecycle_manager_second_test/BUILD.gn +++ b/test/unittest/ui_ability_lifecycle_manager_second_test/BUILD.gn @@ -48,6 +48,7 @@ ohos_unittest("ui_ability_lifecycle_manager_second_test") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_services_path}/common/src/event_report.cpp", "mock/src/app_utils.cpp", "mock/src/mock_my_flag.cpp", diff --git a/test/unittest/ui_ability_lifecycle_manager_test/BUILD.gn b/test/unittest/ui_ability_lifecycle_manager_test/BUILD.gn index 71428d24e0c..a9e8116224a 100644 --- a/test/unittest/ui_ability_lifecycle_manager_test/BUILD.gn +++ b/test/unittest/ui_ability_lifecycle_manager_test/BUILD.gn @@ -1,4 +1,4 @@ -# 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 @@ -44,6 +44,7 @@ ohos_unittest("ui_ability_lifecycle_manager_test") { "${ability_runtime_services_path}/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/request_id_util.cpp", "${ability_runtime_services_path}/common/src/event_report.cpp", "mock/include/ipc_skeleton.cpp", "ui_ability_lifecycle_manager_test.cpp", diff --git a/utils/server/startup/src/startup_util.cpp b/utils/server/startup/src/startup_util.cpp index 9f176c267e0..54e590daaf9 100644 --- a/utils/server/startup/src/startup_util.cpp +++ b/utils/server/startup/src/startup_util.cpp @@ -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 @@ -96,6 +96,7 @@ void StartupUtil::InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo abilityInfo.codeLanguage = extensionInfo.codeLanguage; abilityInfo.type = AppExecFwk::AbilityType::EXTENSION; abilityInfo.extensionTypeName = extensionInfo.extensionTypeName; + abilityInfo.isolationProcess = extensionInfo.isolationProcess; if (!extensionInfo.hapPath.empty()) { abilityInfo.hapPath = extensionInfo.hapPath; } -- Gitee