From d3716e8782e11ffb7556d88563952207e646f887 Mon Sep 17 00:00:00 2001 From: tantingting Date: Wed, 11 Sep 2024 14:21:55 +0800 Subject: [PATCH 01/26] Add tdd Signed-off-by: tantingting --- .../configuration_test/configuration_test.cpp | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/test/unittest/configuration_test/configuration_test.cpp b/test/unittest/configuration_test/configuration_test.cpp index 2950ce8d26..1d67f63d5e 100644 --- a/test/unittest/configuration_test/configuration_test.cpp +++ b/test/unittest/configuration_test/configuration_test.cpp @@ -583,6 +583,49 @@ HWTEST_F(ConfigurationTest, InitDisplayConfig_0100, TestSize.Level1) EXPECT_EQ(ConvertDirection(originDirection), resConfig->GetDirection()); } +/** + * @tc.name: InitDisplayConfig_0200 + * @tc.desc: Init display config. + * @tc.type: FUNC + */ +HWTEST_F(ConfigurationTest, InitDisplayConfig_0200, TestSize.Level1) +{ + auto configUtils = std::make_shared(); + ASSERT_NE(configUtils, nullptr); + + int displayId = Rosen::WindowScene::DEFAULT_DISPLAY_ID; + float originDensity; + std::string originDirection; + auto ret = configUtils->GetDisplayConfig(displayId, originDensity, originDirection); + EXPECT_EQ(ret, true); + + configUtils->InitDisplayConfig(nullptr, nullptr, displayId, originDensity, 0); + + AppExecFwk::Configuration originConfig; + auto configuration = std::make_shared(originConfig); + ASSERT_NE(configuration, nullptr); + configUtils->InitDisplayConfig(configuration, nullptr, displayId, originDensity, 0); + + std::shared_ptr resourceManager(Global::Resource::CreateResourceManager()); + ASSERT_NE(resourceManager, nullptr); + InitResourceManager(resourceManager); + configUtils->InitDisplayConfig(configuration, resourceManager, displayId, originDensity, 0); + + // check configurtion + std::string displayIdStr = configuration->GetItem(ConfigurationInner::APPLICATION_DISPLAYID); + EXPECT_EQ(displayIdStr, std::to_string(displayId)); + std::string densityStr = configuration->GetItem(displayId, ConfigurationInner::APPLICATION_DENSITYDPI); + EXPECT_EQ(densityStr, GetDensityStr(originDensity)); + std::string directionStr = configuration->GetItem(displayId, ConfigurationInner::APPLICATION_DIRECTION); + EXPECT_EQ(directionStr, ConfigurationInner::DIRECTION_VERTICAL); + + // check resourcemanager + std::unique_ptr resConfig(Global::Resource::CreateResConfig()); + resourceManager->GetResConfig(*resConfig); + EXPECT_EQ(originDensity, resConfig->GetScreenDensity()); + EXPECT_EQ(ConvertDirection(ConfigurationInner::DIRECTION_VERTICAL), resConfig->GetDirection()); +} + /** * @tc.name: UpdateDisplayConfig_0100 * @tc.desc: Update display config with changed config. @@ -662,5 +705,86 @@ HWTEST_F(ConfigurationTest, UpdateDisplayConfig_0200, TestSize.Level1) configUtils->UpdateDisplayConfig(displayId, configuration, resourceManager, configChanged); EXPECT_EQ(configChanged, false); } + +/** + * @tc.name: UpdateDisplayConfig_0300 + * @tc.desc: Update display config with changed config. + * @tc.type: FUNC + */ +HWTEST_F(ConfigurationTest, UpdateDisplayConfig_0300, TestSize.Level1) +{ + auto configUtils = std::make_shared(); + ASSERT_NE(configUtils, nullptr); + + int displayId = Rosen::WindowScene::DEFAULT_DISPLAY_ID; + float originDensity; + std::string originDirection; + auto ret = configUtils->GetDisplayConfig(displayId, originDensity, originDirection); + EXPECT_EQ(ret, true); + + bool configChanged = false; + configChanged = configUtils->UpdateDisplayConfig( + nullptr, nullptr, displayId, originDensity, Rosen::DisplayOrientation::PORTRAIT); + EXPECT_EQ(configChanged, false); + + AppExecFwk::Configuration originConfig; + auto configuration = std::make_shared(originConfig); + ASSERT_NE(configuration, nullptr); + configChanged = configUtils->UpdateDisplayConfig( + configuration, nullptr, displayId, originDensity, Rosen::DisplayOrientation::PORTRAIT); + EXPECT_EQ(configChanged, false); + + std::shared_ptr resourceManager(Global::Resource::CreateResourceManager()); + ASSERT_NE(resourceManager, nullptr); + InitResourceManager(resourceManager); + configChanged = configUtils->UpdateDisplayConfig( + configuration, resourceManager, displayId, originDensity, Rosen::DisplayOrientation::PORTRAIT); + EXPECT_EQ(configChanged, true); + + // check configurtion + std::string densityStr = configuration->GetItem(displayId, ConfigurationInner::APPLICATION_DENSITYDPI); + EXPECT_EQ(densityStr, GetDensityStr(originDensity)); + std::string directionStr = configuration->GetItem(displayId, ConfigurationInner::APPLICATION_DIRECTION); + EXPECT_EQ(directionStr, ConfigurationInner::DIRECTION_VERTICAL); + + // check resourcemanager + std::unique_ptr resConfig(Global::Resource::CreateResConfig()); + resourceManager->GetResConfig(*resConfig); + EXPECT_EQ(originDensity, resConfig->GetScreenDensity()); + EXPECT_EQ(ConvertDirection(ConfigurationInner::DIRECTION_VERTICAL), resConfig->GetDirection()); +} + +/** + * @tc.name: UpdateDisplayConfig_0400 + * @tc.desc: Update display config with unchanged config. + * @tc.type: FUNC + */ +HWTEST_F(ConfigurationTest, UpdateDisplayConfig_0400, TestSize.Level1) +{ + auto configUtils = std::make_shared(); + ASSERT_NE(configUtils, nullptr); + + int displayId = Rosen::WindowScene::DEFAULT_DISPLAY_ID; + float originDensity; + std::string originDirection; + auto ret = configUtils->GetDisplayConfig(displayId, originDensity, originDirection); + EXPECT_EQ(ret, true); + + AppExecFwk::Configuration originConfig; + auto configuration = std::make_shared(originConfig); + ASSERT_NE(configuration, nullptr); + + // Add configuration. + configuration->AddItem(displayId, ConfigurationInner::APPLICATION_DENSITYDPI, GetDensityStr(originDensity)); + configuration->AddItem( + displayId, ConfigurationInner::APPLICATION_DIRECTION, ConfigurationInner::DIRECTION_VERTICAL); + configuration->AddItem(ConfigurationInner::APPLICATION_DISPLAYID, std::to_string(displayId)); + + std::shared_ptr resourceManager(Global::Resource::CreateResourceManager()); + ASSERT_NE(resourceManager, nullptr); + bool configChanged = configUtils->UpdateDisplayConfig( + configuration, resourceManager, displayId, originDensity, Rosen::DisplayOrientation::PORTRAIT); + EXPECT_EQ(configChanged, false); +} } // namespace AAFwk } // namespace OHOS From b1b91f7ca4ee9a3ddf336256677b02c3c6d035de Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 11 Sep 2024 09:54:48 +0800 Subject: [PATCH 02/26] =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=AA=97=E5=8F=A3getHo?= =?UTF-8?q?stWindowId=20=E8=8E=B7=E5=8F=96=20hostwindowID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../src/ability_manager_service.cpp | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 20f023c8f5..78bbb52236 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -60,6 +60,7 @@ #include "restart_app_manager.h" #include "scene_board_judgement.h" #include "server_constant.h" +#include "session_manager_lite.h" #include "softbus_bus_center.h" #include "start_ability_handler/start_ability_sandbox_savefile.h" #include "start_ability_utils.h" @@ -12139,24 +12140,52 @@ void AbilityManagerService::ReportCleanSession(const sptr &sessionI void AbilityManagerService::SetAbilityRequestSessionInfo(AbilityRequest &abilityRequest, AppExecFwk::ExtensionAbilityType extensionType) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "called"); if (extensionType != AppExecFwk::ExtensionAbilityType::UI_SERVICE) { return; } abilityRequest.want.RemoveParam(WANT_PARAMS_HOST_WINDOW_ID_KEY); auto callerAbilityRecord = Token::GetAbilityRecordByToken(abilityRequest.callerToken); if(callerAbilityRecord != nullptr) { - sptr callerSessionInfo = callerAbilityRecord->GetSessionInfo(); - if (callerSessionInfo != nullptr) { - if (callerAbilityRecord->GetAbilityInfo().type == AbilityType::PAGE) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "UIAbility Caller"); + if (callerAbilityRecord->GetAbilityInfo().type == AbilityType::PAGE) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "UIAbility Caller"); + sptr callerSessionInfo = callerAbilityRecord->GetSessionInfo(); + if (callerSessionInfo != nullptr) { abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, callerSessionInfo->persistentId); - } else { - abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, 0); + } + } else if (callerAbilityRecord->GetAbilityInfo().type == AppExecFwk::AbilityType::EXTENSION && + AAFwk::UIExtensionUtils::IsUIExtension(callerAbilityRecord->GetAbilityInfo().extensionAbilityType)) { + CHECK_POINTER(abilityRequest.callerToken); + auto abilityRecord = Token::GetAbilityRecordByToken(abilityRequest.callerToken); + CHECK_POINTER(abilityRecord); + auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE; + auto connectManager = GetConnectManagerByUserId(userId); + if (connectManager == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo manager null, userId:%{public}d", userId); + return; } - } + UIExtensionSessionInfo uiExtensionSessionInfo; + auto ret = connectManager->GetUIExtensionSessionInfo(abilityRequest.callerToken, uiExtensionSessionInfo); + if (ret != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo get ui extension session info failed"); + return; + } + int32_t mainWindowId = 0; + auto sceneSessionManager = Rosen::SessionManagerLite::GetInstance(). + GetSceneSessionManagerLiteProxy(); + CHECK_POINTER(sceneSessionManager); + auto err = sceneSessionManager->GetRootMainWindowId(static_cast(uiExtensionSessionInfo.hostWindowId),mainWindowId); + TAG_LOGI(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo uiExtensionSessionInfo.hostWindowId = %{public}d", + uiExtensionSessionInfo.hostWindowId); + TAG_LOGI(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo mainWindowId = %{public}d, err = %{public}d", mainWindowId, err); + abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, mainWindowId); + } else { + abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, 0); + } } else { - TAG_LOGE(AAFwkTag::ABILITYMGR, "callerAbilityRecord null"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "callerAbilityRecord is nullptr"); } + TAG_LOGI(AAFwkTag::ABILITYMGR, "complete"); } int32_t AbilityManagerService::TerminateMission(int32_t missionId) From 1f8eac965a53ec7384e1566fd33204f02fc3b293 Mon Sep 17 00:00:00 2001 From: chenxinzhan Date: Fri, 13 Sep 2024 15:15:54 +0800 Subject: [PATCH 03/26] cr_modify Signed-off-by: chenxinzhan Change-Id: I9b209c2fa218c4d5add14d48445124b8f8443c3c --- .../native/ability/native/ability_impl.cpp | 5 ----- .../ability/native/new_ability_impl.cpp | 20 ++--------------- frameworks/native/appkit/app/main_thread.cpp | 4 ++-- .../kits/native/ability/native/ability_impl.h | 13 ----------- .../native/ability/native/new_ability_impl.h | 4 ---- .../kits/native/appkit/app/main_thread.h | 2 +- .../include/ability_manager_service.h | 2 -- .../src/ability_manager_service.cpp | 22 ++++++++----------- services/appmgr/include/app_running_record.h | 1 - services/appmgr/src/app_mgr_service.cpp | 2 -- .../uripermmgr/include/upms_policy_info.h | 3 --- .../main_thread_test/main_thread_test.cpp | 4 ++-- 12 files changed, 16 insertions(+), 66 deletions(-) diff --git a/frameworks/native/ability/native/ability_impl.cpp b/frameworks/native/ability/native/ability_impl.cpp index b79850193b..c0dd13ceb5 100644 --- a/frameworks/native/ability/native/ability_impl.cpp +++ b/frameworks/native/ability/native/ability_impl.cpp @@ -31,11 +31,6 @@ namespace OHOS { using AbilityRuntime::FreezeUtil; namespace AppExecFwk { -namespace { -const std::string PERMISSION_KEY = "ohos.user.grant.permission"; -const std::string GRANTED_RESULT_KEY = "ohos.user.grant.permission.result"; -} - void AbilityImpl::Init(const std::shared_ptr &application, const std::shared_ptr &record, std::shared_ptr &ability, diff --git a/frameworks/native/ability/native/new_ability_impl.cpp b/frameworks/native/ability/native/new_ability_impl.cpp index 5168b72937..d20e051da3 100644 --- a/frameworks/native/ability/native/new_ability_impl.cpp +++ b/frameworks/native/ability/native/new_ability_impl.cpp @@ -25,13 +25,6 @@ namespace OHOS { using AbilityRuntime::FreezeUtil; namespace AppExecFwk { using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient; -/** - * @brief Handling the life cycle switching of NewAbility. - * - * @param want Indicates the structure containing information about the ability. - * @param targetState The life cycle state to switch to. - * - */ void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState, sptr sessionInfo) @@ -72,10 +65,10 @@ void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Lif void NewAbilityImpl::HandleShareData(const int32_t &uniqueId) { - TAG_LOGI(AAFwkTag::ABILITY, "begin sourceState:%{public}d", lifecycleState_); WantParams wantParam; int32_t resultCode = Share(wantParam); - TAG_LOGI(AAFwkTag::ABILITY, "wantParam size: %{public}d", wantParam.Size()); + TAG_LOGI(AAFwkTag::ABILITY, "begin sourceState:%{public}d, wantParam size:%{public}d", + lifecycleState_, wantParam.Size()); AbilityManagerClient::GetInstance()->ShareDataDone(token_, resultCode, uniqueId, wantParam); } @@ -89,15 +82,6 @@ void NewAbilityImpl::AbilityTransactionCallback(const AbilityLifeCycleState &sta } } -/** - * @brief Handling the life cycle switching of NewAbility in switch. - * - * @param want Indicates the structure containing information about the ability. - * @param targetState The life cycle state to switch to. - * - * @return return true if need notify ams, otherwise return false. - * - */ bool NewAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 667bef9885..5ebb8c5a00 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -1371,7 +1371,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con std::vector localPaths; ChangeToLocalPath(bundleName, appInfo.moduleSourceDirs, localPaths); LoadAbilityLibrary(localPaths); - LoadNativeLiabrary(bundleInfo, appInfo.nativeLibraryPath); + LoadNativeLibrary(bundleInfo, appInfo.nativeLibraryPath); #ifdef SUPPORT_SCREEN } else if (Ace::AceForwardCompatibility::PipelineChanged()) { std::vector localPaths; @@ -1816,7 +1816,7 @@ void MainThread::CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::st } } -void MainThread::LoadNativeLiabrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath) +void MainThread::LoadNativeLibrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath) { CalcNativeLiabraryEntries(bundleInfo, nativeLibraryPath); if (nativeFileEntries_.empty()) { diff --git a/interfaces/kits/native/ability/native/ability_impl.h b/interfaces/kits/native/ability/native/ability_impl.h index 77e3c07897..1a43b03b90 100644 --- a/interfaces/kits/native/ability/native/ability_impl.h +++ b/interfaces/kits/native/ability/native/ability_impl.h @@ -29,10 +29,6 @@ #endif namespace OHOS { namespace AppExecFwk { -class Ability; -class AbilityHandler; -class ApplicationImpl; -class AbilityLocalRecord; class AbilityLifecycleCallbacks; class OHOSApplication; class AbilityImpl : public std::enable_shared_from_this { @@ -491,15 +487,6 @@ protected: std::mutex notifyForegroundLock_; private: - typedef enum { - START, - INACTIVE, - ACTIVE, - BACKGROUND, - FOREGROUND, - STOP, - } Action; - std::shared_ptr applicationImpl_; std::shared_ptr contextDeal_; bool hasSaveData_ = false; diff --git a/interfaces/kits/native/ability/native/new_ability_impl.h b/interfaces/kits/native/ability/native/new_ability_impl.h index d445102f2a..50013b54dc 100644 --- a/interfaces/kits/native/ability/native/new_ability_impl.h +++ b/interfaces/kits/native/ability/native/new_ability_impl.h @@ -20,10 +20,6 @@ namespace OHOS { namespace AppExecFwk { -class Ability; -class AbilityHandler; -class AbilityLocalRecord; -class AbilityImpl; class NewAbilityImpl final : public AbilityImpl { public: /** diff --git a/interfaces/kits/native/appkit/app/main_thread.h b/interfaces/kits/native/appkit/app/main_thread.h index 996bc9af75..501ab3925d 100644 --- a/interfaces/kits/native/appkit/app/main_thread.h +++ b/interfaces/kits/native/appkit/app/main_thread.h @@ -675,7 +675,7 @@ private: void LoadAceAbilityLibrary(); void CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::string &nativeLibraryPath); - void LoadNativeLiabrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath); + void LoadNativeLibrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath); void LoadAppDetailAbilityLibrary(std::string &nativeLibraryPath); diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index e3c5bbad75..30498f3dc6 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -85,7 +85,6 @@ constexpr int32_t U0_USER_ID = 0; constexpr int32_t INVALID_USER_ID = -1; constexpr const char* KEY_SESSION_ID = "com.ohos.param.sessionId"; using OHOS::AppExecFwk::IAbilityController; -class PendingWantManager; struct StartAbilityInfo; class WindowFocusChangedListener; @@ -2287,7 +2286,6 @@ private: const Want& want, uint32_t specifyTokenId); constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000; - constexpr static int WAITING_BOOT_ANIMATION_TIMER = 5; std::shared_ptr taskHandler_; std::shared_ptr eventHandler_; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index c526c62c43..3901a5ecc5 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -125,12 +125,9 @@ constexpr const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_ // UIExtension type constexpr const char* UIEXTENSION_TYPE_KEY = "ability.want.params.uiExtensionType"; constexpr const char* UIEXTENSION_TARGET_TYPE_KEY = "ability.want.params.uiExtensionTargetType"; -constexpr const char* SYSTEM_SHARE = "share"; -constexpr const char* SYSTEM_SHARE_TYPE = "sysPicker/share"; // Share picker params constexpr char SHARE_PICKER_DIALOG_BUNDLE_NAME_KEY[] = "const.system.sharePicker.bundleName"; constexpr char SHARE_PICKER_DIALOG_ABILITY_NAME_KEY[] = "const.system.sharePicker.abilityName"; -constexpr char SHARE_PICKER_UIEXTENSION_NAME_KEY[] = "const.system.sharePicker.UIExtensionAbilityName"; constexpr char SHARE_PICKER_DIALOG_DEFAULY_BUNDLE_NAME[] = "com.ohos.sharepickerdialog"; constexpr char SHARE_PICKER_DIALOG_DEFAULY_ABILITY_NAME[] = "PickerDialog"; constexpr char TOKEN_KEY[] = "ohos.ability.params.token"; @@ -150,8 +147,8 @@ constexpr const char* DMS_PERSISTENT_ID = "ohos.dms.persistentId"; constexpr const char* DEBUG_APP = "debugApp"; constexpr const char* NATIVE_DEBUG = "nativeDebug"; -constexpr const char* AUTO_FILL_PASSWORD_TPYE = "autoFill/password"; -constexpr const char* AUTO_FILL_SMART_TPYE = "autoFill/smart"; +constexpr const char* AUTO_FILL_PASSWORD_TYPE = "autoFill/password"; +constexpr const char* AUTO_FILL_SMART_TYPE = "autoFill/smart"; constexpr size_t INDEX_ZERO = 0; constexpr size_t INDEX_ONE = 1; constexpr size_t INDEX_TWO = 2; @@ -2911,9 +2908,9 @@ void AbilityManagerService::SetAutoFillElementName(const sptr &exte TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); CHECK_POINTER_IS_NULLPTR(extensionSessionInfo); std::vector argList; - if (extensionSessionInfo->want.GetStringParam(UIEXTENSION_TYPE_KEY) == AUTO_FILL_PASSWORD_TPYE) { + if (extensionSessionInfo->want.GetStringParam(UIEXTENSION_TYPE_KEY) == AUTO_FILL_PASSWORD_TYPE) { SplitStr(KEY_AUTO_FILL_ABILITY, "/", argList); - } else if (extensionSessionInfo->want.GetStringParam(UIEXTENSION_TYPE_KEY) == AUTO_FILL_SMART_TPYE) { + } else if (extensionSessionInfo->want.GetStringParam(UIEXTENSION_TYPE_KEY) == AUTO_FILL_SMART_TYPE) { SplitStr(KEY_SMART_AUTO_FILL_ABILITY, "/", argList); } else { TAG_LOGW(AAFwkTag::ABILITYMGR, "not autofill"); @@ -2999,6 +2996,8 @@ int AbilityManagerService::StartUIExtensionAbility(const sptr &exte int32_t result = DelayedSingleton::GetInstance()->CheckAndUpdateWant( extensionSessionInfo->want, AppExecFwk::ExecuteMode::UI_EXTENSION_ABILITY); if (result != ERR_OK) { + eventInfo.errCode = ERR_INVALID_VALUE; + EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return result; } } @@ -6172,11 +6171,9 @@ int32_t AbilityManagerService::InitialAbilityRequest(AbilityRequest &request, request.appInfo = request.abilityInfo.applicationInfo; request.uid = request.appInfo.uid; TAG_LOGD(AAFwkTag::ABILITYMGR, - "GenerateExtensionAbilityRequest end, app name: %{public}s, bundle name: %{public}s, uid: %{public}d.", - request.appInfo.name.c_str(), request.appInfo.bundleName.c_str(), request.uid); + "GenerateExtensionAbilityRequest end, app name:%{public}s, bundle name:%{public}s, uid:%{public}d, moduleName:%{public}s", + request.appInfo.name.c_str(), request.appInfo.bundleName.c_str(), request.uid, request.abilityInfo.moduleName.c_str()); - TAG_LOGD(AAFwkTag::ABILITYMGR, - "GenerateExtensionAbilityRequest, moduleName: %{public}s.", request.abilityInfo.moduleName.c_str()); request.want.SetModuleName(request.abilityInfo.moduleName); return ERR_OK; @@ -9416,9 +9413,8 @@ int AbilityManagerService::CheckCallOtherExtensionPermission(const AbilityReques return ERR_OK; } - const std::string fileAccessPermission = "ohos.permission.FILE_ACCESS_MANAGER"; if (extensionType == AppExecFwk::ExtensionAbilityType::FILEACCESS_EXTENSION && - AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission(fileAccessPermission)) { + AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission(PermissionConstants::PERMISSION_FILE_ACCESS_MANAGER)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Temporary, FILEACCESS_EXTENSION use serviceExtension start-up rule."); return CheckCallServiceExtensionPermission(abilityRequest); } diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index b40fd095bd..08cfc078b8 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -928,7 +928,6 @@ private: std::shared_ptr appInfo_ = nullptr; // the application's info of this process int32_t appRecordId_ = 0; - std::string appName_; std::string processName_; // the name of this process std::string specifiedProcessFlag_; // the flag of specified Process int64_t eventId_ = 0; diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 400305fb0c..2210567d81 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -60,8 +60,6 @@ constexpr const char* TASK_APPLICATION_FOREGROUNDED = "ApplicationForegroundedTa constexpr const char* TASK_APPLICATION_BACKGROUNDED = "ApplicationBackgroundedTask"; constexpr const char* TASK_APPLICATION_TERMINATED = "ApplicationTerminatedTask"; constexpr const char* TASK_ABILITY_CLEANED = "AbilityCleanedTask"; -constexpr const char* TASK_ADD_APP_DEATH_RECIPIENT = "AddAppRecipientTask"; -constexpr const char* TASK_CLEAR_UP_APPLICATION_DATA = "ClearUpApplicationDataTask"; constexpr const char* TASK_STARTUP_RESIDENT_PROCESS = "StartupResidentProcess"; constexpr const char* TASK_ADD_ABILITY_STAGE_DONE = "AddAbilityStageDone"; constexpr const char* TASK_START_USER_TEST_PROCESS = "StartUserTestProcess"; diff --git a/services/uripermmgr/include/upms_policy_info.h b/services/uripermmgr/include/upms_policy_info.h index c5162682aa..ea4ae23e5e 100644 --- a/services/uripermmgr/include/upms_policy_info.h +++ b/services/uripermmgr/include/upms_policy_info.h @@ -16,9 +16,6 @@ #ifndef ABILITY_ABILITY_RUNTIME_UPMS_POLICY_INFO_H #define ABILITY_ABILITY_RUNTIME_UPMS_POLICY_INFO_H -#include -#include - namespace OHOS { namespace AAFwk { struct PolicyInfo final { diff --git a/test/unittest/appkit/main_thread_test/main_thread_test.cpp b/test/unittest/appkit/main_thread_test/main_thread_test.cpp index 0fe86c7ca0..95ff2e2d9f 100644 --- a/test/unittest/appkit/main_thread_test/main_thread_test.cpp +++ b/test/unittest/appkit/main_thread_test/main_thread_test.cpp @@ -1532,10 +1532,10 @@ HWTEST_F(MainThreadTest, LoadNativeLiabrary_0100, TestSize.Level1) std::string nativeLibraryPath = ""; ASSERT_NE(mainThread_, nullptr); BundleInfo bundleInfo; - mainThread_->LoadNativeLiabrary(bundleInfo, nativeLibraryPath); + mainThread_->LoadNativeLibrary(bundleInfo, nativeLibraryPath); nativeLibraryPath = "test/"; - mainThread_->LoadNativeLiabrary(bundleInfo, nativeLibraryPath); + mainThread_->LoadNativeLibrary(bundleInfo, nativeLibraryPath); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } #endif From ab0d97369e230253a5ae245f2d42e9aafc204763 Mon Sep 17 00:00:00 2001 From: zhang_hao_zheng Date: Thu, 19 Sep 2024 19:32:10 +0800 Subject: [PATCH 04/26] =?UTF-8?q?=E4=BC=98=E5=8C=96extension=20ams?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhang_hao_zheng Change-Id: I95bcd8ffa9c98286c88232361269759d2222c5f9 --- .../ability_runtime/ability_context_impl.cpp | 4 ++-- .../native/extension_ability_thread.cpp | 4 ++-- .../include/ability_manager_interface.h | 6 ++--- .../include/ability_connect_manager.h | 6 ++--- .../include/ability_manager_proxy.h | 2 +- .../include/ability_manager_service.h | 10 ++++---- .../src/ability_connect_manager.cpp | 1 + .../abilitymgr/src/ability_manager_proxy.cpp | 2 +- .../src/ability_manager_service.cpp | 24 +++++++++++-------- .../appmgr/include/app_mgr_service_inner.h | 2 +- services/appmgr/src/ams_mgr_scheduler.cpp | 2 +- services/appmgr/src/app_mgr_service_inner.cpp | 4 ++-- 12 files changed, 36 insertions(+), 31 deletions(-) diff --git a/frameworks/native/ability/ability_runtime/ability_context_impl.cpp b/frameworks/native/ability/ability_runtime/ability_context_impl.cpp index 4d01338113..8ecd2fa4a5 100644 --- a/frameworks/native/ability/ability_runtime/ability_context_impl.cpp +++ b/frameworks/native/ability/ability_runtime/ability_context_impl.cpp @@ -402,7 +402,7 @@ ErrCode AbilityContextImpl::ConnectAbility(const AAFwk::Want& want, const sptrname.c_str(), want.GetElement().GetAbilityName().c_str()); ErrCode ret = ConnectionManager::GetInstance().ConnectAbility(token_, want, connectCallback); if (ret != ERR_OK) { @@ -440,7 +440,7 @@ void AbilityContextImpl::DisconnectAbility(const AAFwk::Want& want, const sptr& connectCallback, int32_t accountId) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::CONTEXT, "DisconnectAbility called, caller:%{public}s, target:%{public}s", + TAG_LOGI(AAFwkTag::CONTEXT, "DisconnectAbility, caller:%{public}s, target:%{public}s", abilityInfo_ == nullptr ? "" : abilityInfo_->name.c_str(), want.GetElement().GetAbilityName().c_str()); ErrCode ret = ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback, accountId); diff --git a/frameworks/native/ability/native/extension_ability_thread.cpp b/frameworks/native/ability/native/extension_ability_thread.cpp index 9c39ae4a7b..7ee22ed128 100644 --- a/frameworks/native/ability/native/extension_ability_thread.cpp +++ b/frameworks/native/ability/native/extension_ability_thread.cpp @@ -211,7 +211,7 @@ void ExtensionAbilityThread::HandleAttach(const std::shared_ptr sessionInfo) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::EXT, "%{public}s Begin", __func__); + TAG_LOGD(AAFwkTag::EXT, "%{public}s", __func__); if (extensionImpl_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "null extensionImpl_"); return; diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 4bfe056497..d0f565df26 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -336,7 +336,7 @@ public: * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started. * @return Returns ERR_OK on success, others on failure. */ - virtual int StartExtensionAbility( + virtual int32_t StartExtensionAbility( const Want &want, const sptr &callerToken, int32_t userId = DEFAULT_INVAL_VALUE, @@ -597,7 +597,7 @@ public: * @param userId, Designation User ID. * @return Returns ERR_OK on success, others on failure. */ - virtual int ConnectAbility( + virtual int32_t ConnectAbility( const Want &want, const sptr &connect, const sptr &callerToken, @@ -613,7 +613,7 @@ public: * @param userId, the service user ID. * @return Returns ERR_OK on success, others on failure. */ - virtual int ConnectAbilityCommon( + virtual int32_t ConnectAbilityCommon( const Want &want, const sptr &connect, const sptr &callerToken, diff --git a/services/abilitymgr/include/ability_connect_manager.h b/services/abilitymgr/include/ability_connect_manager.h index d707b6ccfc..c20d542478 100644 --- a/services/abilitymgr/include/ability_connect_manager.h +++ b/services/abilitymgr/include/ability_connect_manager.h @@ -69,7 +69,7 @@ public: * @param abilityRequest, the request of the service ability to start. * @return Returns ERR_OK on success, others on failure. */ - int StartAbility(const AbilityRequest &abilityRequest); + int32_t StartAbility(const AbilityRequest &abilityRequest); /** * TerminateAbility with token and result want. @@ -97,7 +97,7 @@ public: * @param connectInfo the connect info. * @return Returns ERR_OK on success, others on failure. */ - int ConnectAbilityLocked(const AbilityRequest &abilityRequest, const sptr &connect, + int32_t ConnectAbilityLocked(const AbilityRequest &abilityRequest, const sptr &connect, const sptr &callerToken, sptr sessionInfo = nullptr, sptr connectInfo = nullptr); @@ -340,7 +340,7 @@ private: * @param abilityRequest, the request of the service ability to start. * @return Returns ERR_OK on success, others on failure. */ - int StartAbilityLocked(const AbilityRequest &abilityRequest); + int32_t StartAbilityLocked(const AbilityRequest &abilityRequest); /** * TerminateAbilityLocked with token and result want. diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index a94de0a1e6..9958c91fdc 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -255,7 +255,7 @@ public: * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started. * @return Returns ERR_OK on success, others on failure. */ - virtual int StartExtensionAbility( + virtual int32_t StartExtensionAbility( const Want &want, const sptr &callerToken, int32_t userId = DEFAULT_INVAL_VALUE, diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index d501d4878f..d322a15d8b 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -400,7 +400,7 @@ public: * @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started. * @return Returns ERR_OK on success, others on failure. */ - virtual int StartExtensionAbility( + virtual int32_t StartExtensionAbility( const Want &want, const sptr &callerToken, int32_t userId = DEFAULT_INVAL_VALUE, @@ -583,13 +583,13 @@ public: * @param userId, Designation User ID. * @return Returns ERR_OK on success, others on failure. */ - virtual int ConnectAbility( + virtual int32_t ConnectAbility( const Want &want, const sptr &connect, const sptr &callerToken, int32_t userId = DEFAULT_INVAL_VALUE) override; - virtual int ConnectAbilityCommon( + virtual int32_t ConnectAbilityCommon( const Want &want, const sptr &connect, const sptr &callerToken, @@ -1032,7 +1032,7 @@ public: bool isImplicit = false, bool isUIAbilityOnly = false); - int StartExtensionAbilityInner( + int32_t StartExtensionAbilityInner( const Want &want, const sptr &callerToken, int32_t userId, @@ -1884,7 +1884,7 @@ private: int32_t PreStartInner(const FreeInstallInfo& taskInfo); void RemovePreStartSession(const std::string& sessionId); - int ConnectLocalAbility( + int32_t ConnectLocalAbility( const Want &want, const int32_t userId, const sptr &connect, diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 99c29dac18..ab066b9b32 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -1191,6 +1191,7 @@ void AbilityConnectManager::CompleteCommandAbility(std::shared_ptrGetURI()); if (abilityRecord->NeedConnectAfterCommand()) { + abilityRecord->UpdateConnectWant(); ConnectAbility(abilityRecord); } } diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index e9b914480c..05a741861a 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -610,7 +610,7 @@ int AbilityManagerProxy::StartAbilityOnlyUIAbility(const Want &want, const sptr< return reply.ReadInt32(); } -int AbilityManagerProxy::StartExtensionAbility(const Want &want, const sptr &callerToken, +int32_t AbilityManagerProxy::StartExtensionAbility(const Want &want, const sptr &callerToken, int32_t userId, AppExecFwk::ExtensionAbilityType extensionType) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 511777c3ed..e1c1cbc99f 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -2575,7 +2575,7 @@ void AbilityManagerService::ReportEventToRSS(const AppExecFwk::AbilityInfo &abil }); } -int AbilityManagerService::StartExtensionAbility(const Want &want, const sptr &callerToken, +int32_t AbilityManagerService::StartExtensionAbility(const Want &want, const sptr &callerToken, int32_t userId, AppExecFwk::ExtensionAbilityType extensionType) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); @@ -2727,7 +2727,7 @@ int AbilityManagerService::ChangeUIAbilityVisibilityBySCB(sptr sess return uiAbilityManager->ChangeUIAbilityVisibilityBySCB(sessionInfo, isShow); } -int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sptr &callerToken, +int32_t AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sptr &callerToken, int32_t userId, AppExecFwk::ExtensionAbilityType extensionType, bool checkSystemCaller, bool isImplicit, bool isDlp, bool isStartAsCaller) { @@ -2746,6 +2746,8 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::START_EXTENSION_ERROR); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "CheckDlpForExtension error"); + eventInfo.errCode = result; + EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return result; } #endif // WITH_DLP @@ -2760,6 +2762,8 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp int32_t validUserId = GetValidUserId(userId); int32_t appIndex = 0; if (!StartAbilityUtils::GetAppIndex(want, callerToken, appIndex)) { + eventInfo.errCode = ERR_APP_CLONE_INDEX_INVALID; + EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return ERR_APP_CLONE_INDEX_INVALID; } StartAbilityInfoWrap threadLocalInfo(want, validUserId, appIndex, callerToken, true); @@ -2769,13 +2773,13 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "interceptorExecuter_ null or doProcess error"); eventInfo.errCode = result; - SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); + EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return result; } if (!JudgeMultiUserConcurrency(validUserId)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "multi-user non-concurrent unsatisfied"); - eventInfo.errCode = ERR_INVALID_VALUE; + eventInfo.errCode = ERR_CROSS_USER; EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return ERR_CROSS_USER; } @@ -2809,7 +2813,6 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp TAG_LOGD(AAFwkTag::ABILITYMGR, "userId is : %{public}d, singleton is : %{public}d", validUserId, static_cast(abilityInfo.applicationInfo.singleton)); -#ifdef WITH_DLP result = isDlp ? IN_PROCESS_CALL( CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, isImplicit, isStartAsCaller)) : CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, isImplicit, isStartAsCaller); @@ -2819,7 +2822,6 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return result; } -#endif // WITH_DLP AbilityInterceptorParam afterCheckParam = AbilityInterceptorParam(abilityRequest.want, 0, GetUserId(), false, callerToken, std::make_shared(abilityInfo), false, appIndex); @@ -2827,6 +2829,8 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp afterCheckExecuter_->DoProcess(afterCheckParam); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "afterCheckExecuter_ null or doProcess error"); + eventInfo.errCode = result; + EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return result; } @@ -3776,13 +3780,13 @@ int AbilityManagerService::MinimizeUIAbilityBySCB(const sptr &sessi return uiAbilityManager->MinimizeUIAbility(abilityRecord, fromUser, sceneFlag); } -int AbilityManagerService::ConnectAbility( +int32_t AbilityManagerService::ConnectAbility( const Want &want, const sptr &connect, const sptr &callerToken, int32_t userId) { return ConnectAbilityCommon(want, connect, callerToken, AppExecFwk::ExtensionAbilityType::SERVICE, userId); } -int AbilityManagerService::ConnectAbilityCommon( +int32_t AbilityManagerService::ConnectAbilityCommon( const Want &want, const sptr &connect, const sptr &callerToken, AppExecFwk::ExtensionAbilityType extensionType, int32_t userId, bool isQueryExtensionOnly) { @@ -4011,7 +4015,7 @@ int AbilityManagerService::DisconnectAbility(sptr connect) return err; } -int AbilityManagerService::ConnectLocalAbility(const Want &want, const int32_t userId, +int32_t AbilityManagerService::ConnectLocalAbility(const Want &want, const int32_t userId, const sptr &connect, const sptr &callerToken, AppExecFwk::ExtensionAbilityType extensionType, const sptr &sessionInfo, bool isQueryExtensionOnly, sptr connectInfo) @@ -8479,7 +8483,7 @@ int AbilityManagerService::CheckStaticCfgPermissionForAbility(const AppExecFwk:: return AppExecFwk::Constants::PERMISSION_GRANTED; } - for (auto permission : abilityInfo.permissions) { + for (const auto &permission : abilityInfo.permissions) { if (AccessTokenKit::VerifyAccessToken(tokenId, permission, false) != AppExecFwk::Constants::PERMISSION_GRANTED) { TAG_LOGE(AAFwkTag::ABILITYMGR, "verify access token fail, permission:%{public}s", diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index b3f455ea13..8eeb72f022 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1159,7 +1159,7 @@ public: void SetSceneBoardAttachFlag(bool flag); - void CacheLoadAbilityTask(const LoadAbilityTaskFunc& func); + void CacheLoadAbilityTask(const LoadAbilityTaskFunc&& func); void SubmitCacheLoadAbilityTask(); /** diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 46df12a8e9..327a8b52b7 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -90,7 +90,7 @@ void AmsMgrScheduler::LoadAbility(const std::shared_ptr &abilityInf // cache other application load ability task before scene board attach if (!amsMgrServiceInner_->GetSceneBoardAttachFlag() && abilityInfo->bundleName != SCENE_BOARD_BUNDLE_NAME) { - amsMgrServiceInner_->CacheLoadAbilityTask(loadAbilityFunc); + amsMgrServiceInner_->CacheLoadAbilityTask(std::move(loadAbilityFunc)); return; } if (abilityInfo->bundleName == SCENE_BOARD_BUNDLE_NAME && abilityInfo->name == SCENEBOARD_ABILITY_NAME) { diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index ac2e8e450e..cacb7adfcd 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -7619,10 +7619,10 @@ int32_t AppMgrServiceInner::StartNativeChildProcess(const pid_t hostPid, const s return StartChildProcessImpl(nativeChildRecord, appRecord, dummyChildPid, args, options); } -void AppMgrServiceInner::CacheLoadAbilityTask(const LoadAbilityTaskFunc& func) +void AppMgrServiceInner::CacheLoadAbilityTask(const LoadAbilityTaskFunc&& func) { std::lock_guard lock(loadTaskListMutex_); - loadAbilityTaskFuncList_.emplace_back(func); + loadAbilityTaskFuncList_.emplace_back(std::move(func)); } void AppMgrServiceInner::SubmitCacheLoadAbilityTask() From c14a6b6f67187b97eb1dc1367b207baa827e7088 Mon Sep 17 00:00:00 2001 From: Tintin9529 Date: Mon, 23 Sep 2024 09:54:45 +0800 Subject: [PATCH 05/26] delete temp file Signed-off-by: Tintin9529 --- .../native/appkit/app/application_cleaner.cpp | 13 ++++--------- .../kits/native/appkit/app/application_cleaner.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/frameworks/native/appkit/app/application_cleaner.cpp b/frameworks/native/appkit/app/application_cleaner.cpp index 503039b63d..231aa468bd 100644 --- a/frameworks/native/appkit/app/application_cleaner.cpp +++ b/frameworks/native/appkit/app/application_cleaner.cpp @@ -44,7 +44,7 @@ static const int RESULT_ERR = -1; static const char TASK_NAME[] = "ApplicationCleaner::ClearTempData"; static constexpr uint64_t DELAY = 5000000; //5s -constexpr int64_t ONEHUNDRED_MB = 50 * 1024; +constexpr int64_t MAX_FILE_SIZE = 50 * 1024; } // namespace void ApplicationCleaner::RenameTempData() { @@ -97,7 +97,7 @@ void ApplicationCleaner::ClearTempData() } }; - if (CheckFileSize(rootDir, ONEHUNDRED_MB)) { + if (CheckFileSize(rootDir)) { ffrt::submit(cleanTemp); } else { ffrt::task_attr attr; @@ -107,7 +107,7 @@ void ApplicationCleaner::ClearTempData() } } -bool ApplicationCleaner::CheckFileSize(const std::vector bundlePath, const int64_t maxFileSize) +bool ApplicationCleaner::CheckFileSize(const std::vector &bundlePath) { int64_t fileSize = 0; @@ -118,12 +118,7 @@ bool ApplicationCleaner::CheckFileSize(const std::vector bundlePath } fileSize += fileInfo.st_size; } - - if (fileSize > maxFileSize) { - return false; -} - - return true; + return (fileSize <= MAX_FILE_SIZE); } int ApplicationCleaner::GetRootPath(std::vector &rootPath) diff --git a/interfaces/kits/native/appkit/app/application_cleaner.h b/interfaces/kits/native/appkit/app/application_cleaner.h index 204db2febc..431e713d9a 100644 --- a/interfaces/kits/native/appkit/app/application_cleaner.h +++ b/interfaces/kits/native/appkit/app/application_cleaner.h @@ -42,7 +42,7 @@ private: int GetObsoleteBundleTempPath(const std::vector &rootPath, std::vector &tempPath); bool RemoveDir(const std::string &tempPath); void TraverseObsoleteTempDirectory(const std::string ¤tPath, std::vector &tempDirs); - bool CheckFileSize(const std::vector bundlePath, const int64_t maxFileSize); + bool CheckFileSize(const std::vector &bundlePath); private: std::shared_ptr context_ = nullptr; From b0f86565b8faa7bbc4e35c2cae2d0e52bac20ca8 Mon Sep 17 00:00:00 2001 From: ZhangYan Date: Mon, 23 Sep 2024 16:40:27 +0800 Subject: [PATCH 06/26] =?UTF-8?q?=E5=BC=82=E6=AD=A5=E9=80=9A=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ZhangYan --- .../app_manager/src/appmgr/app_state_callback_proxy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_proxy.cpp index b17e6c04ee..c6e700e920 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_state_callback_proxy.cpp @@ -88,7 +88,7 @@ void AppStateCallbackProxy::NotifyConfigurationChange(const AppExecFwk::Configur { MessageParcel data; MessageParcel reply; - MessageOption option; + MessageOption option(MessageOption::TF_ASYNC); if (!WriteInterfaceToken(data)) { TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); return; @@ -112,7 +112,7 @@ void AppStateCallbackProxy::NotifyStartResidentProcess(std::vector Date: Sun, 22 Sep 2024 09:10:00 +0800 Subject: [PATCH 07/26] 0924_10_fix Signed-off-by:Luobniz Signed-off-by: l30067926 Change-Id: I057ad6f05f398ce810582ab9bd69ae48bfda8362 --- interfaces/inner_api/ability_manager/BUILD.gn | 6 +++--- services/abilitymgr/BUILD.gn | 13 ++++++++----- services/abilitymgr/abilitymgr.gni | 4 ++-- .../abilitymgr/include/{ => mission}/mission.h | 0 .../include/{ => mission}/mission_data_storage.h | 0 .../include/{ => mission}/mission_info_mgr.h | 0 .../include/{ => mission}/mission_list.h | 0 .../include/{ => mission}/mission_list_manager.h | 0 .../mission_list_manager_interface.h | 0 .../{ => mission}/mission_listener_controller.h | 0 .../abilitymgr/src/ability_manager_service.cpp | 15 +++++++++++++++ services/abilitymgr/src/{ => mission}/mission.cpp | 0 .../src/{ => mission}/mission_data_storage.cpp | 0 .../abilitymgr/src/{ => mission}/mission_info.cpp | 0 .../src/{ => mission}/mission_info_mgr.cpp | 0 .../abilitymgr/src/{ => mission}/mission_list.cpp | 0 .../src/{ => mission}/mission_list_manager.cpp | 0 .../{ => mission}/mission_listener_controller.cpp | 0 .../src/{ => mission}/mission_listener_proxy.cpp | 0 .../src/{ => mission}/mission_listener_stub.cpp | 0 .../src/{ => mission}/mission_snapshot.cpp | 0 services/abilitymgr/src/uri_utils.cpp | 2 +- test/unittest/BUILD.gn | 4 ++-- 23 files changed, 31 insertions(+), 13 deletions(-) rename services/abilitymgr/include/{ => mission}/mission.h (100%) rename services/abilitymgr/include/{ => mission}/mission_data_storage.h (100%) rename services/abilitymgr/include/{ => mission}/mission_info_mgr.h (100%) rename services/abilitymgr/include/{ => mission}/mission_list.h (100%) rename services/abilitymgr/include/{ => mission}/mission_list_manager.h (100%) rename services/abilitymgr/include/{ => mission}/mission_list_manager_interface.h (100%) rename services/abilitymgr/include/{ => mission}/mission_listener_controller.h (100%) rename services/abilitymgr/src/{ => mission}/mission.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_data_storage.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_info.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_info_mgr.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_list.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_list_manager.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_listener_controller.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_listener_proxy.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_listener_stub.cpp (100%) rename services/abilitymgr/src/{ => mission}/mission_snapshot.cpp (100%) diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 07e519bdc5..4b1e2a6eb1 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -87,7 +87,7 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/insight_intent_execute_result.cpp", "${ability_runtime_services_path}/abilitymgr/src/launch_param.cpp", "${ability_runtime_services_path}/abilitymgr/src/lifecycle_state_info.cpp", - "${ability_runtime_services_path}/abilitymgr/src/mission_listener_stub.cpp", + "${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/open_link/open_link_options.cpp", "${ability_runtime_services_path}/abilitymgr/src/prepare_terminate_callback_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/prepare_terminate_callback_stub.cpp", @@ -229,8 +229,8 @@ ohos_shared_library("mission_info") { branch_protector_ret = "pac_ret" sources = [ - "${ability_runtime_services_path}/abilitymgr/src/mission_info.cpp", - "${ability_runtime_services_path}/abilitymgr/src/mission_snapshot.cpp", + "${ability_runtime_services_path}/abilitymgr/src/mission/mission_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/mission/mission_snapshot.cpp", ] public_configs = [ ":ability_manager_public_config" ] diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 08d9f4a0e4..ea6ae679d1 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -33,6 +33,7 @@ config("abilityms_config") { "include/", "include/data_ability", "include/dialog_session/", + "include/mission/", "include/rdb/", "include/screen_lock/", "${ability_runtime_innerkits_path}/ability_manager/include", @@ -110,6 +111,7 @@ ohos_shared_library("abilityms") { include_dirs = [ "${ability_runtime_services_path}/appdfr/include", "${ability_runtime_path}/interfaces/kits/native/ability/native/ui_service_extension_ability/connection", + "${ability_runtime_services_path}/abilitymgr/include/mission", ] deps = [ ":wantagent_manager", @@ -334,6 +336,7 @@ ohos_shared_library("mission_list") { "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", "${ability_runtime_services_path}/abilitymgr/data_ability/include", "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_services_path}/abilitymgr/include/mission", "${ability_runtime_services_path}/common/include", "${ability_runtime_services_path}/appdfr/include", "${ability_runtime_utils_path}/global/constant", @@ -359,11 +362,11 @@ ohos_shared_library("mission_list") { } sources = [ - "src/mission.cpp", - "src/mission_data_storage.cpp", - "src/mission_info_mgr.cpp", - "src/mission_list.cpp", - "src/mission_list_manager.cpp", + "src/mission/mission.cpp", + "src/mission/mission_data_storage.cpp", + "src/mission/mission_info_mgr.cpp", + "src/mission/mission_list.cpp", + "src/mission/mission_list_manager.cpp", "src/task_data_persistence_mgr.cpp", ] diff --git a/services/abilitymgr/abilitymgr.gni b/services/abilitymgr/abilitymgr.gni index 9d99636dad..2e180485b7 100644 --- a/services/abilitymgr/abilitymgr.gni +++ b/services/abilitymgr/abilitymgr.gni @@ -83,8 +83,8 @@ abilityms_files = [ "src/call_container.cpp", "src/call_record.cpp", "src/inner_mission_info.cpp", - "src/mission_listener_controller.cpp", - "src/mission_listener_proxy.cpp", + "src/mission/mission_listener_controller.cpp", + "src/mission/mission_listener_proxy.cpp", "src/rdb/ability_resident_process_rdb.cpp", "src/rdb/parser_util.cpp", "src/rdb/rdb_data_manager.cpp", diff --git a/services/abilitymgr/include/mission.h b/services/abilitymgr/include/mission/mission.h similarity index 100% rename from services/abilitymgr/include/mission.h rename to services/abilitymgr/include/mission/mission.h diff --git a/services/abilitymgr/include/mission_data_storage.h b/services/abilitymgr/include/mission/mission_data_storage.h similarity index 100% rename from services/abilitymgr/include/mission_data_storage.h rename to services/abilitymgr/include/mission/mission_data_storage.h diff --git a/services/abilitymgr/include/mission_info_mgr.h b/services/abilitymgr/include/mission/mission_info_mgr.h similarity index 100% rename from services/abilitymgr/include/mission_info_mgr.h rename to services/abilitymgr/include/mission/mission_info_mgr.h diff --git a/services/abilitymgr/include/mission_list.h b/services/abilitymgr/include/mission/mission_list.h similarity index 100% rename from services/abilitymgr/include/mission_list.h rename to services/abilitymgr/include/mission/mission_list.h diff --git a/services/abilitymgr/include/mission_list_manager.h b/services/abilitymgr/include/mission/mission_list_manager.h similarity index 100% rename from services/abilitymgr/include/mission_list_manager.h rename to services/abilitymgr/include/mission/mission_list_manager.h diff --git a/services/abilitymgr/include/mission_list_manager_interface.h b/services/abilitymgr/include/mission/mission_list_manager_interface.h similarity index 100% rename from services/abilitymgr/include/mission_list_manager_interface.h rename to services/abilitymgr/include/mission/mission_list_manager_interface.h diff --git a/services/abilitymgr/include/mission_listener_controller.h b/services/abilitymgr/include/mission/mission_listener_controller.h similarity index 100% rename from services/abilitymgr/include/mission_listener_controller.h rename to services/abilitymgr/include/mission/mission_listener_controller.h diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 511777c3ed..87ae63b9cb 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -1101,6 +1101,9 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr 0 && callerToken != nullptr) { // for sa specify tokenId and caller token UpdateCallerInfoFromToken(abilityRequest.want, callerToken); @@ -1723,6 +1726,9 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); return result; } + if (!UriUtils::GetInstance().CheckNonImplicitShareFileUri(abilityRequest)) { + return ERR_SHARE_FILE_URI_NON_IMPLICITLY; + } if (!isStartAsCaller) { TAG_LOGD(AAFwkTag::ABILITYMGR, "do not start as caller, UpdateCallerInfo"); @@ -3071,6 +3077,9 @@ int AbilityManagerService::StartUIExtensionAbility(const sptr &exte EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return result; } + if (!UriUtils::GetInstance().CheckNonImplicitShareFileUri(abilityRequest)) { + return ERR_SHARE_FILE_URI_NON_IMPLICITLY; + } abilityRequest.extensionType = abilityRequest.abilityInfo.extensionAbilityType; auto abilityInfo = abilityRequest.abilityInfo; @@ -4043,6 +4052,9 @@ int AbilityManagerService::ConnectLocalAbility(const Want &want, const int32_t u TAG_LOGE(AAFwkTag::ABILITYMGR, "generate request error"); return result; } + if (!UriUtils::GetInstance().CheckNonImplicitShareFileUri(abilityRequest)) { + return ERR_SHARE_FILE_URI_NON_IMPLICITLY; + } result = CheckPermissionForUIService(extensionType, want, abilityRequest); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "checkPermissionForUIService failed"); @@ -11849,6 +11861,9 @@ int AbilityManagerService::StartUIAbilityByPreInstallInner(sptr ses TAG_LOGE(AAFwkTag::ABILITYMGR, "Generate ability request local error"); return result; } + if (!UriUtils::GetInstance().CheckNonImplicitShareFileUri(abilityRequest)) { + return ERR_SHARE_FILE_URI_NON_IMPLICITLY; + } if (specifyTokenId > 0 && callerToken != nullptr) { // for sa specify tokenId and caller token UpdateCallerInfoFromToken(abilityRequest.want, callerToken); diff --git a/services/abilitymgr/src/mission.cpp b/services/abilitymgr/src/mission/mission.cpp similarity index 100% rename from services/abilitymgr/src/mission.cpp rename to services/abilitymgr/src/mission/mission.cpp diff --git a/services/abilitymgr/src/mission_data_storage.cpp b/services/abilitymgr/src/mission/mission_data_storage.cpp similarity index 100% rename from services/abilitymgr/src/mission_data_storage.cpp rename to services/abilitymgr/src/mission/mission_data_storage.cpp diff --git a/services/abilitymgr/src/mission_info.cpp b/services/abilitymgr/src/mission/mission_info.cpp similarity index 100% rename from services/abilitymgr/src/mission_info.cpp rename to services/abilitymgr/src/mission/mission_info.cpp diff --git a/services/abilitymgr/src/mission_info_mgr.cpp b/services/abilitymgr/src/mission/mission_info_mgr.cpp similarity index 100% rename from services/abilitymgr/src/mission_info_mgr.cpp rename to services/abilitymgr/src/mission/mission_info_mgr.cpp diff --git a/services/abilitymgr/src/mission_list.cpp b/services/abilitymgr/src/mission/mission_list.cpp similarity index 100% rename from services/abilitymgr/src/mission_list.cpp rename to services/abilitymgr/src/mission/mission_list.cpp diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission/mission_list_manager.cpp similarity index 100% rename from services/abilitymgr/src/mission_list_manager.cpp rename to services/abilitymgr/src/mission/mission_list_manager.cpp diff --git a/services/abilitymgr/src/mission_listener_controller.cpp b/services/abilitymgr/src/mission/mission_listener_controller.cpp similarity index 100% rename from services/abilitymgr/src/mission_listener_controller.cpp rename to services/abilitymgr/src/mission/mission_listener_controller.cpp diff --git a/services/abilitymgr/src/mission_listener_proxy.cpp b/services/abilitymgr/src/mission/mission_listener_proxy.cpp similarity index 100% rename from services/abilitymgr/src/mission_listener_proxy.cpp rename to services/abilitymgr/src/mission/mission_listener_proxy.cpp diff --git a/services/abilitymgr/src/mission_listener_stub.cpp b/services/abilitymgr/src/mission/mission_listener_stub.cpp similarity index 100% rename from services/abilitymgr/src/mission_listener_stub.cpp rename to services/abilitymgr/src/mission/mission_listener_stub.cpp diff --git a/services/abilitymgr/src/mission_snapshot.cpp b/services/abilitymgr/src/mission/mission_snapshot.cpp similarity index 100% rename from services/abilitymgr/src/mission_snapshot.cpp rename to services/abilitymgr/src/mission/mission_snapshot.cpp diff --git a/services/abilitymgr/src/uri_utils.cpp b/services/abilitymgr/src/uri_utils.cpp index 2eb32fc138..a096008836 100644 --- a/services/abilitymgr/src/uri_utils.cpp +++ b/services/abilitymgr/src/uri_utils.cpp @@ -115,7 +115,7 @@ bool UriUtils::CheckNonImplicitShareFileUri(const AbilityRequest &abilityRequest if (abilityRequest.appInfo.apiTargetVersion % API_VERSION_MOD <= API12) { return true; } - if (abilityRequest.want.GetElement().GetAbilityName().empty()) { + if (abilityRequest.want.GetElement().GetBundleName().empty()) { return true; } bool isFileUri = !abilityRequest.want.GetUriString().empty() && abilityRequest.want.GetUri().GetScheme() == "file"; diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 1fa6a5d570..3b5a1fb544 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -282,8 +282,8 @@ ohos_source_set("abilityms_test_source") { "${ability_runtime_services_path}/abilitymgr/src/mission/mission_info_mgr.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_list.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_list_manager.cpp", - "${ability_runtime_services_path}/abilitymgr/src/mission_listener_controller.cpp", - "${ability_runtime_services_path}/abilitymgr/src/mission_listener_proxy.cpp", + "${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_controller.cpp", + "${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/mission/mission_snapshot.cpp", "${ability_runtime_services_path}/abilitymgr/src/remote_mission_listener_proxy.cpp", From 55e977056bc63737ab844172a21cbf5ffcd04b6a Mon Sep 17 00:00:00 2001 From: hanchenZz Date: Thu, 19 Sep 2024 16:40:22 +0800 Subject: [PATCH 08/26] =?UTF-8?q?=E8=A1=A5=E5=85=85appspawn=20tdd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanchenZz --- .../app_spawn_client_test.cpp | 878 +++++++++++++++++- 1 file changed, 877 insertions(+), 1 deletion(-) diff --git a/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp b/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp index 7ef501f016..7ffd2c76ae 100644 --- a/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp +++ b/test/unittest/app_spawn_client_test/app_spawn_client_test.cpp @@ -14,7 +14,7 @@ */ #include - +#include "hilog_tag_wrapper.h" #define private public #include "app_spawn_client.h" #undef private @@ -70,5 +70,881 @@ HWTEST_F(AppSpawnClientTest, PreStartNWebSpawnProcessImpl_002, TestSize.Level0) int ret = asc->PreStartNWebSpawnProcess(); EXPECT_EQ(ret, ERR_OK); } + +/** + * @tc.name: AppSpawnClient_001 + * @tc.desc: new AppSpawnClient object + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, AppSpawnClient_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_001 start"); + const char* serviceName = "appspawn"; + auto asc = std::make_shared(serviceName); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_001 end"); +} + +/** + * @tc.name: AppSpawnClient_002 + * @tc.desc: new AppSpawnClient object + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, AppSpawnClient_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_002 start"); + const char* serviceName = "cjappspawn"; + auto asc = std::make_shared(serviceName); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_002 end"); +} + +/** + * @tc.name: AppSpawnClient_003 + * @tc.desc: new AppSpawnClient object + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, AppSpawnClient_003, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_003 start"); + const char* serviceName = "nwebRestart"; + auto asc = std::make_shared(serviceName); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_003 end"); +} + +/** + * @tc.name: AppSpawnClient_004 + * @tc.desc: new AppSpawnClient object + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, AppSpawnClient_004, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_004 start"); + const char* serviceName = "nativespawn"; + auto asc = std::make_shared(serviceName); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_004 end"); +} + +/** + * @tc.name: AppSpawnClient_005 + * @tc.desc: new AppSpawnClient object + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, AppSpawnClient_005, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_005 start"); + const char* serviceName = "nwebspawn"; + auto asc = std::make_shared(serviceName); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AppSpawnClient_005 end"); +} + +/** + * @tc.name: OpenConnection_001 + * @tc.desc: appspawn OpenConnection + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, OpenConnection_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 start"); + auto asc = std::make_shared(true); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 end"); +} + +/** + * @tc.name: OpenConnection_002 + * @tc.desc: appspawn OpenConnection + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, OpenConnection_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 start"); + auto asc = std::make_shared(false); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 end"); +} + +/** + * @tc.name: CloseConnection_001 + * @tc.desc: appspawn CloseConnection + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, CloseConnection_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 start"); + auto asc = std::make_shared(true); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 end"); +} + +/** + * @tc.name: CloseConnection_002 + * @tc.desc: appspawn CloseConnection + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, CloseConnection_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 start"); + auto asc = std::make_shared(false); + auto ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "OpenConnection_001 end"); +} + +/** + * @tc.name: SetDacInfo_001 + * @tc.desc: appspawn SetDacInfo + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetDacInfo_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetDacInfo_001 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetDacInfo(startMsg, reqHandle); + EXPECT_EQ(ret, ERR_OK); + + TAG_LOGI(AAFwkTag::TEST, "SetDacInfo_001 end"); +} + +/** + * @tc.name: SetMountPermission_001 + * @tc.desc: appspawn SetMountPermission + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetMountPermission_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetMountPermission_001 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetMountPermission(startMsg, reqHandle); + EXPECT_NE(ret, ERR_OK); + + TAG_LOGI(AAFwkTag::TEST, "SetMountPermission_001 end"); +} + +/** + * @tc.name: SetStartFlags_001 + * @tc.desc: appspawn SetStartFlags + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetStartFlags_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetStartFlags_001 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetStartFlags(startMsg, reqHandle); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "SetStartFlags_001 end"); +} + + +/** + * @tc.name: AppspawnSetExtMsgMore_001 + * @tc.desc: appspawn AppspawnSetExtMsgMore + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, AppspawnSetExtMsgMore_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AppspawnSetExtMsgMore_001 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->AppspawnSetExtMsgMore(startMsg, reqHandle); + EXPECT_EQ(ret, ERR_OK); + + TAG_LOGI(AAFwkTag::TEST, "AppspawnSetExtMsgMore_001 end"); +} + + +/** + * @tc.name: AppspawnCreateDefaultMsg_001 + * @tc.desc: appspawn AppspawnCreateDefaultMsg + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, AppspawnCreateDefaultMsg_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AppspawnCreateDefaultMsg_001 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string apl("test_apl"); + startMsg.apl = apl; + std::string ownerId("test_owner_id"); + startMsg.ownerId = ownerId; + std::string bundleName("test_bundle_name"); + startMsg.bundleName = bundleName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->AppspawnCreateDefaultMsg(startMsg, reqHandle); + EXPECT_NE(ret, ERR_OK); + + TAG_LOGI(AAFwkTag::TEST, "AppspawnCreateDefaultMsg_001 end"); +} + + +/** + * @tc.name: VerifyMsg_001 + * @tc.desc: appspawn VerifyMsg + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, VerifyMsg_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_001 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + bool result = false; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + + result = asc->VerifyMsg(startMsg); + EXPECT_EQ(result, true); + + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_001 end"); +} + +/** + * @tc.name: VerifyMsg_002 + * @tc.desc: appspawn VerifyMsg + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, VerifyMsg_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_002 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = -1; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + bool result = false; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + + result = asc->VerifyMsg(startMsg); + EXPECT_EQ(result, false); + + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_002 end"); +} + +/** + * @tc.name: VerifyMsg_003 + * @tc.desc: appspawn VerifyMsg + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, VerifyMsg_003, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_003 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = -1; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + bool result = false; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + + result = asc->VerifyMsg(startMsg); + EXPECT_EQ(result, false); + + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_003 end"); +} + +/** + * @tc.name: VerifyMsg_004 + * @tc.desc: appspawn VerifyMsg + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, VerifyMsg_004, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_004 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003, -1}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + bool result = false; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + result = asc->VerifyMsg(startMsg); + EXPECT_EQ(result, false); + + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_004 end"); +} + +/** + * @tc.name: VerifyMsg_005 + * @tc.desc: appspawn VerifyMsg + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, VerifyMsg_005, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_005 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002}; + std::string procName(""); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + auto asc = std::make_shared(false); + int32_t ret = 0; + bool result = false; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + result = asc->VerifyMsg(startMsg); + EXPECT_EQ(result, false); + + TAG_LOGI(AAFwkTag::TEST, "VerifyMsg_005 end"); +} + +/** + * @tc.name: SetChildProcessTypeStartFlag_001 + * @tc.desc: appspawn SetChildProcessTypeStartFlag + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetChildProcessTypeStartFlag_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetChildProcessTypeStartFlag_001 start"); + AppSpawnStartMsg startMsg = {0}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + int32_t childProcessType = 1; + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetChildProcessTypeStartFlag(reqHandle, childProcessType); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "SetChildProcessTypeStartFlag_001 end"); +} + +/** + * @tc.name: SetChildProcessTypeStartFlag_002 + * @tc.desc: appspawn SetChildProcessTypeStartFlag + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetChildProcessTypeStartFlag_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetChildProcessTypeStartFlag_002 start"); + AppSpawnStartMsg startMsg = {0}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + int32_t childProcessType = -1; + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetChildProcessTypeStartFlag(reqHandle, childProcessType); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "SetChildProcessTypeStartFlag_002 end"); +} + +/** + * @tc.name: SetExtMsgFds_001 + * @tc.desc: appspawn SetExtMsgFds + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetExtMsgFds_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetExtMsgFds_001 start"); + AppSpawnStartMsg startMsg = {0}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + startMsg.fds.emplace("test_fd1", 100); + startMsg.fds.emplace("test_fd2", 101); + startMsg.fds.emplace("test_fd3", 102); + + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetExtMsgFds(reqHandle, startMsg.fds); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "SetExtMsgFds_001 end"); +} + +/** + * @tc.name: SetExtMsgFds_002 + * @tc.desc: appspawn SetExtMsgFds + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetExtMsgFds_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetExtMsgFds_002 start"); + AppSpawnStartMsg startMsg = {0}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + startMsg.fds.emplace("test_fd1", 100); + startMsg.fds.emplace("test_fd2", 101); + startMsg.fds.emplace("test_fd3", -1); + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetExtMsgFds(reqHandle, startMsg.fds); + EXPECT_NE(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "SetExtMsgFds_002 end"); +} + +/** + * @tc.name: SetIsolationModeFlag_001 + * @tc.desc: appspawn SetIsolationModeFlag + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetIsolationModeFlag_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetIsolationModeFlag_001 start"); + AppSpawnStartMsg startMsg = {0}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + startMsg.isolationMode = true; + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetIsolationModeFlag(startMsg, reqHandle); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "SetIsolationModeFlag_001 end"); +} + +/** + * @tc.name: SetIsolationModeFlag_002 + * @tc.desc: appspawn SetIsolationModeFlag + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, SetIsolationModeFlag_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "SetIsolationModeFlag_002 start"); + AppSpawnStartMsg startMsg = {0}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + startMsg.isolationMode = false; + auto asc = std::make_shared(false); + int32_t ret = 0; + AppSpawnReqMsgHandle reqHandle = nullptr; + ret = asc->OpenConnection(); + EXPECT_EQ(ret, ERR_OK); + ret = AppSpawnReqMsgCreate(static_cast(startMsg.code), startMsg.procName.c_str(), &reqHandle); + EXPECT_EQ(ret, ERR_OK); + ret = asc->SetIsolationModeFlag(startMsg, reqHandle); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "SetIsolationModeFlag_002 end"); +} + + +/** + * @tc.name: StartProcess_001 + * @tc.desc: appspawn StartProcess + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, StartProcess_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "StartProcess_001 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + int32_t ret = 0; + auto asc = std::make_shared(false); + pid_t pid = 0; + ret = asc->StartProcess(startMsg, pid); + EXPECT_NE(ret, ERR_OK); + + TAG_LOGI(AAFwkTag::TEST, "StartProcess_001 end"); +} + +/** + * @tc.name: StartProcess_002 + * @tc.desc: appspawn StartProcess + * @tc.type: FUNC + * @tc.require: issueI5W4S7 + */ +HWTEST_F(AppSpawnClientTest, StartProcess_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "StartProcess_002 start"); + AppSpawnStartMsg startMsg = {0}; + startMsg.uid = 1001; + startMsg.gid = 2001; + startMsg.gids = {1001, 1002, 1003, -1}; + std::string procName("test_proc_name"); + startMsg.procName = procName; + std::string permission1("permission_for_test_1"); + std::string permission2("permission_for_test_2"); + std::string permission3("permission_for_test_3"); + startMsg.permissions.insert(permission1); + startMsg.permissions.insert(permission2); + startMsg.permissions.insert(permission3); + startMsg.flags = 0x1000; + startMsg.atomicServiceFlag = false; + startMsg.strictMode = false; + startMsg.isolatedExtension = false; + startMsg.childProcessType = 1; + startMsg.isolationMode = false; + std::string provisionType("test_provisionType"); + startMsg.provisionType = provisionType; + std::string processType("test_processType"); + startMsg.processType = processType; + startMsg.maxChildProcess = 1; + std::string extensionSandboxPath("test_extensionSandboxPath"); + startMsg.extensionSandboxPath = extensionSandboxPath; + + int32_t ret = 0; + auto asc = std::make_shared(false); + pid_t pid = 0; + ret = asc->StartProcess(startMsg, pid); + EXPECT_NE(ret, ERR_OK); + + TAG_LOGI(AAFwkTag::TEST, "StartProcess_002 end"); +} + + } // namespace AppExecFwk } // namespace OHOS From 2ca04c9a34bac88f02b9f4eded6e411c4d09b4fa Mon Sep 17 00:00:00 2001 From: yuwenze Date: Tue, 24 Sep 2024 12:02:46 +0800 Subject: [PATCH 09/26] fixed Signed-off-by: yuwenze Change-Id: I4df5db87950fcec5c8b07907f05d41ccf2d28da1 --- .../src/scene_board/ui_ability_lifecycle_manager.cpp | 9 +++++---- .../abilitymgr/src/utils/ability_permission_util.cpp | 4 ++++ .../ability_permission_util_test.cpp | 12 +++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) 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 e8f64c53d5..e260811972 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -357,11 +357,12 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(const AbilityRequest &a } auto sessionInfo = CreateSessionInfo(abilityRequest); sessionInfo->requestCode = abilityRequest.requestCode; - sessionInfo->persistentId = GetPersistentIdByAbilityRequest(abilityRequest, sessionInfo->reuse); - auto instanceKey = abilityRequest.want.GetStringParam(Want::APP_INSTANCE_KEY); - if (!instanceKey.empty()) { - sessionInfo->instanceKey = instanceKey; + auto isCreating = abilityRequest.want.GetBoolParam(Want::CREATE_APP_INSTANCE_KEY, false); + if (abilityInfo.applicationInfo.multiAppMode.multiAppModeType != AppExecFwk::MultiAppModeType::MULTI_INSTANCE || + !isCreating) { + sessionInfo->persistentId = GetPersistentIdByAbilityRequest(abilityRequest, sessionInfo->reuse); } + sessionInfo->instanceKey = abilityRequest.want.GetStringParam(Want::APP_INSTANCE_KEY); sessionInfo->userId = userId_; sessionInfo->isAtomicService = (abilityInfo.applicationInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE); TAG_LOGI( diff --git a/services/abilitymgr/src/utils/ability_permission_util.cpp b/services/abilitymgr/src/utils/ability_permission_util.cpp index ae800a60da..1bbc3d7bcf 100644 --- a/services/abilitymgr/src/utils/ability_permission_util.cpp +++ b/services/abilitymgr/src/utils/ability_permission_util.cpp @@ -21,6 +21,7 @@ #include "app_utils.h" #include "accesstoken_kit.h" #include "hitrace_meter.h" +#include "implicit_start_processor.h" #include "insight_intent_execute_param.h" #include "ipc_skeleton.h" #include "permission_constants.h" @@ -109,6 +110,9 @@ bool AbilityPermissionUtil::IsDominateScreen(const Want &want, bool isPendingWan int32_t AbilityPermissionUtil::CheckMultiInstanceAndAppClone(Want &want, int32_t userId, int32_t appIndex, sptr callerToken) { + if (ImplicitStartProcessor::IsImplicitStartAction(want)) { + return ERR_OK; + } auto instanceKey = want.GetStringParam(Want::APP_INSTANCE_KEY); auto isCreating = want.GetBoolParam(Want::CREATE_APP_INSTANCE_KEY, false); AppExecFwk::ApplicationInfo appInfo; diff --git a/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp b/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp index 2db1d6ba5e..e639085cc1 100644 --- a/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp +++ b/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp @@ -56,11 +56,7 @@ HWTEST_F(AbilityPermissionUtilTest, AbilityPermissionUtil_CheckMultiInstanceAndA bool isSupportMultiInstance = AppUtils::GetInstance().IsSupportMultiInstance(); std::string deviceType = OHOS::system::GetDeviceType(); TAG_LOGI(AAFwkTag::TEST, "current deviceType is %{public}s", deviceType.c_str()); - if (deviceType == "2in1") { - EXPECT_EQ(result, RESOLVE_ABILITY_ERR); - } else { - EXPECT_EQ(result, ERR_OK); - } + EXPECT_EQ(result, ERR_OK); TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil_CheckMultiInstanceAndAppClone_0100 end"); } @@ -74,7 +70,10 @@ HWTEST_F(AbilityPermissionUtilTest, AbilityPermissionUtil_CheckMultiInstanceAndA HWTEST_F(AbilityPermissionUtilTest, AbilityPermissionUtil_CheckMultiInstanceAndAppClone_0200, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil_CheckMultiInstanceAndAppClone_0200 start"); + std::string bundleName = "com.ohos.test"; + std::string abilityName = "EntryAbility"; Want want; + want.SetElementName(bundleName, abilityName); std::string instanceKey = "app_instance_0"; want.SetParam(Want::APP_INSTANCE_KEY, instanceKey); auto result = AbilityPermissionUtil::GetInstance().CheckMultiInstanceAndAppClone(want, 100, 0, nullptr); @@ -100,7 +99,10 @@ HWTEST_F(AbilityPermissionUtilTest, AbilityPermissionUtil_CheckMultiInstanceAndA HWTEST_F(AbilityPermissionUtilTest, AbilityPermissionUtil_CheckMultiInstanceAndAppClone_0300, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil_CheckMultiInstanceAndAppClone_0300 start"); + std::string bundleName = "com.ohos.test"; + std::string abilityName = "EntryAbility"; Want want; + want.SetElementName(bundleName, abilityName); want.SetParam(Want::CREATE_APP_INSTANCE_KEY, true); auto result = AbilityPermissionUtil::GetInstance().CheckMultiInstanceAndAppClone(want, 100, 0, nullptr); From 845efdf73d288aba40b8ef6393274412fbb0b4b6 Mon Sep 17 00:00:00 2001 From: Tintin9529 Date: Tue, 24 Sep 2024 13:54:50 +0800 Subject: [PATCH 10/26] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=8B=A6=E6=88=AA=E6=B7=BB=E5=8A=A0=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tintin9529 --- services/abilitymgr/src/ability_manager_service.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 22029b48cb..b80156dc53 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -6219,7 +6219,10 @@ int AbilityManagerService::GenerateAbilityRequest(const Want &want, int requestC } if (ModalSystemDialogUtil::CheckDebugAppNotInDeveloperMode(request.abilityInfo.applicationInfo)) { - if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + // service and extension do not show dialog. + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled() && + !(request.abilityInfo.type == AppExecFwk::AbilityType::SERVICE || + request.abilityInfo.type == AppExecFwk::AbilityType::EXTENSION)) { ModalSystemDialogUtil::ShowDeveloperModeDialog(request.abilityInfo.bundleName, request.abilityInfo.name); } TAG_LOGE(AAFwkTag::ABILITYMGR, "not developer mode"); From 80629f3c975fd4b54805f003d7f009f281ed87d6 Mon Sep 17 00:00:00 2001 From: hhl Date: Mon, 23 Sep 2024 20:20:00 +0800 Subject: [PATCH 11/26] add testcase Signed-off-by: hhl --- .../ability_recovery_test.cpp | 37 ++++++++++ .../app_recovery_test/app_recovery_test.cpp | 22 ++++++ .../dfr_test/appfreeze_inner_test/BUILD.gn | 2 +- .../dfr_test/appfreeze_manager_test/BUILD.gn | 2 +- .../appfreeze_manager_test.cpp | 69 +++++++++++++++++++ .../dfr_test/appfreeze_state_test/BUILD.gn | 2 +- test/unittest/dfr_test/watchdog_test/BUILD.gn | 2 +- .../dfr_test/watchdog_test/watchdog_test.cpp | 33 +++++++++ 8 files changed, 165 insertions(+), 4 deletions(-) diff --git a/test/unittest/app_recovery_test/ability_recovery_test.cpp b/test/unittest/app_recovery_test/ability_recovery_test.cpp index dcf0c54f53..77e12c9be7 100644 --- a/test/unittest/app_recovery_test/ability_recovery_test.cpp +++ b/test/unittest/app_recovery_test/ability_recovery_test.cpp @@ -513,6 +513,19 @@ HWTEST_F(AbilityRecoveryUnitTest, PersistAppState_002, TestSize.Level1) EXPECT_TRUE(abilityRecovery_->PersistState()); } +/** + * @tc.name: PersistAppState_003 + * @tc.desc: add testcase. + * @tc.type: FUNC + * @tc.require: I5Z7LE + */ +HWTEST_F(AbilityRecoveryUnitTest, PersistAppState_003, TestSize.Level1) +{ + abilityRecovery_->abilityInfo_ = abilityInfo_; + abilityRecovery_->missionId_ = -1; + EXPECT_FALSE(abilityRecovery_->PersistState()); +} + /** * @tc.name: IsSameAbility_001 * @tc.desc: Test IsSameAbility when not set SetJsAbility. @@ -551,5 +564,29 @@ HWTEST_F(AbilityRecoveryUnitTest, TestAppRecoveryAllocator_001, TestSize.Level1) EXPECT_EQ(allocator.Alloc(0), nullptr); EXPECT_EQ(allocator.Realloc(nullptr, 0), nullptr); } + +/** + * @tc.name: Test ReadSerializeDataFromFile + * @tc.desc: add testcase + * @tc.type: Bugfix + */ +HWTEST_F(AbilityRecoveryUnitTest, TestReadSerializeDataFromFile_001, TestSize.Level1) +{ + int32_t savedStateId = 0; + AAFwk::WantParams wantParams; + EXPECT_TRUE(!abilityRecovery_->ReadSerializeDataFromFile(savedStateId, wantParams)); +} + +/** + * @tc.name: Test LoadSavedState + * @tc.desc: add testcase + * @tc.type: Bugfix + */ +HWTEST_F(AbilityRecoveryUnitTest, TestLoadSavedState_001, TestSize.Level1) +{ + abilityRecovery_->hasLoaded_ = false; + abilityRecovery_->missionId_ = 10; + EXPECT_TRUE(!abilityRecovery_->LoadSavedState(StateReason::DEVELOPER_REQUEST)); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_recovery_test/app_recovery_test.cpp b/test/unittest/app_recovery_test/app_recovery_test.cpp index b242f2dc5a..0bc0e7f23b 100644 --- a/test/unittest/app_recovery_test/app_recovery_test.cpp +++ b/test/unittest/app_recovery_test/app_recovery_test.cpp @@ -698,5 +698,27 @@ HWTEST_F(AppRecoveryUnitTest, DeleteInValidMissionFiles_001, TestSize.Level1) AppRecovery::GetInstance().DeleteInValidMissionFiles(); EXPECT_NE(AbilityRuntime::Context::GetApplicationContext(), nullptr); } + +/** + * @tc.name: DeleteInValidMissionFileById_001 + * @tc.desc: add testcase. + */ +HWTEST_F(AppRecoveryUnitTest, DeleteInValidMissionFileById_001, TestSize.Level1) +{ + AbilityRuntime::ApplicationContext::GetInstance()->contextImpl_ = std::make_shared(); + AppRecovery::GetInstance().DeleteInValidMissionFileById("/data/local/tmp", 10); + EXPECT_NE(AbilityRuntime::Context::GetApplicationContext(), nullptr); +} + +/** + * @tc.name: ClearPageStack_001 + * @tc.desc: add testcase. + */ +HWTEST_F(AppRecoveryUnitTest, ClearPageStack_001, TestSize.Level1) +{ + AbilityRuntime::ApplicationContext::GetInstance()->contextImpl_ = std::make_shared(); + AppRecovery::GetInstance().ClearPageStack("ClearPageStack_001"); + EXPECT_NE(AbilityRuntime::Context::GetApplicationContext(), nullptr); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn b/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn index d4818c5bbd..0a334c59b4 100644 --- a/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn +++ b/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") -module_output_path = "ability_runtime/appfreeze_inner_test" +module_output_path = "ability_runtime/dfr_test" ############################################################################### config("module_context_config") { diff --git a/test/unittest/dfr_test/appfreeze_manager_test/BUILD.gn b/test/unittest/dfr_test/appfreeze_manager_test/BUILD.gn index ca35c2db20..c8c755ed45 100644 --- a/test/unittest/dfr_test/appfreeze_manager_test/BUILD.gn +++ b/test/unittest/dfr_test/appfreeze_manager_test/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") -module_output_path = "ability_runtime/appfreeze_inner_test" +module_output_path = "ability_runtime/dfr_test" ############################################################################### config("module_context_config") { diff --git a/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp b/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp index ae70eebc19..03f045f72a 100644 --- a/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp +++ b/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp @@ -98,6 +98,9 @@ HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_002, TestSize.Level1) EXPECT_EQ(ret, 0); ret = appfreezeManager->AcquireStack(faultData, appInfo, "test"); EXPECT_EQ(ret, 0); + faultData.errorObject.name = AppFreezeType::LIFECYCLE_HALF_TIMEOUT; + ret = appfreezeManager->AppfreezeHandleWithStack(faultData, appInfo); + EXPECT_EQ(ret, 0); } /** @@ -200,5 +203,71 @@ HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_006, TestSize.Level1) result = appfreezeManager->IsNeedIgnoreFreezeEvent(pid); EXPECT_TRUE(result); } + +/** + * @tc.number: AppfreezeManagerTest_007 + * @tc.desc: add testcase codecoverage + * @tc.type: FUNC + */ +HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_007, TestSize.Level1) +{ + int32_t pid = static_cast(getprocpid()); + int state = AppfreezeManager::AppFreezeState::APPFREEZE_STATE_IDLE; + EXPECT_EQ(appfreezeManager->GetFreezeState(pid), state); + appfreezeManager->SetFreezeState(pid, + AppfreezeManager::AppFreezeState::APPFREEZE_STATE_FREEZE); + appfreezeManager->SetFreezeState(pid, state); + EXPECT_EQ(appfreezeManager->GetFreezeState(pid), state); +} + +/** + * @tc.number: AppfreezeManagerTest_AppFreezeFilter_001 + * @tc.desc: add testcase codecoverage + * @tc.type: FUNC + */ +HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_AppFreezeFilter_001, TestSize.Level1) +{ + int32_t pid = static_cast(getprocpid()); + EXPECT_TRUE(!appfreezeManager->CancelAppFreezeDetect(pid, "")); + appfreezeManager->ResetAppfreezeState(pid, ""); + EXPECT_TRUE(appfreezeManager->IsValidFreezeFilter(pid, "")); + appfreezeManager->RemoveDeathProcess(""); +} + +/** + * @tc.number: AppfreezeManagerTest_AppFreezeFilter_002 + * @tc.desc: add testcase codecoverage + * @tc.type: FUNC + */ +HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_AppFreezeFilter_002, TestSize.Level1) +{ + int32_t pid = static_cast(getprocpid()); + std::string bundleName = "AppfreezeManagerTest_AppFreezeFilter_002"; + EXPECT_TRUE(appfreezeManager->CancelAppFreezeDetect(pid, bundleName)); + EXPECT_TRUE(appfreezeManager->IsProcessDebug(pid, bundleName)); + appfreezeManager->ResetAppfreezeState(pid, bundleName); + EXPECT_TRUE(!appfreezeManager->IsProcessDebug(pid, bundleName)); + EXPECT_TRUE(!appfreezeManager->IsValidFreezeFilter(pid, bundleName)); + appfreezeManager->RemoveDeathProcess(bundleName); +} + +/** + * @tc.number: AppfreezeManagerTest_CatchStack_001 + * @tc.desc: add testcase codecoverage + * @tc.type: FUNC + */ +HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_CatchStack_001, TestSize.Level1) +{ + int32_t pid = static_cast(getprocpid()); + std::string ret = ""; + appfreezeManager->FindStackByPid(ret, pid); + EXPECT_TRUE(ret.empty()); + appfreezeManager->catchStackMap_[pid] = "AppfreezeManagerTest_CatchStack_001"; + appfreezeManager->FindStackByPid(ret, pid); + EXPECT_TRUE(!ret.empty()); + EXPECT_TRUE(!appfreezeManager->catchStackMap_.empty()); + appfreezeManager->DeleteStack(pid); + EXPECT_TRUE(appfreezeManager->catchStackMap_.empty()); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn b/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn index 422a69dcb9..b28a2ed51d 100644 --- a/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn +++ b/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") -module_output_path = "ability_runtime/appfreeze_state_test" +module_output_path = "ability_runtime/dfr_test" ############################################################################### config("module_context_config") { diff --git a/test/unittest/dfr_test/watchdog_test/BUILD.gn b/test/unittest/dfr_test/watchdog_test/BUILD.gn index 9f6238bdb1..8faac0b8ba 100644 --- a/test/unittest/dfr_test/watchdog_test/BUILD.gn +++ b/test/unittest/dfr_test/watchdog_test/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") -module_output_path = "ability_runtime/watchdog_test" +module_output_path = "ability_runtime/dfr_test" ############################################################################### config("module_context_config") { diff --git a/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp b/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp index be58e12cee..c98f9c3be0 100644 --- a/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp +++ b/test/unittest/dfr_test/watchdog_test/watchdog_test.cpp @@ -132,6 +132,39 @@ HWTEST_F(WatchdogTest, AppExecFwk_watchdog_ReportEvent_0002, Function | MediumTe EXPECT_TRUE(1); } +/** + * @tc.number: AppExecFwk_watchdog_ReportEvent_0003 + * @tc.name: ReportEvent + * @tc.desc: Test ReportEvent. + * @tc.require: I5UL6H + */ +HWTEST_F(WatchdogTest, AppExecFwk_watchdog_ReportEvent_0003, Function | MediumTest | Level3) +{ + watchdog_->isBgWorkingThread_.store(true); + watchdog_->ReportEvent(); + EXPECT_TRUE(watchdog_->needReport_); +} + +/** + * @tc.number: AppExecFwk_watchdog_ReportEvent_0004 + * @tc.name: ReportEvent + * @tc.desc: Test ReportEvent. + * @tc.require: I5UL6H + */ +HWTEST_F(WatchdogTest, AppExecFwk_watchdog_ReportEvent_0004, Function | MediumTest | Level3) +{ + watchdog_->isBgWorkingThread_.store(false); + watchdog_->lastWatchTime_ = std::chrono::duration_cast(std::chrono:: + system_clock::now().time_since_epoch()).count() - TEST_INTERVAL_TIME; + watchdog_->needReport_ = true; + watchdog_->isSixSecondEvent_.store(true); + watchdog_->isInBackground_.store(false); + watchdog_->ReportEvent(); + watchdog_->needReport_ = false; + watchdog_->ReportEvent(); + EXPECT_TRUE(!watchdog_->needReport_); +} + /** * @tc.number: WatchdogTest_Init_001 * @tc.name: Init From 548a700a1de096cf9faa47d1dc5f532553a7ec74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E5=86=AC=E5=86=AC=E5=86=AC?= Date: Tue, 24 Sep 2024 14:23:32 +0800 Subject: [PATCH 12/26] =?UTF-8?q?Message:biner=E8=A7=A3=E6=9E=90=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 郑冬冬冬 --- services/appdfr/src/appfreeze_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appdfr/src/appfreeze_manager.cpp b/services/appdfr/src/appfreeze_manager.cpp index 39967e788d..15eb0e2c8c 100644 --- a/services/appdfr/src/appfreeze_manager.cpp +++ b/services/appdfr/src/appfreeze_manager.cpp @@ -329,7 +329,7 @@ std::map> AppfreezeManager::BinderParser(std::ifstream& fin, continue; } - if (line.find("async") != std::string::npos) { + if (line.find("async\t") != std::string::npos) { continue; } From bf287dd58ca7c758e20cd00eed4cc72812916cf9 Mon Sep 17 00:00:00 2001 From: yangxuguang-huawei Date: Fri, 20 Sep 2024 18:38:27 +0800 Subject: [PATCH 13/26] feat: add permission for pc-low-mem Signed-off-by: yangxuguang-huawei --- .../ability_manager/include/process_options.h | 2 + .../src/ability_manager_service.cpp | 12 +- services/abilitymgr/src/process_options.cpp | 5 + .../ui_ability_lifecycle_manager.cpp | 3 +- .../common/src/permission_verification.cpp | 32 +- test/unittest/BUILD.gn | 1 + .../BUILD.gn | 77 ++++ .../ability_manager_service_seventh_test.cpp | 338 ++++++++++++++++++ .../include/app_utils.h | 38 ++ .../include/mock_ability_manager_service.h | 41 +++ .../include/permission_verification.h | 47 +++ .../src/app_utils.cpp | 40 +++ .../src/mock_ability_manager_service.cpp | 78 ++++ .../src/permission_verification.cpp | 51 +++ 14 files changed, 741 insertions(+), 24 deletions(-) create mode 100644 test/unittest/ability_manager_service_seventh_test/BUILD.gn create mode 100644 test/unittest/ability_manager_service_seventh_test/ability_manager_service_seventh_test.cpp create mode 100644 test/unittest/ability_manager_service_seventh_test/include/app_utils.h create mode 100644 test/unittest/ability_manager_service_seventh_test/include/mock_ability_manager_service.h create mode 100644 test/unittest/ability_manager_service_seventh_test/include/permission_verification.h create mode 100644 test/unittest/ability_manager_service_seventh_test/src/app_utils.cpp create mode 100644 test/unittest/ability_manager_service_seventh_test/src/mock_ability_manager_service.cpp create mode 100644 test/unittest/ability_manager_service_seventh_test/src/permission_verification.cpp diff --git a/interfaces/inner_api/ability_manager/include/process_options.h b/interfaces/inner_api/ability_manager/include/process_options.h index 17a26e7c9f..fe62eedd5d 100644 --- a/interfaces/inner_api/ability_manager/include/process_options.h +++ b/interfaces/inner_api/ability_manager/include/process_options.h @@ -25,6 +25,7 @@ enum class ProcessMode { NEW_PROCESS_ATTACH_TO_PARENT = 1, NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM = 2, ATTACH_TO_STATUS_BAR_ITEM = 3, + NO_ATTACHMENT = 99, END }; @@ -49,6 +50,7 @@ public: static bool IsNewProcessMode(ProcessMode value); static bool IsAttachToStatusBarMode(ProcessMode value); static bool IsValidProcessMode(ProcessMode value); + static bool IsNoAttachmentMode(ProcessMode value); ProcessMode processMode = ProcessMode::UNSPECIFIED; StartupVisibility startupVisibility = StartupVisibility::UNSPECIFIED; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index c7a72731f6..229f57e00a 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -10532,7 +10532,8 @@ int32_t AbilityManagerService::CheckProcessOptions(const Want &want, const Start (startOptions.processOptions->startupVisibility == StartupVisibility::STARTUP_HIDE); bool hasStartBackgroundAbilityPermission = PermissionVerification::GetInstance()-> VerifyStartUIAbilityToHiddenPermission(); - bool canStartupHide = (isStartupVisibilityHide && hasStartBackgroundAbilityPermission); + bool canStartupHide = (ProcessOptions::IsNoAttachmentMode(startOptions.processOptions->processMode) && + isStartupVisibilityHide && hasStartBackgroundAbilityPermission); if (!CheckCallingTokenId(element.GetBundleName(), userId, appIndex) && !canStartupHide) { TAG_LOGE(AAFwkTag::ABILITYMGR, "not self application and has no start background ability permission"); @@ -12300,6 +12301,11 @@ int32_t AbilityManagerService::BlockAllAppStart(bool flag) HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); + if (!AppUtils::GetInstance().IsStartOptionsWithAnimation()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "not supported device"); + return ERR_PERMISSION_DENIED; + } + if (!PermissionVerification::GetInstance()->VerifyBlockAllAppStartPermission()) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Permission verification failed"); return ERR_PERMISSION_DENIED; @@ -12312,6 +12318,10 @@ int32_t AbilityManagerService::BlockAllAppStart(bool flag) bool AbilityManagerService::ShouldBlockAllAppStart() { + if (!AppUtils::GetInstance().IsStartOptionsWithAnimation()) { + return false; + } + std::unique_lock lock(shouldBlockAllAppStartMutex_); return shouldBlockAllAppStart_; } diff --git a/services/abilitymgr/src/process_options.cpp b/services/abilitymgr/src/process_options.cpp index b9bb380d6d..04f64c6c8d 100644 --- a/services/abilitymgr/src/process_options.cpp +++ b/services/abilitymgr/src/process_options.cpp @@ -93,5 +93,10 @@ bool ProcessOptions::IsValidProcessMode(ProcessMode value) { return (value > ProcessMode::UNSPECIFIED) && (value < ProcessMode::END); } + +bool ProcessOptions::IsNoAttachmentMode(ProcessMode value) +{ + return (value == ProcessMode::NO_ATTACHMENT); +} } // namespace AAFwk } // namespace OHOS 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 79be55fa6f..52672f7a5e 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -2516,7 +2516,8 @@ int UIAbilityLifecycleManager::ChangeAbilityVisibility(sptr token auto sessionInfo = abilityRecord->GetSessionInfo(); CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); if (sessionInfo->processOptions == nullptr || - !ProcessOptions::IsAttachToStatusBarMode(sessionInfo->processOptions->processMode)) { + (!ProcessOptions::IsAttachToStatusBarMode(sessionInfo->processOptions->processMode) && + !ProcessOptions::IsNoAttachmentMode(sessionInfo->processOptions->processMode))) { TAG_LOGE(AAFwkTag::ABILITYMGR, "process options check failed"); return ERR_START_OPTIONS_CHECK_FAILED; } diff --git a/services/common/src/permission_verification.cpp b/services/common/src/permission_verification.cpp index 935cc0c5a9..d9ddbef444 100644 --- a/services/common/src/permission_verification.cpp +++ b/services/common/src/permission_verification.cpp @@ -536,34 +536,22 @@ bool PermissionVerification::VerifyKillProcessDependedOnWebPermission() const bool PermissionVerification::VerifyBlockAllAppStartPermission() const { - if (!IsSACall()) { - TAG_LOGE(AAFwkTag::DEFAULT, "not SA call"); - return false; + if (IsSACall() && VerifyCallingPermission(PermissionConstants::PERMISSION_BLOCK_ALL_APP_START)) { + TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted"); + return true; } -#ifdef ENABLE_BLOCK_ALL_APP_START - if (!VerifyCallingPermission(PermissionConstants::PERMISSION_BLOCK_ALL_APP_START)) { - TAG_LOGE(AAFwkTag::DEFAULT, "no PERMISSION_BLOCK_ALL_APP_START"); - return false; - } -#endif - TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted"); - return true; + TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied"); + return false; } bool PermissionVerification::VerifyStartUIAbilityToHiddenPermission() const { - if (!IsSACall()) { - TAG_LOGE(AAFwkTag::DEFAULT, "not SA call"); - return false; + if (IsSACall() && VerifyCallingPermission(PermissionConstants::PERMISSION_START_UIABILITY_TO_HIDDEN)) { + TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted"); + return true; } -#ifdef ENABLE_BLOCK_ALL_APP_START - if (!VerifyCallingPermission(PermissionConstants::PERMISSION_START_UIABILITY_TO_HIDDEN)) { - TAG_LOGE(AAFwkTag::DEFAULT, "no PERMISSION_START_UIABILITY_TO_HIDDEN"); - return false; - } -#endif - TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted"); - return true; + TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied"); + return false; } } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index cffa110fae..8bf56e97e0 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -348,6 +348,7 @@ group("unittest") { "ability_manager_service_first_test:unittest", "ability_manager_service_fourth_test:unittest", "ability_manager_service_second_test:unittest", + "ability_manager_service_seventh_test:unittest", "ability_manager_service_sixth_test:unittest", "ability_manager_service_third_test:unittest", "ability_manager_stub_test:unittest", diff --git a/test/unittest/ability_manager_service_seventh_test/BUILD.gn b/test/unittest/ability_manager_service_seventh_test/BUILD.gn new file mode 100644 index 0000000000..8037bbe972 --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/BUILD.gn @@ -0,0 +1,77 @@ +# Copyright (c) 2024 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. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/abilitymgr" + +ohos_unittest("ability_manager_service_seventh_test") { + module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } + branch_protector_ret = "pac_ret" + include_dirs = [ + "include/", + "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime/", + "${ability_runtime_path}/interfaces/inner_api/ability_manager/include", + "${ability_runtime_services_path}/common/include", + ] + + sources = [ + "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp", + "ability_manager_service_seventh_test.cpp", + "src/app_utils.cpp", + "src/mock_ability_manager_service.cpp", + "src/permission_verification.cpp", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:process_options", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "hilog:libhilog", + "init:libbegetutil", + "ipc:ipc_core", + ] + + if (ability_runtime_graphics) { + external_deps += [ + "window_manager:libwsutils", + "window_manager:scene_session", + ] + } +} + +group("unittest") { + testonly = true + deps = [ ":ability_manager_service_seventh_test" ] +} diff --git a/test/unittest/ability_manager_service_seventh_test/ability_manager_service_seventh_test.cpp b/test/unittest/ability_manager_service_seventh_test/ability_manager_service_seventh_test.cpp new file mode 100644 index 0000000000..733850b306 --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/ability_manager_service_seventh_test.cpp @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2024 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 + +#include "mock_ability_manager_service.h" +#include "ability_manager_errors.h" +#include "app_utils.h" +#include "hilog_tag_wrapper.h" +#include "permission_verification.h" +#include "process_options.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AppExecFwk; +namespace OHOS { +namespace AAFwk { +namespace { +const char* START_OPTIONS_WITH_ANIMATION = "persist.sys.abilityms.start_options_with_animation"; +} // namespace +class AbilityManagerServiceSeventhTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; + +void AbilityManagerServiceSeventhTest::SetUpTestCase() {} + +void AbilityManagerServiceSeventhTest::TearDownTestCase() {} + +void AbilityManagerServiceSeventhTest::SetUp() {} + +void AbilityManagerServiceSeventhTest::TearDown() {} + +/* + * Feature: AbilityManagerService + * Name: BlockAllAppStart_001 + * Function: BlockAllAppStart + * SubFunction: NA + * FunctionPoints: AbilityManagerService BlockAllAppStart + */ +HWTEST_F(AbilityManagerServiceSeventhTest, BlockAllAppStart_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_001 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + PermissionVerification::flag = PermissionVerification::FLAG::IS_SA_CALL; + PermissionVerification::hasBlockAllAppStartPermission = true; + AppUtils::isStartOptionsWithAnimation_ = true; + EXPECT_EQ(AppUtils::GetInstance().IsStartOptionsWithAnimation(), true); + EXPECT_EQ(PermissionVerification::GetInstance()->VerifyBlockAllAppStartPermission(), true); + auto retCode = abilityMs_->BlockAllAppStart(true); + EXPECT_EQ(retCode, ERR_OK); + EXPECT_EQ(abilityMs_->shouldBlockAllAppStart_, true); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_001 end"); +} + +/* + * Feature: AbilityManagerService + * Name: BlockAllAppStart_002 + * Function: BlockAllAppStart + * SubFunction: NA + * FunctionPoints: AbilityManagerService BlockAllAppStart + */ +HWTEST_F(AbilityManagerServiceSeventhTest, BlockAllAppStart_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_002 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + AppUtils::isStartOptionsWithAnimation_ = false; + EXPECT_EQ(AppUtils::GetInstance().IsStartOptionsWithAnimation(), false); + auto retCode = abilityMs_->BlockAllAppStart(true); + EXPECT_EQ(retCode, ERR_PERMISSION_DENIED); + EXPECT_EQ(abilityMs_->shouldBlockAllAppStart_, false); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_002 end"); +} + +/* + * Feature: AbilityManagerService + * Name: BlockAllAppStart_003 + * Function: BlockAllAppStart + * SubFunction: NA + * FunctionPoints: AbilityManagerService BlockAllAppStart + */ +HWTEST_F(AbilityManagerServiceSeventhTest, BlockAllAppStart_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_003 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + AppUtils::isStartOptionsWithAnimation_ = true; + EXPECT_EQ(AppUtils::GetInstance().IsStartOptionsWithAnimation(), true); + PermissionVerification::flag = PermissionVerification::FLAG::IS_SA_CALL; + PermissionVerification::hasBlockAllAppStartPermission = false; + EXPECT_EQ(PermissionVerification::GetInstance()->VerifyBlockAllAppStartPermission(), false); + auto retCode = abilityMs_->BlockAllAppStart(true); + EXPECT_EQ(retCode, ERR_PERMISSION_DENIED); + EXPECT_EQ(abilityMs_->shouldBlockAllAppStart_, false); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_003 end"); +} + +/* + * Feature: AbilityManagerService + * Name: BlockAllAppStart_004 + * Function: BlockAllAppStart + * SubFunction: NA + * FunctionPoints: AbilityManagerService BlockAllAppStart + */ +HWTEST_F(AbilityManagerServiceSeventhTest, BlockAllAppStart_004, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_004 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + PermissionVerification::flag = PermissionVerification::FLAG::IS_SA_CALL; + PermissionVerification::hasBlockAllAppStartPermission = true; + AppUtils::isStartOptionsWithAnimation_ = true; + EXPECT_EQ(AppUtils::GetInstance().IsStartOptionsWithAnimation(), true); + EXPECT_EQ(PermissionVerification::GetInstance()->VerifyBlockAllAppStartPermission(), true); + auto retCode = abilityMs_->BlockAllAppStart(false); + EXPECT_EQ(retCode, ERR_OK); + EXPECT_EQ(abilityMs_->shouldBlockAllAppStart_, false); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest BlockAllAppStart_004 end"); +} + +/* + * Feature: AbilityManagerService + * Name: ShouldBlockAllAppStart_001 + * Function: ShouldBlockAllAppStart + * SubFunction: NA + * FunctionPoints: AbilityManagerService ShouldBlockAllAppStart + */ +HWTEST_F(AbilityManagerServiceSeventhTest, ShouldBlockAllAppStart_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest ShouldBlockAllAppStart_001 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + AppUtils::isStartOptionsWithAnimation_ = true; + EXPECT_EQ(AppUtils::GetInstance().IsStartOptionsWithAnimation(), true); + abilityMs_->shouldBlockAllAppStart_ = true; + EXPECT_EQ(abilityMs_->shouldBlockAllAppStart_, true); + EXPECT_EQ(abilityMs_->ShouldBlockAllAppStart(), true); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest ShouldBlockAllAppStart_001 end"); +} + +/* + * Feature: AbilityManagerService + * Name: ShouldBlockAllAppStart_002 + * Function: ShouldBlockAllAppStart + * SubFunction: NA + * FunctionPoints: AbilityManagerService ShouldBlockAllAppStart + */ +HWTEST_F(AbilityManagerServiceSeventhTest, ShouldBlockAllAppStart_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest ShouldBlockAllAppStart_002 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + AppUtils::isStartOptionsWithAnimation_ = false; + EXPECT_EQ(AppUtils::GetInstance().IsStartOptionsWithAnimation(), false); + EXPECT_EQ(abilityMs_->ShouldBlockAllAppStart(), false); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest ShouldBlockAllAppStart_002 end"); +} + +/* + * Feature: AbilityManagerService + * Name: ShouldBlockAllAppStart_003 + * Function: ShouldBlockAllAppStart + * SubFunction: NA + * FunctionPoints: AbilityManagerService ShouldBlockAllAppStart + */ +HWTEST_F(AbilityManagerServiceSeventhTest, ShouldBlockAllAppStart_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest ShouldBlockAllAppStart_003 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + AppUtils::isStartOptionsWithAnimation_ = true; + EXPECT_EQ(AppUtils::GetInstance().IsStartOptionsWithAnimation(), true); + abilityMs_->shouldBlockAllAppStart_ = false; + EXPECT_EQ(abilityMs_->shouldBlockAllAppStart_, false); + EXPECT_EQ(abilityMs_->ShouldBlockAllAppStart(), false); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest ShouldBlockAllAppStart_003 end"); +} + +/* + * Feature: AbilityManagerService + * Name: CheckProcessOptions_001 + * Function: CheckProcessOptions + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckProcessOptions + */ +HWTEST_F(AbilityManagerServiceSeventhTest, CheckProcessOptions_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_001 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + PermissionVerification::flag = PermissionVerification::FLAG::IS_SA_CALL; + PermissionVerification::hasStartUIAbilityToHiddenPermission = true; + EXPECT_EQ(PermissionVerification::GetInstance()->VerifyStartUIAbilityToHiddenPermission(), true); + Want want; + want.SetElementName("bundle", "ability"); + StartOptions startOptions; + startOptions.processOptions = std::make_shared(); + startOptions.processOptions->processMode = ProcessMode::NO_ATTACHMENT; + startOptions.processOptions->startupVisibility = StartupVisibility::STARTUP_HIDE; + auto retCode = abilityMs_->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(retCode, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_001 end"); +} + +/* + * Feature: AbilityManagerService + * Name: CheckProcessOptions_002 + * Function: CheckProcessOptions + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckProcessOptions + */ +HWTEST_F(AbilityManagerServiceSeventhTest, CheckProcessOptions_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_002 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + Want want; + want.SetElementName("bundle", "ability"); + StartOptions startOptions; + auto retCode = abilityMs_->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(retCode, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_002 end"); +} + +/* + * Feature: AbilityManagerService + * Name: CheckProcessOptions_003 + * Function: CheckProcessOptions + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckProcessOptions + */ +HWTEST_F(AbilityManagerServiceSeventhTest, CheckProcessOptions_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_003 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + Want want; + want.SetElementName("bundle", "ability"); + StartOptions startOptions; + startOptions.processOptions = std::make_shared(); + auto retCode = abilityMs_->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(retCode, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_003 end"); +} + +/* + * Feature: AbilityManagerService + * Name: CheckProcessOptions_004 + * Function: CheckProcessOptions + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckProcessOptions + */ +HWTEST_F(AbilityManagerServiceSeventhTest, CheckProcessOptions_004, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_004 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + PermissionVerification::flag = PermissionVerification::FLAG::IS_SA_CALL; + PermissionVerification::hasStartUIAbilityToHiddenPermission = true; + EXPECT_EQ(PermissionVerification::GetInstance()->VerifyStartUIAbilityToHiddenPermission(), true); + Want want; + want.SetElementName("bundle", "ability"); + StartOptions startOptions; + startOptions.processOptions = std::make_shared(); + startOptions.processOptions->processMode = ProcessMode::NO_ATTACHMENT; + auto retCode = abilityMs_->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(retCode, ERR_NOT_SELF_APPLICATION); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_004 end"); +} + +/* + * Feature: AbilityManagerService + * Name: CheckProcessOptions_005 + * Function: CheckProcessOptions + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckProcessOptions + */ +HWTEST_F(AbilityManagerServiceSeventhTest, CheckProcessOptions_005, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_005 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + PermissionVerification::flag = 0; + Want want; + want.SetElementName("bundle", "ability"); + StartOptions startOptions; + startOptions.processOptions = std::make_shared(); + startOptions.processOptions->processMode = ProcessMode::NO_ATTACHMENT; + startOptions.processOptions->startupVisibility = StartupVisibility::STARTUP_HIDE; + auto retCode = abilityMs_->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(retCode, ERR_NOT_SELF_APPLICATION); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_005 end"); +} + +/* + * Feature: AbilityManagerService + * Name: CheckProcessOptions_006 + * Function: CheckProcessOptions + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckProcessOptions + */ +HWTEST_F(AbilityManagerServiceSeventhTest, CheckProcessOptions_006, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_006 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + PermissionVerification::flag = PermissionVerification::FLAG::IS_SA_CALL; + PermissionVerification::hasStartUIAbilityToHiddenPermission = false; + EXPECT_EQ(PermissionVerification::GetInstance()->VerifyStartUIAbilityToHiddenPermission(), false); + Want want; + want.SetElementName("bundle", "ability"); + StartOptions startOptions; + startOptions.processOptions = std::make_shared(); + startOptions.processOptions->processMode = ProcessMode::NO_ATTACHMENT; + startOptions.processOptions->startupVisibility = StartupVisibility::STARTUP_HIDE; + auto retCode = abilityMs_->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(retCode, ERR_NOT_SELF_APPLICATION); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSeventhTest CheckProcessOptions_006 end"); +} +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/ability_manager_service_seventh_test/include/app_utils.h b/test/unittest/ability_manager_service_seventh_test/include/app_utils.h new file mode 100644 index 0000000000..0e115c4a3a --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/include/app_utils.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 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_APP_UTILS_H +#define OHOS_ABILITY_RUNTIME_APP_UTILS_H + +#include "nocopyable.h" + +namespace OHOS { +namespace AAFwk { +class AppUtils { +public: + static AppUtils &GetInstance(); + static bool isStartOptionsWithAnimation_; + + ~AppUtils(); + bool IsStartOptionsWithAnimation(); + +private: + AppUtils(); + + DISALLOW_COPY_AND_MOVE(AppUtils); +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_APP_UTILS_H diff --git a/test/unittest/ability_manager_service_seventh_test/include/mock_ability_manager_service.h b/test/unittest/ability_manager_service_seventh_test/include/mock_ability_manager_service.h new file mode 100644 index 0000000000..6f5024c65c --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/include/mock_ability_manager_service.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_SERVICE_H +#define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_SERVICE_H + +#include "ffrt.h" +#include "start_options.h" +#include "want.h" + +namespace OHOS { +namespace AAFwk { +/** + * @class AbilityManagerService + * AbilityManagerService provides a facility for managing ability life cycle. + */ +class AbilityManagerService : public std::enable_shared_from_this { +public: + int32_t BlockAllAppStart(bool flag); + int32_t CheckProcessOptions(const Want &want, const StartOptions &startOptions, int32_t userId); + bool ShouldBlockAllAppStart(); + +public: + ffrt::mutex shouldBlockAllAppStartMutex_; + bool shouldBlockAllAppStart_ = false; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_SERVICE_H diff --git a/test/unittest/ability_manager_service_seventh_test/include/permission_verification.h b/test/unittest/ability_manager_service_seventh_test/include/permission_verification.h new file mode 100644 index 0000000000..2d1583891f --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/include/permission_verification.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 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_PERMISSION_VERIFICATION_H +#define OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H + +#include "singleton.h" + +namespace OHOS { +namespace AAFwk { +class PermissionVerification : public DelayedSingleton { +public: + PermissionVerification() = default; + ~PermissionVerification() = default; + + enum FLAG { + IS_SA_CALL = 1, + }; + + static bool hasBlockAllAppStartPermission; + static bool hasStartUIAbilityToHiddenPermission; + static int flag; + + bool IsSACall(); + + bool VerifyBlockAllAppStartPermission(); + + bool VerifyStartUIAbilityToHiddenPermission(); + +private: + DISALLOW_COPY_AND_MOVE(PermissionVerification); +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H diff --git a/test/unittest/ability_manager_service_seventh_test/src/app_utils.cpp b/test/unittest/ability_manager_service_seventh_test/src/app_utils.cpp new file mode 100644 index 0000000000..aa27d97252 --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/src/app_utils.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 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 "app_utils.h" + +#include "hilog_tag_wrapper.h" + +namespace OHOS { +namespace AAFwk { +bool AppUtils::isStartOptionsWithAnimation_ = false; + +AppUtils::~AppUtils() {} + +AppUtils::AppUtils() {} + +AppUtils &AppUtils::GetInstance() +{ + static AppUtils utils; + return utils; +} + +bool AppUtils::IsStartOptionsWithAnimation() +{ + TAG_LOGD(AAFwkTag::DEFAULT, "called %{public}d", isStartOptionsWithAnimation_); + return isStartOptionsWithAnimation_; +} +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/ability_manager_service_seventh_test/src/mock_ability_manager_service.cpp b/test/unittest/ability_manager_service_seventh_test/src/mock_ability_manager_service.cpp new file mode 100644 index 0000000000..2fb86a0334 --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/src/mock_ability_manager_service.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 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 "mock_ability_manager_service.h" + +#include "ability_manager_errors.h" +#include "app_utils.h" +#include "hilog_tag_wrapper.h" +#include "permission_verification.h" +#include "process_options.h" + +namespace OHOS { +namespace AAFwk { +int32_t AbilityManagerService::CheckProcessOptions(const Want &want, const StartOptions &startOptions, int32_t userId) +{ + if (startOptions.processOptions == nullptr || + !ProcessOptions::IsValidProcessMode(startOptions.processOptions->processMode)) { + return ERR_OK; + } + + TAG_LOGI(AAFwkTag::ABILITYMGR, "start ability with process options"); + + bool isStartupVisibilityHide = + (startOptions.processOptions->startupVisibility == StartupVisibility::STARTUP_HIDE); + bool hasStartBackgroundAbilityPermission = PermissionVerification::GetInstance()-> + VerifyStartUIAbilityToHiddenPermission(); + bool canStartupHide = (ProcessOptions::IsNoAttachmentMode(startOptions.processOptions->processMode) && + isStartupVisibilityHide && hasStartBackgroundAbilityPermission); + if (!canStartupHide) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "not self application and has no start background ability permission"); + return ERR_NOT_SELF_APPLICATION; + } + + return ERR_OK; +} + +int32_t AbilityManagerService::BlockAllAppStart(bool flag) +{ + TAG_LOGI(AAFwkTag::ABILITYMGR, "call"); + + if (!AppUtils::GetInstance().IsStartOptionsWithAnimation()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "not supported device"); + return ERR_PERMISSION_DENIED; + } + + if (!PermissionVerification::GetInstance()->VerifyBlockAllAppStartPermission()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Permission verification failed"); + return ERR_PERMISSION_DENIED; + } + + std::unique_lock lock(shouldBlockAllAppStartMutex_); + shouldBlockAllAppStart_ = flag; + return ERR_OK; +} + +bool AbilityManagerService::ShouldBlockAllAppStart() +{ + if (!AppUtils::GetInstance().IsStartOptionsWithAnimation()) { + return false; + } + + std::unique_lock lock(shouldBlockAllAppStartMutex_); + return shouldBlockAllAppStart_; +} +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/ability_manager_service_seventh_test/src/permission_verification.cpp b/test/unittest/ability_manager_service_seventh_test/src/permission_verification.cpp new file mode 100644 index 0000000000..56eeda753c --- /dev/null +++ b/test/unittest/ability_manager_service_seventh_test/src/permission_verification.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 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 "permission_verification.h" + +#include "hilog_tag_wrapper.h" + +namespace OHOS { +namespace AAFwk { +int PermissionVerification::flag = 0; +bool PermissionVerification::hasBlockAllAppStartPermission = false; +bool PermissionVerification::hasStartUIAbilityToHiddenPermission = false; + +bool PermissionVerification::IsSACall() +{ + return (flag == FLAG::IS_SA_CALL); +} + +bool PermissionVerification::VerifyBlockAllAppStartPermission() +{ + if (IsSACall() && hasBlockAllAppStartPermission) { + TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted"); + return true; + } + TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied"); + return false; +} + +bool PermissionVerification::VerifyStartUIAbilityToHiddenPermission() +{ + if (IsSACall() && hasStartUIAbilityToHiddenPermission) { + TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted"); + return true; + } + TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied"); + return false; +} +} // namespace AAFwk +} // namespace OHOS From 34b2a8a09c69ed53389d7c9994d53663894b95d6 Mon Sep 17 00:00:00 2001 From: savior-xzh Date: Mon, 23 Sep 2024 16:52:27 +0800 Subject: [PATCH 14/26] tdd Signed-off-by: savior-xzh Change-Id: I1aa783d5a9733119349afe4d44db769534f5d57f --- .../ability_permission_util_test/BUILD.gn | 45 +++++- .../ability_permission_util_test.cpp | 106 +++++++++++++- .../mock/include/mock_my_flag.h | 31 ++++ .../include/mock_permission_verification.h | 100 +++++++++++++ .../mock/src/mock_my_flag.cpp | 22 +++ .../mock/src/mock_permission_verification.cpp | 133 ++++++++++++++++++ 6 files changed, 433 insertions(+), 4 deletions(-) create mode 100644 test/unittest/ability_permission_util_test/mock/include/mock_my_flag.h create mode 100644 test/unittest/ability_permission_util_test/mock/include/mock_permission_verification.h create mode 100644 test/unittest/ability_permission_util_test/mock/src/mock_my_flag.cpp create mode 100644 test/unittest/ability_permission_util_test/mock/src/mock_permission_verification.cpp diff --git a/test/unittest/ability_permission_util_test/BUILD.gn b/test/unittest/ability_permission_util_test/BUILD.gn index 2fe8ef429c..65ccbf477d 100644 --- a/test/unittest/ability_permission_util_test/BUILD.gn +++ b/test/unittest/ability_permission_util_test/BUILD.gn @@ -19,27 +19,68 @@ module_output_path = "ability_runtime/abilitymgr" ohos_unittest("ability_permission_util_test") { module_out_path = module_output_path - sources = [ "ability_permission_util_test.cpp" ] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime/", + "${ability_runtime_path}/interfaces/inner_api/ability_manager/include", + "${ability_runtime_test_path}/mock/ability_manager_collaborator", + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_test_path}/mock/mock_sa_call", + "${ability_runtime_test_path}/mock/prepare_terminate_callback", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit/include", + "${ability_runtime_test_path}/unittest/app_debug_listener_stub_test", + "mock/include", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + sources = [ + "ability_permission_util_test.cpp", + "mock/src/mock_my_flag.cpp", + "mock/src/mock_permission_verification.cpp", + ] + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/common:app_util", "//third_party/googletest:gtest_main", ] external_deps = [ + "ability_base:base", + "ability_base:configuration", "ability_base:want", - "ability_runtime:app_manager", + "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", + "access_token:libaccesstoken_sdk", + "appspawn:appspawn_client", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "dsoftbus:softbus_client", "ffrt:libffrt", + "hicollie:libhicollie", "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", + "json:nlohmann_json_static", "jsoncpp:jsoncpp", + "kv_store:distributeddata_mgr", + "memory_utils:libmeminfo", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", ] } diff --git a/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp b/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp index b31354d1e3..7a4c32ba90 100644 --- a/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp +++ b/test/unittest/ability_permission_util_test/ability_permission_util_test.cpp @@ -15,19 +15,31 @@ #include +#include "mock_permission_verification.h" #define private public -#include "ability_record.h" #include "utils/ability_permission_util.h" +#include "ability_info.h" +#include "ability_record.h" +#include "ability_util.h" +#include "accesstoken_kit.h" #include "app_utils.h" +#include "ipc_skeleton.h" +#include "running_process_info.h" +#include "permission_constants.h" +#include "permission_verification.h" #undef private #include "hilog_tag_wrapper.h" #include "parameters.h" using namespace testing; using namespace testing::ext; +using namespace OHOS::AppExecFwk; +using AbilityRequest = OHOS::AAFwk::AbilityRequest; +using OHOS::AppExecFwk::AbilityType; +using OHOS::AAFwk::AbilityPermissionUtil; namespace OHOS { -namespace AAFwk { +namespace AbilityRuntime { class AbilityPermissionUtilTest : public testing::Test { public: static void SetUpTestCase(); @@ -311,5 +323,95 @@ HWTEST_F(AbilityPermissionUtilTest, AbilityPermissionUtil_CheckMultiInstanceKeyF EXPECT_EQ(result, ERR_MULTI_INSTANCE_NOT_SUPPORTED); TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil_CheckMultiInstanceKeyForExtension_0300 end"); } + +/** + * @tc.name: IsDominateScreen_0100 + * @tc.desc: IsDominateScreen_0100 Test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(AbilityPermissionUtilTest, IsDominateScreen_0100, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0100 start"); + + Want want; + bool isPendingWantCaller = true; + bool ret = AbilityPermissionUtil::GetInstance().IsDominateScreen(want, isPendingWantCaller); + EXPECT_FALSE(ret); + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0100 end"); +} + +/** + * @tc.name: IsDominateScreen_0200 + * @tc.desc: IsDominateScreen_0200 Test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(AbilityPermissionUtilTest, IsDominateScreen_0200, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0200 start"); + + MyFlag::flag_ = 1; + Want want; + bool isPendingWantCaller = false; + bool ret = AbilityPermissionUtil::GetInstance().IsDominateScreen(want, isPendingWantCaller); + EXPECT_FALSE(ret); + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0200 end"); +} + +/** + * @tc.name: IsDominateScreen_0300 + * @tc.desc: IsDominateScreen_0300 Test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(AbilityPermissionUtilTest, IsDominateScreen_0300, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0300 start"); + + MyFlag::flag_ = 2; + Want want; + bool isPendingWantCaller = false; + bool ret = AbilityPermissionUtil::GetInstance().IsDominateScreen(want, isPendingWantCaller); + EXPECT_FALSE(ret); + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0300 end"); +} + +/** + * @tc.name: IsDominateScreen_0400 + * @tc.desc: IsDominateScreen_0400 Test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(AbilityPermissionUtilTest, IsDominateScreen_0400, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0400 start"); + + MyFlag::flag_ = 3; + Want want; + bool isPendingWantCaller = false; + bool ret = AbilityPermissionUtil::GetInstance().IsDominateScreen(want, isPendingWantCaller); + EXPECT_FALSE(ret); + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0400 end"); +} + +/** + * @tc.name: IsDominateScreen_0500 + * @tc.desc: IsDominateScreen_0500 Test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(AbilityPermissionUtilTest, IsDominateScreen_0500, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0500 start"); + + MyFlag::flag_ = 3; + Want want; + want.SetParam("ohos.insightIntent.executeParam.name", true); + bool isPendingWantCaller = false; + bool ret = AbilityPermissionUtil::GetInstance().IsDominateScreen(want, isPendingWantCaller); + EXPECT_FALSE(ret); + TAG_LOGI(AAFwkTag::TEST, "AbilityPermissionUtil IsDominateScreen_0500 end"); +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/ability_permission_util_test/mock/include/mock_my_flag.h b/test/unittest/ability_permission_util_test/mock/include/mock_my_flag.h new file mode 100644 index 0000000000..2ee3eafe7f --- /dev/null +++ b/test/unittest/ability_permission_util_test/mock/include/mock_my_flag.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 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 MOCK_MY_FLAG_H +#define MOCK_MY_FLAG_H +namespace OHOS { +namespace AAFwk { +class MyFlag { +public: + enum FLAG { + IS_SA_CALL = 1, + IS_SHELL_CALL, + IS_SA_AND_SHELL_CALL, + }; + static int flag_; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // MOCK_MY_FLAG_H \ No newline at end of file diff --git a/test/unittest/ability_permission_util_test/mock/include/mock_permission_verification.h b/test/unittest/ability_permission_util_test/mock/include/mock_permission_verification.h new file mode 100644 index 0000000000..4fcc914ac4 --- /dev/null +++ b/test/unittest/ability_permission_util_test/mock/include/mock_permission_verification.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 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_PERMISSION_VERIFICATION_H +#define OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H + +#include "ipc_skeleton.h" +#include "singleton.h" +#include "want.h" +#include "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { + +class PermissionVerification : public DelayedSingleton { +public: +struct VerificationInfo { + bool visible = false; + bool isBackgroundCall = true; + bool associatedWakeUp = false; + uint32_t accessTokenId = 0; + int32_t apiTargetVersion = 0; +}; + + PermissionVerification() = default; + ~PermissionVerification() = default; + + bool VerifyCallingPermission(const std::string &permissionName) const; + + bool IsSACall() const; + + bool IsShellCall() const; + + bool CheckSpecificSystemAbilityAccessPermission() const; + + bool VerifyRunningInfoPerm() const; + + bool VerifyControllerPerm() const; + + bool VerifyDlpPermission(Want &want) const; + + int VerifyAccountPermission() const; + + bool VerifyMissionPermission() const; + + int VerifyAppStateObserverPermission() const; + + int32_t VerifyUpdateConfigurationPerm() const; + + bool VerifyInstallBundlePermission() const; + + bool VerifyGetBundleInfoPrivilegedPermission() const; + + int CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const; + + int CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const; + + int CheckStartByCallPermission(const VerificationInfo &verificationInfo) const; + + unsigned int GetCallingTokenID() const; + + bool JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const; + + bool JudgeStartAbilityFromBackground(const bool isBackgroundCall) const; + + bool JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const; + + int JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const; + + inline bool IsCallFromSameAccessToken(const uint32_t accessTokenId) const + { + return IPCSkeleton::GetCallingTokenID() == accessTokenId; + } + + bool JudgeCallerIsAllowedToUseSystemAPI() const; + bool IsSystemAppCall() const; + + bool VerifyPrepareTerminatePermission() const; + + bool VerifySetProcessCachePermission() const; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H \ No newline at end of file diff --git a/test/unittest/ability_permission_util_test/mock/src/mock_my_flag.cpp b/test/unittest/ability_permission_util_test/mock/src/mock_my_flag.cpp new file mode 100644 index 0000000000..c509149c67 --- /dev/null +++ b/test/unittest/ability_permission_util_test/mock/src/mock_my_flag.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 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 "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { +int MyFlag::flag_ = 0; +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_permission_util_test/mock/src/mock_permission_verification.cpp b/test/unittest/ability_permission_util_test/mock/src/mock_permission_verification.cpp new file mode 100644 index 0000000000..6fbc5bcf3e --- /dev/null +++ b/test/unittest/ability_permission_util_test/mock/src/mock_permission_verification.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2024 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 "mock_permission_verification.h" + +namespace OHOS { +namespace AAFwk { + +bool PermissionVerification::VerifyCallingPermission(const std::string &permissionName) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::IsSACall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SA_CALL); +} +bool PermissionVerification::IsShellCall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SHELL_CALL); +} +bool PermissionVerification::CheckSpecificSystemAbilityAccessPermission() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyRunningInfoPerm() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyControllerPerm() const +{ + return !!(MyFlag::flag_); +} +#ifdef WITH_DLP +bool PermissionVerification::VerifyDlpPermission(Want &want) const +{ + return !!(MyFlag::flag_); +} +#endif // WITH_DLP +int PermissionVerification::VerifyAccountPermission() const +{ + return MyFlag::flag_; +} +bool PermissionVerification::VerifyMissionPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::VerifyAppStateObserverPermission() const +{ + return MyFlag::flag_; +} +int32_t PermissionVerification::VerifyUpdateConfigurationPerm() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::VerifyInstallBundlePermission() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyGetBundleInfoPrivilegedPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckStartByCallPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +unsigned int PermissionVerification::GetCallingTokenID() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartAbilityFromBackground(const bool isBackgroundCall) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +bool PermissionVerification::JudgeCallerIsAllowedToUseSystemAPI() const +{ + return true; +} +bool PermissionVerification::VerifyPrepareTerminatePermission() const +{ + return true; +} +bool PermissionVerification::IsSystemAppCall() const +{ + return true; +} + +bool PermissionVerification::VerifySetProcessCachePermission() const +{ + return true; +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file From 524720eb2a6be4240e1142973462970d09c8c330 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 24 Sep 2024 14:52:11 +0800 Subject: [PATCH 15/26] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../src/ability_manager_service.cpp | 56 ++++++------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 41d12af7b6..0644e6e79f 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -12261,48 +12261,28 @@ void AbilityManagerService::SetAbilityRequestSessionInfo(AbilityRequest &ability if (extensionType != AppExecFwk::ExtensionAbilityType::UI_SERVICE) { return; } + abilityRequest.want.RemoveParam(WANT_PARAMS_HOST_WINDOW_ID_KEY); auto callerAbilityRecord = Token::GetAbilityRecordByToken(abilityRequest.callerToken); - if(callerAbilityRecord != nullptr) { - if (callerAbilityRecord->GetAbilityInfo().type == AbilityType::PAGE) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "UIAbility Caller"); - sptr callerSessionInfo = callerAbilityRecord->GetSessionInfo(); - if (callerSessionInfo != nullptr) { - abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, callerSessionInfo->persistentId); - } - } else if (callerAbilityRecord->GetAbilityInfo().type == AppExecFwk::AbilityType::EXTENSION && - AAFwk::UIExtensionUtils::IsUIExtension(callerAbilityRecord->GetAbilityInfo().extensionAbilityType)) { - CHECK_POINTER(abilityRequest.callerToken); - auto abilityRecord = Token::GetAbilityRecordByToken(abilityRequest.callerToken); - CHECK_POINTER(abilityRecord); - auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE; - auto connectManager = GetConnectManagerByUserId(userId); - if (connectManager == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo manager null, userId:%{public}d", userId); - return; - } - UIExtensionSessionInfo uiExtensionSessionInfo; - auto ret = connectManager->GetUIExtensionSessionInfo(abilityRequest.callerToken, uiExtensionSessionInfo); - if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo get ui extension session info failed"); - return; - } - int32_t mainWindowId = 0; - auto sceneSessionManager = Rosen::SessionManagerLite::GetInstance(). - GetSceneSessionManagerLiteProxy(); - CHECK_POINTER(sceneSessionManager); - auto err = sceneSessionManager->GetRootMainWindowId(static_cast(uiExtensionSessionInfo.hostWindowId),mainWindowId); - TAG_LOGI(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo uiExtensionSessionInfo.hostWindowId = %{public}d", - uiExtensionSessionInfo.hostWindowId); - TAG_LOGI(AAFwkTag::ABILITYMGR, "SetAbilityRequestSessionInfo mainWindowId = %{public}d, err = %{public}d", mainWindowId, err); - abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, mainWindowId); - } else { - abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, 0); - } + CHECK_POINTER_LOG(callerAbilityRecord, "callerAbilityRecord is nullptr"); + sptr callerSessionInfo = callerAbilityRecord->GetSessionInfo(); + CHECK_POINTER_LOG(callerSessionInfo, "callerSessionInfo is nullptr"); + + if (callerAbilityRecord->GetAbilityInfo().type == AbilityType::PAGE) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "UIAbility Caller"); + abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, callerSessionInfo->persistentId); + } else if (AAFwk::UIExtensionUtils::IsUIExtension(callerAbilityRecord->GetAbilityInfo().extensionAbilityType)) { + int32_t mainWindowId = -1; + auto sceneSessionManager = Rosen::SessionManagerLite::GetInstance(). + GetSceneSessionManagerLiteProxy(); + CHECK_POINTER_LOG(sceneSessionManager, "sceneSessionManager is nullptr"); + auto err = sceneSessionManager->GetRootMainWindowId(static_cast(callerSessionInfo->hostWindowId),mainWindowId); + TAG_LOGI(AAFwkTag::ABILITYMGR, "callerSessionInfo->hostWindowId = %{public}d, mainWindowId = %{public}d, err = %{public}d", + callerSessionInfo->hostWindowId, mainWindowId, err); + abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, mainWindowId); } else { - TAG_LOGE(AAFwkTag::ABILITYMGR, "callerAbilityRecord is nullptr"); + abilityRequest.want.SetParam(WANT_PARAMS_HOST_WINDOW_ID_KEY, 0); } - TAG_LOGI(AAFwkTag::ABILITYMGR, "complete"); } int32_t AbilityManagerService::TerminateMission(int32_t missionId) From 2522428014197c30903cf2f3aa14179abfad0c2b Mon Sep 17 00:00:00 2001 From: liuzongze Date: Tue, 24 Sep 2024 15:15:29 +0800 Subject: [PATCH 16/26] =?UTF-8?q?=E8=BD=BB=E9=87=8F=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=20mock=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuzongze Change-Id: I80c3264dab1377ce5cc922ee809701edecdacc22 --- .../include/js_application_context_utils.h | 1 + .../ability_simulator/src/js_application_context_utils.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/frameworks/simulator/ability_simulator/include/js_application_context_utils.h b/frameworks/simulator/ability_simulator/include/js_application_context_utils.h index ca2bb44399..a35196f033 100644 --- a/frameworks/simulator/ability_simulator/include/js_application_context_utils.h +++ b/frameworks/simulator/ability_simulator/include/js_application_context_utils.h @@ -54,6 +54,7 @@ public: static napi_value GetRunningProcessInformation(napi_env env, napi_callback_info info); static napi_value CreateJsApplicationContext(napi_env env, const std::shared_ptr &context); static napi_value SetSupportedProcessCacheSelf(napi_env env, napi_callback_info info); + static napi_value SetColorMode(napi_env env, napi_callback_info info); napi_value OnGetCacheDir(napi_env env, NapiCallbackInfo& info); napi_value OnGetTempDir(napi_env env, NapiCallbackInfo& info); diff --git a/frameworks/simulator/ability_simulator/src/js_application_context_utils.cpp b/frameworks/simulator/ability_simulator/src/js_application_context_utils.cpp index e926daeed4..df7a13537a 100644 --- a/frameworks/simulator/ability_simulator/src/js_application_context_utils.cpp +++ b/frameworks/simulator/ability_simulator/src/js_application_context_utils.cpp @@ -34,6 +34,11 @@ napi_value JsApplicationContextUtils::CreateBundleContext(napi_env env, napi_cal return nullptr; } +napi_value JsApplicationContextUtils::SetColorMode(napi_env env, napi_callback_info info) +{ + return nullptr; +} + napi_value JsApplicationContextUtils::SwitchArea(napi_env env, napi_callback_info info) { GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnSwitchArea, APPLICATION_CONTEXT_NAME); @@ -355,6 +360,7 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_ JsApplicationContextUtils::GetRunningProcessInformation); BindNativeFunction(env, object, "getRunningProcessInformation", MD_NAME, JsApplicationContextUtils::GetRunningProcessInformation); + BindNativeFunction(env, object, "setColorMode", MD_NAME, JsApplicationContextUtils::SetColorMode); } } // namespace AbilityRuntime } // namespace OHOS From bf7520a7394cdb6dcd806ad1a81e7e02d08fe4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Sat, 21 Sep 2024 19:45:28 +0800 Subject: [PATCH 17/26] description:add test case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙旭辉 --- test/unittest/BUILD.gn | 3 + .../ability_interceptor_second_test/BUILD.gn | 94 +++ .../ability_interceptor_second_test.cpp | 253 +++++++ .../ability_interceptor_third_test/BUILD.gn | 96 +++ .../ability_interceptor_third_test.cpp | 87 +++ .../BUILD.gn | 17 + .../ability_manager_service_sixth_test.cpp | 668 ++++++++++++++++++ .../mock/include/mock_my_flag.h | 31 + .../include/mock_permission_verification.h | 102 +++ .../mock/src/mock_my_flag.cpp | 22 + .../mock/src/mock_permission_verification.cpp | 134 ++++ .../dialog_session_manager_test/BUILD.gn | 74 ++ .../dialog_session_manager_test.cpp | 275 +++++++ 13 files changed, 1856 insertions(+) create mode 100644 test/unittest/ability_interceptor_second_test/BUILD.gn create mode 100644 test/unittest/ability_interceptor_second_test/ability_interceptor_second_test.cpp create mode 100644 test/unittest/ability_interceptor_third_test/BUILD.gn create mode 100644 test/unittest/ability_interceptor_third_test/ability_interceptor_third_test.cpp create mode 100644 test/unittest/ability_manager_service_sixth_test/mock/include/mock_my_flag.h create mode 100644 test/unittest/ability_manager_service_sixth_test/mock/include/mock_permission_verification.h create mode 100644 test/unittest/ability_manager_service_sixth_test/mock/src/mock_my_flag.cpp create mode 100644 test/unittest/ability_manager_service_sixth_test/mock/src/mock_permission_verification.cpp create mode 100644 test/unittest/dialog_session_manager_test/BUILD.gn create mode 100644 test/unittest/dialog_session_manager_test/dialog_session_manager_test.cpp diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 9673ece0a8..8520164271 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -338,7 +338,9 @@ group("unittest") { "ability_first_frame_state_observer_stub_test:unittest", "ability_foreground_state_observer_proxy_test:unittest", "ability_foreground_state_observer_stub_test:unittest", + "ability_interceptor_second_test:unittest", "ability_interceptor_test:unittest", + "ability_interceptor_third_test:unittest", "ability_manager_client_branch_second_test:unittest", "ability_manager_client_branch_test:unittest", "ability_manager_proxy_test:unittest", @@ -472,6 +474,7 @@ group("unittest") { "dataobs_mgr_stub_test:unittest", "deeplink_reserve_config_test:unittest", "dfr_test:unittest", + "dialog_session_manager_test:unittest", "dlp_state_item_test:unittest", "dlp_utils_test:unittest", "dummy_values_bucket_test:unittest", diff --git a/test/unittest/ability_interceptor_second_test/BUILD.gn b/test/unittest/ability_interceptor_second_test/BUILD.gn new file mode 100644 index 0000000000..384759c20b --- /dev/null +++ b/test/unittest/ability_interceptor_second_test/BUILD.gn @@ -0,0 +1,94 @@ +# Copyright (c) 2024 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. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/abilitymgr" + +ohos_unittest("ability_interceptor_second_test") { + module_out_path = module_output_path + cflags_cc = [] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock", + "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", + "${distributedschedule_path}/samgr/adapter/interfaces/innerkits/include/", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_services_path}/abilitymgr/include", + ] + + sources = [ + # add mock file + "${ability_runtime_services_path}/abilitymgr/src/start_ability_utils.cpp", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp", + "ability_interceptor_second_test.cpp", + ] + + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_test_path}/mock/services_abilitymgr_test:aafwk_mock_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + "//third_party/libjpeg-turbo:turbojpeg_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "dsoftbus:softbus_client", + "ffrt:libffrt", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "napi:ace_napi", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } + + if (os_dlp_part_enabled) { + cflags_cc += [ "-DWITH_DLP" ] + } +} + +group("unittest") { + testonly = true + deps = [ ":ability_interceptor_second_test" ] +} diff --git a/test/unittest/ability_interceptor_second_test/ability_interceptor_second_test.cpp b/test/unittest/ability_interceptor_second_test/ability_interceptor_second_test.cpp new file mode 100644 index 0000000000..ce89012d7d --- /dev/null +++ b/test/unittest/ability_interceptor_second_test/ability_interceptor_second_test.cpp @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2024 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 +#define private public +#define protected public +#include "ability_manager_service.h" +#include "interceptor/disposed_rule_interceptor.h" +#undef private +#undef protected + +#include "bundlemgr/mock_bundle_manager.h" +#include "permission_constants.h" +#include "start_ability_utils.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AppExecFwk; + +namespace { +const std::string BUNDLE_NAME = "testBundle"; +constexpr const char* TEST_IS_FROM_PARENTCONTROL = "ohos.ability.isFromParentControl"; +constexpr const char* TEST_INTERCEPT_BUNDLE_NAME = "intercept_bundleName"; +} + +namespace OHOS { +namespace AAFwk { +class AbilityInterceptorSecondTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); + +public: +}; + +void AbilityInterceptorSecondTest::SetUpTestCase() +{ + GTEST_LOG_(INFO) << "AbilityInterceptorSecondTest SetUpTestCase called"; + AbilityManagerClient::GetInstance()->CleanAllMissions(); + OHOS::DelayedSingleton::DestroyInstance(); + + OHOS::DelayedSingleton::GetInstance()->RegisterSystemAbility( + OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, new BundleMgrService()); +} + +void AbilityInterceptorSecondTest::TearDownTestCase() +{ + GTEST_LOG_(INFO) << "AbilityInterceptorSecondTest TearDownTestCase called"; + OHOS::DelayedSingleton::DestroyInstance(); +} + +void AbilityInterceptorSecondTest::SetUp() +{} + +void AbilityInterceptorSecondTest::TearDown() +{} + +HWTEST_F(AbilityInterceptorSecondTest, CreateExecuter_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + EXPECT_NE(executer, nullptr); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_001 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + Want want; + ElementName element("", "com.test.disposedrule", "MainAbility", "entry"); + want.SetElement(element); + AppExecFwk::DisposedRule disposedRule; + disposedRule.disposedType = AppExecFwk::DisposedType::BLOCK_ABILITY; + bool result = executer->CheckDisposedRule(want, disposedRule); + EXPECT_EQ(result, true); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_002 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + Want want; + ElementName element("", "com.test.disposedrule", "MainAbility", "entry"); + want.SetElement(element); + AppExecFwk::DisposedRule disposedRule; + disposedRule.disposedType = AppExecFwk::DisposedType::BLOCK_ABILITY; + disposedRule.controlType = AppExecFwk::ControlType::DISALLOWED_LIST; + bool result = executer->CheckDisposedRule(want, disposedRule); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_003 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + std::string bundleName = "com.example.disposedruletest1"; + Want want; + want.SetBundle(bundleName); + DisposedRule disposedRule; + disposedRule.want = std::make_shared(); + disposedRule.want->SetBundle(bundleName); + ErrCode result = executer->StartNonBlockRule(want, disposedRule); + EXPECT_EQ(result, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_004 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_004, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + std::string bundleName1 = "com.example.disposedruletest1"; + std::string bundleName2 = "com.example.disposedruletest2"; + Want want; + want.SetBundle(bundleName1); + DisposedRule disposedRule; + disposedRule.want = std::make_shared(); + disposedRule.want->SetBundle(bundleName2); + ErrCode result = executer->StartNonBlockRule(want, disposedRule); + EXPECT_NE(result, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_005 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_005, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + std::string bundleName = "com.example.disposedruletest"; + Want want; + want.SetBundle(bundleName); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + sptr callerToken = abilityRecord->GetToken(); + ErrCode result = executer->CreateModalUIExtension(want, callerToken); + EXPECT_EQ(result, INNER_ERR); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_006 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_006, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + std::string bundleName = "com.test.disposedrule"; + Want want; + ElementName element("", "com.test.disposedrule", "MainAbility", "entry"); + want.SetElement(element); + DisposedRule disposedRule; + disposedRule.want = std::make_shared(); + disposedRule.want->SetParam(TEST_IS_FROM_PARENTCONTROL, true); + executer->SetInterceptInfo(want, disposedRule); + EXPECT_STREQ(disposedRule.want->GetStringParam(TEST_INTERCEPT_BUNDLE_NAME).c_str(), bundleName.c_str()); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_007 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_007, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + std::string bundleName = "interceptor_callerBundleName"; + Want want; + want.SetBundle(bundleName); + int32_t userId = 10; + DisposedRule disposedRule; + int32_t appIndex = 0; + bool result = executer->CheckControl(want, userId, disposedRule, appIndex); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: AbilityInterceptorSecondTest_DisposedRuleInterceptor_008 + * @tc.desc: DisposedRuleInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorSecondTest, DisposedRuleInterceptor_008, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + std::shared_ptr executer = std::make_shared(); + std::string bundleName = "interceptor_callerBundleName"; + Want want; + want.SetBundle(bundleName); + int32_t userId = 10; + int32_t appIndex = 0; + DisposedRule disposedRule; + disposedRule.disposedType = AppExecFwk::DisposedType::BLOCK_APPLICATION; + disposedRule.controlType == AppExecFwk::ControlType::DISALLOWED_LIST; + executer->CheckDisposedRule(want, disposedRule); + bool result = executer->CheckControl(want, userId, disposedRule, appIndex); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/ability_interceptor_third_test/BUILD.gn b/test/unittest/ability_interceptor_third_test/BUILD.gn new file mode 100644 index 0000000000..aa0393101c --- /dev/null +++ b/test/unittest/ability_interceptor_third_test/BUILD.gn @@ -0,0 +1,96 @@ +# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/abilitymgr" + +ohos_unittest("ability_interceptor_third_test") { + module_out_path = module_output_path + cflags_cc = [] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock", + "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", + "${distributedschedule_path}/samgr/adapter/interfaces/innerkits/include/", + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_services_path}/abilitymgr/include/interceptor", + ] + + sources = [ + # add mock file + "${ability_runtime_services_path}/abilitymgr/src/interceptor/ability_interceptor_executer.cpp", + "${ability_runtime_services_path}/abilitymgr/src/start_ability_utils.cpp", + "ability_interceptor_third_test.cpp", + ] + + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_test_path}/mock/services_abilitymgr_test:aafwk_mock_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_services_path}/common:task_handler_wrap", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_appmgr_mock", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core:appexecfwk_bundlemgr_mock", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + "//third_party/libjpeg-turbo:turbojpeg_static", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_deps_wrapper", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "dsoftbus:softbus_client", + "ffrt:libffrt", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "napi:ace_napi", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } + + if (os_dlp_part_enabled) { + cflags_cc += [ "-DWITH_DLP" ] + } +} + +group("unittest") { + testonly = true + deps = [ ":ability_interceptor_third_test" ] +} diff --git a/test/unittest/ability_interceptor_third_test/ability_interceptor_third_test.cpp b/test/unittest/ability_interceptor_third_test/ability_interceptor_third_test.cpp new file mode 100644 index 0000000000..454c0d6f95 --- /dev/null +++ b/test/unittest/ability_interceptor_third_test/ability_interceptor_third_test.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024-2024 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 +#define private public +#define protected public +#include "ability_interceptor_executer.h" +#undef private +#undef protected + +#include "interceptor/crowd_test_interceptor.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace AAFwk { +class AbilityInterceptorThirdTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); + +public: +}; + +void AbilityInterceptorThirdTest::SetUpTestCase() +{} + +void AbilityInterceptorThirdTest::TearDownTestCase() +{} + +void AbilityInterceptorThirdTest::SetUp() +{} + +void AbilityInterceptorThirdTest::TearDown() +{} + +/** + * @tc.name: AbilityInterceptorThirdTest_RemoveInterceptor_001 + * @tc.desc: CrowdTestInterceptor + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorThirdTest, RemoveInterceptor_001, TestSize.Level1) +{ + std::shared_ptr executer = std::make_shared(); + executer->AddInterceptor("CrowdTest", std::make_shared()); + auto resMap = executer->GetInterceptorMapCopy(); + EXPECT_EQ(resMap.size(), 1); + executer->RemoveInterceptor("CrowdTest"); + auto resMap2 = executer->GetInterceptorMapCopy(); + EXPECT_EQ(resMap2.size(), 0); +} + +/** + * @tc.name: AbilityInterceptorThirdTest_SetTaskHandler_001 + * @tc.desc: SetTaskHandler + * @tc.type: FUNC + * @tc.require: No + */ +HWTEST_F(AbilityInterceptorThirdTest, SetTaskHandler_001, TestSize.Level1) +{ + std::shared_ptr executer = std::make_shared(); + std::shared_ptr taskHandler = AAFwk::TaskHandlerWrap::CreateQueueHandler("SetTaskHandler"); + executer->AddInterceptor("CrowdTest", std::make_shared()); + executer->SetTaskHandler(taskHandler); + auto resMap2 = executer->GetInterceptorMapCopy(); + EXPECT_EQ(resMap2.size(), 1); +} + +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/ability_manager_service_sixth_test/BUILD.gn b/test/unittest/ability_manager_service_sixth_test/BUILD.gn index e5757bfa76..de74a32996 100644 --- a/test/unittest/ability_manager_service_sixth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_sixth_test/BUILD.gn @@ -28,24 +28,38 @@ ohos_unittest("ability_manager_service_sixth_test") { include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime/", "${ability_runtime_path}/interfaces/inner_api/ability_manager/include", + "${ability_runtime_services_path}/abilitymgr/include/scene_board", + "${ability_runtime_test_path}/mock/common/include", "${ability_runtime_test_path}/mock/mock_sa_call", + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", "${ability_runtime_test_path}/mock/task_handler_wrap_mock/include", "${ability_runtime_test_path}/unittest/ability_manager_client_branch_test", + "mock/include", ] sources = [ "${ability_runtime_services_path}/abilitymgr/src/ability_connect_callback_stub.cpp", + "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", "ability_manager_service_sixth_test.cpp", + "mock/src/mock_my_flag.cpp", + "mock/src/mock_permission_verification.cpp", ] configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", + "${ability_runtime_innerkits_path}/ability_manager:process_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_path}/utils/server/startup:startup_util", "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/abilitymgr:mission_list", "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "//third_party/googletest:gmock_main", @@ -65,14 +79,17 @@ ohos_unittest("ability_manager_service_sixth_test") { "common_event_service:cesfwk_innerkits", "ffrt:libffrt", "hilog:libhilog", + "hitrace:hitrace_meter", "init:libbegetutil", "ipc:ipc_core", + "kv_store:distributeddata_inner", ] if (ability_runtime_graphics) { external_deps += [ "window_manager:libwsutils", "window_manager:scene_session", + "window_manager:session_manager_lite", ] } } diff --git a/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp b/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp index e751608717..a313fa25a8 100644 --- a/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp +++ b/test/unittest/ability_manager_service_sixth_test/ability_manager_service_sixth_test.cpp @@ -18,13 +18,22 @@ #define private public #define protected public #include "ability_manager_service.h" +#include "ability_record.h" +#include "mission_list_manager.h" +#include "ui_ability_lifecycle_manager.h" #undef private #undef protected #include "ability_manager_errors.h" #include "ability_manager_stub_mock_test.h" #include "hilog_tag_wrapper.h" +#include "mock_ability_token.h" +#include "mock_bundle_manager_service.h" +#include "mock_my_flag.h" +#include "mock_permission_verification.h" #include "mock_task_handler_wrap.h" +#include "process_options.h" +#include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; @@ -36,6 +45,29 @@ namespace AAFwk { namespace { const int32_t USER_ID_U100 = 100; const int32_t APP_MEMORY_SIZE = 512; +constexpr const char* DEBUG_APP = "debugApp"; +const std::string TEST_BUNDLE_NAME = "testBundleName"; +const std::string TEST_ABILITY_NAME = "testAbilityName"; +const std::string CONTACTS_BUNDLE_NAME = "com.ohos.contacts"; +const std::string CONTACTS_ABILITY_NAME = "com.ohos.contacts.MainAbility"; +const std::string DEVICE_MANAGER_BUNDLE_NAME = "com.ohos.devicemanagerui"; +const std::string DEVICE_MANAGER_NAME = "com.ohos.devicemanagerui.MainAbility"; +const std::string UIEXTENSION_TYPE_KEY = "ability.want.params.uiExtensionType"; +const std::string AUTO_FILL_PASSWORD_TPYE = "autoFill/password"; +const std::string AUTO_FILL_SMART_TPYE = "autoFill/smart"; +const std::string AUTO_FILL_PASSWORD_ABILITY_NAME = "AutoFillAbility"; +const std::string AUTO_FILL_PASSWORD_BUNDLE_NAME = "com.ohos.passwordbox"; +const std::string AUTO_FILL_MODULE_NAME = "entry"; +const std::string AUTO_FILL_SMART_ABILITY_NAME = "TextAutoFillAbility"; +const std::string AUTO_FILL_SMART_BUNDLE_NAME = "com.ohos.textautofill"; +const int32_t MAIN_USER_ID = 100; +const std::string EMPTY_DEVICE_ID = ""; +constexpr const char* BUNDLE_NAME_LAUNCHER = "com.ohos.launcher"; +constexpr const char* BUNDLE_NAME_SCENEBOARD = "com.ohos.sceneboard"; +constexpr const char* LAUNCHER_ABILITY_NAME = "com.ohos.launcher.MainAbility"; +constexpr const char* SCENEBOARD_ABILITY_NAME = "com.ohos.sceneboard.MainAbility"; +constexpr const char* BUNDLE_NAME_TEST = "com.huawei.hmos.passwordvault"; +constexpr const char* BUNDLE_NAME_SMART_TEST = "com.huawei.hms.textautofill"; } // namespace class AbilityManagerServiceSixthTest : public testing::Test { public: @@ -47,9 +79,12 @@ public: AbilityRequest GenerateAbilityRequest(const std::string& deviceName, const std::string& abilityName, const std::string& appName, const std::string& bundleName, const std::string& moduleName); + std::shared_ptr MockAbilityManagerService(); + public: AbilityRequest abilityRequest_{}; Want want_{}; + AbilityStartSetting abilityStartSetting_; }; AbilityRequest AbilityManagerServiceSixthTest::GenerateAbilityRequest(const std::string& deviceName, @@ -79,6 +114,18 @@ AbilityRequest AbilityManagerServiceSixthTest::GenerateAbilityRequest(const std: return abilityRequest; } +std::shared_ptr AbilityManagerServiceSixthTest::MockAbilityManagerService() +{ + auto abilityMs = std::make_shared(); + auto taskHandler = MockTaskHandlerWrap::CreateQueueHandler("StartAbilityDetails_003"); + auto eventHandler = std::make_shared(taskHandler, abilityMs); + abilityMs->taskHandler_ = taskHandler; + abilityMs->interceptorExecuter_ = std::make_shared(); + abilityMs->afterCheckExecuter_ = std::make_shared(); + abilityMs->subManagersHelper_ = std::make_shared(taskHandler, eventHandler); + return abilityMs; +} + void AbilityManagerServiceSixthTest::SetUpTestCase() {} void AbilityManagerServiceSixthTest::TearDownTestCase() {} @@ -199,5 +246,626 @@ HWTEST_F(AbilityManagerServiceSixthTest, StartUIAbilityBySCBDefault_001, TestSiz EXPECT_EQ(abilityMs->StartUIAbilityBySCBDefault(sessionInfo, sceneFlag, isColdStart), ERR_APP_CLONE_INDEX_INVALID); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartUIAbilityBySCBDefault_001 end"); } + +/* + * Feature: AbilityManagerService + * Function: StartAbilityDetails + * SubFunction: NA + * FunctionPoints: AbilityManagerService StartAbilityDetails + */ +HWTEST_F(AbilityManagerServiceSixthTest, StartAbilityDetails_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_001 start"); + auto abilityMs = std::make_shared(); + Want want; + want.SetParam(DEBUG_APP, true); + want.SetElementName(TEST_BUNDLE_NAME, ""); + + /** + * @tc.steps: step1. DEBUG app which is not exists + * @tc.expected: step1. expect RESOLVE_ABILITY_ERR + */ + auto ret = abilityMs->StartAbilityDetails(want, abilityStartSetting_, nullptr, -1, -1, false); + EXPECT_EQ(ret, RESOLVE_ABILITY_ERR); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: StartAbilityDetails + * SubFunction: NA + * FunctionPoints: AbilityManagerService StartAbilityDetails + */ +HWTEST_F(AbilityManagerServiceSixthTest, StartAbilityDetails_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_0200 start"); + + Want want; + want.SetParam(DEBUG_APP, true); + want.SetElementName(CONTACTS_BUNDLE_NAME, CONTACTS_ABILITY_NAME); + auto abilityMs = std::make_shared(); + auto ret = abilityMs->StartAbilityDetails(want, abilityStartSetting_, nullptr, -1, -1, false); + + /** + * @tc.steps: step2. CONTACTS_BUNDLE_NAME + * @tc.expected: step2. expect ERR_NOT_IN_APP_PROVISION_MODE + */ + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(ret, RESOLVE_ABILITY_ERR); + } else { + EXPECT_EQ(ret, ERR_NOT_IN_APP_PROVISION_MODE); + } + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_0200 end"); +} + +/* + * Feature: AbilityManagerService + * Function: StartAbilityDetails + * SubFunction: NA + * FunctionPoints: AbilityManagerService StartAbilityDetails + */ +HWTEST_F(AbilityManagerServiceSixthTest, StartAbilityDetails_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_002 start"); + auto abilityMs = std::make_shared(); + + /** + * @tc.steps: step1. interceptorExecuter_ is null + * @tc.expected: step1. expect return ERR_INVALID_VALUE when interceptorExecuter_ null + */ + Want want1; + want1.SetElementName(DEVICE_MANAGER_BUNDLE_NAME, DEVICE_MANAGER_NAME); + auto ret = abilityMs->StartAbilityDetails(want1, abilityStartSetting_, nullptr, MAIN_USER_ID, -1, false); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_002 end"); +} + +/* + * Feature: AbilityManagerService + * Function: StartAbilityDetails + * SubFunction: NA + * FunctionPoints: AbilityManagerService StartAbilityDetails + */ +HWTEST_F(AbilityManagerServiceSixthTest, StartAbilityDetails_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_003 start"); + + Want want; + want.SetElementName(CONTACTS_BUNDLE_NAME, CONTACTS_ABILITY_NAME); + auto abilityMs = MockAbilityManagerService(); + auto ret = abilityMs->StartAbilityDetails(want, abilityStartSetting_, nullptr, -1, -1, false); + + /** + * @tc.steps: step2. interceptorExecuter_ is inited, for CONTACTS_BUNDLE_NAME is sigeleton,usrid 0 + * @tc.expected: step2. expect missionListManager/uiAbilityManager null, return ERR_INVALID_VALUE + */ + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(ret, RESOLVE_ABILITY_ERR); + } else { + EXPECT_EQ(ret, ERR_INVALID_VALUE); + } + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityDetails_003 end"); +} + +/* + * Feature: AbilityManagerService + * Function: StartAbilityDetails + * SubFunction: NA + * FunctionPoints: AbilityManagerService StartAbilityInner + */ +HWTEST_F(AbilityManagerServiceSixthTest, StartAbilityInner_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityInner_001 start"); + auto abilityMs = std::make_shared(); + abilityMs->taskHandler_ = MockTaskHandlerWrap::CreateQueueHandler("StartAbilityInner_001"); + abilityMs->interceptorExecuter_ = std::make_shared(); + abilityMs->afterCheckExecuter_ = std::make_shared(); + Want want; + want.SetElementName(CONTACTS_BUNDLE_NAME, CONTACTS_ABILITY_NAME); + auto ret = abilityMs->StartAbilityInner(want, nullptr, -1, false); + + /** + * @tc.steps: step2. interceptorExecuter_ is inited, for CONTACTS_BUNDLE_NAME is sigeleton,usrid 0 + * @tc.expected: step2. expect missionListManager/uiAbilityManager null, return ERR_INVALID_VALUE + */ + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(ret, RESOLVE_ABILITY_ERR); + } else { + EXPECT_EQ(ret, ERR_INVALID_VALUE); + } + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityInner_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: StartAbilityDetails + * SubFunction: NA + * FunctionPoints: AbilityManagerService StartAbilityInner + */ +HWTEST_F(AbilityManagerServiceSixthTest, StartAbilityInner_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityInner_002 start"); + auto abilityMs = std::make_shared(); + + abilityMs->taskHandler_ = MockTaskHandlerWrap::CreateQueueHandler("StartAbilityInner_002"); + abilityMs->interceptorExecuter_ = std::make_shared(); + abilityMs->afterCheckExecuter_ = std::make_shared(); + Want want; + want.SetFlags(Want::FLAG_ABILITY_PREPARE_CONTINUATION); + auto ret = abilityMs->StartAbilityInner(want, nullptr, -1, false, -1, false, -1, true); + EXPECT_EQ(ret, ERR_INVALID_CONTINUATION_FLAG); + + /** + * @tc.steps: step2. interceptorExecuter_ is inited, for CONTACTS_BUNDLE_NAME is sigeleton,usrid 0 + * @tc.expected: step2. expect missionListManager/uiAbilityManager null, return ERR_INVALID_VALUE + */ + auto callerToken = sptr::MakeSptr(); + MyFlag::flag_ = MyFlag::IS_SA_CALL; + Want want2; + want2.SetElementName(CONTACTS_BUNDLE_NAME, CONTACTS_ABILITY_NAME); + ret = abilityMs->StartAbilityInner(want2, callerToken, -1, false, -1, true, 1, true); + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(ret, RESOLVE_ABILITY_ERR); + } else { + EXPECT_EQ(ret, ERR_INVALID_VALUE); + } + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartAbilityInner_002 end"); +} + +/* + * Feature: AbilityManagerService + * Function: SetAutoFillElementName + * SubFunction: NA + * FunctionPoints: AbilityManagerService SetAutoFillElementName + */ +HWTEST_F(AbilityManagerServiceSixthTest, SetAutoFillElementName_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest SetAutoFillElementName_001 start"); + auto abilityMs = std::make_shared(); + sptr extensionSessionInfo = sptr::MakeSptr(); + extensionSessionInfo->want.SetParam(UIEXTENSION_TYPE_KEY, AUTO_FILL_PASSWORD_TPYE); + abilityMs->SetAutoFillElementName(extensionSessionInfo); + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(extensionSessionInfo->want.GetBundle(), BUNDLE_NAME_TEST); + EXPECT_EQ(extensionSessionInfo->want.GetModuleName(), AUTO_FILL_MODULE_NAME); + } else { + EXPECT_EQ(extensionSessionInfo->want.GetBundle(), AUTO_FILL_PASSWORD_BUNDLE_NAME); + EXPECT_EQ(extensionSessionInfo->want.GetModuleName(), AUTO_FILL_MODULE_NAME); + } + + extensionSessionInfo->want.SetParam(UIEXTENSION_TYPE_KEY, AUTO_FILL_SMART_TPYE); + abilityMs->SetAutoFillElementName(extensionSessionInfo); + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(extensionSessionInfo->want.GetBundle(), BUNDLE_NAME_SMART_TEST); + EXPECT_EQ(extensionSessionInfo->want.GetModuleName(), AUTO_FILL_MODULE_NAME); + } else { + EXPECT_EQ(extensionSessionInfo->want.GetBundle(), AUTO_FILL_PASSWORD_BUNDLE_NAME); + EXPECT_EQ(extensionSessionInfo->want.GetModuleName(), AUTO_FILL_MODULE_NAME); + } + + extensionSessionInfo->want = Want(); + EXPECT_EQ(extensionSessionInfo->want.GetBundle(), ""); + EXPECT_EQ(extensionSessionInfo->want.GetModuleName(), ""); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest SetAutoFillElementName_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: CheckUIExtensionUsage + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckUIExtensionUsage + */ +HWTEST_F(AbilityManagerServiceSixthTest, CheckUIExtensionUsage_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest CheckUIExtensionUsage_001 start"); + auto abilityMs = std::make_shared(); + AppExecFwk::UIExtensionUsage uiExtensionUsage = UIExtensionUsage::MODAL; + AppExecFwk::ExtensionAbilityType extensionType = ExtensionAbilityType::WINDOW; + auto ret = abilityMs->CheckUIExtensionUsage(uiExtensionUsage, extensionType); + EXPECT_EQ(ret, ERR_OK); + + MyFlag::flag_ = MyFlag::IS_SA_CALL; + uiExtensionUsage = UIExtensionUsage::EMBEDDED; + extensionType = AppExecFwk::ExtensionAbilityType::AUTO_FILL_PASSWORD; + ret = abilityMs->CheckUIExtensionUsage(uiExtensionUsage, extensionType); + EXPECT_EQ(ret, ERR_OK); + + extensionType = AppExecFwk::ExtensionAbilityType::SERVICE; + ret = abilityMs->CheckUIExtensionUsage(uiExtensionUsage, extensionType); + EXPECT_EQ(ret, ERR_OK); + + uiExtensionUsage = UIExtensionUsage::CONSTRAINED_EMBEDDED; + extensionType = AppExecFwk::ExtensionAbilityType::SYSPICKER_PHOTOPICKER; + ret = abilityMs->CheckUIExtensionUsage(uiExtensionUsage, extensionType); + EXPECT_EQ(ret, ERR_OK); + + uiExtensionUsage = UIExtensionUsage::CONSTRAINED_EMBEDDED; + extensionType = AppExecFwk::ExtensionAbilityType::WINDOW; + ret = abilityMs->CheckUIExtensionUsage(uiExtensionUsage, extensionType); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest CheckUIExtensionUsage_001 end"); + MyFlag::flag_ = 0; +} + +/* + * Feature: AbilityManagerService + * Function: CheckProcessOptions + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckProcessOptions + */ +HWTEST_F(AbilityManagerServiceSixthTest, CheckProcessOptions_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest CheckProcessOptions_001 start"); + auto abilityMs = std::make_shared(); + + Want want; + StartOptions startOptions; + auto ret = abilityMs->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(ret, ERR_OK); + + startOptions.processOptions = std::make_shared(); + ret = abilityMs->CheckProcessOptions(want, startOptions, -1); + EXPECT_EQ(ret, ERR_OK); + + startOptions.processOptions->processMode = ProcessMode::NEW_PROCESS_ATTACH_TO_PARENT; + ret = abilityMs->CheckProcessOptions(want, startOptions, -1); + if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + EXPECT_EQ(ret, ERR_CAPABILITY_NOT_SUPPORT); + } + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest CheckProcessOptions_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: PreStartFreeInstall + * SubFunction: NA + * FunctionPoints: AbilityManagerService PreStartFreeInstall + */ +HWTEST_F(AbilityManagerServiceSixthTest, PreStartFreeInstall_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest PreStartFreeInstall_001 start"); + Want want; + Want localWant; + uint32_t specifyTokenId { 0 }; + bool isStartAsCaller { false }; + auto callerToken = sptr::MakeSptr(); + auto abilityMs_ = std::make_shared(); + abilityMs_->freeInstallManager_ = std::make_shared(abilityMs_); + auto ret = abilityMs_->PreStartFreeInstall(want, callerToken, specifyTokenId, isStartAsCaller, localWant); + EXPECT_EQ(ret, ERR_OK); + + specifyTokenId = 1; + ret = abilityMs_->PreStartFreeInstall(want, callerToken, specifyTokenId, isStartAsCaller, localWant); + EXPECT_EQ(ret, ERR_OK); + + localWant.SetDeviceId("testDevice"); + specifyTokenId = 1; + callerToken = nullptr; + ret = abilityMs_->PreStartFreeInstall(want, callerToken, specifyTokenId, isStartAsCaller, localWant); + EXPECT_EQ(ret, ERR_OK); + + ret = abilityMs_->PreStartFreeInstall(want, callerToken, specifyTokenId, true, localWant); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest PreStartFreeInstall_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: CheckOptExtensionAbility + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckOptExtensionAbility + */ +HWTEST_F(AbilityManagerServiceSixthTest, CheckOptExtensionAbility_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest CheckOptExtensionAbility_001 start"); + Want want; + AbilityRequest abilityRequest; + auto abilityMs_ = std::make_shared(); + AppExecFwk::ExtensionAbilityType extensionType = ExtensionAbilityType::FORM; + int32_t validUserId = 0; + bool isImplicit = false; + bool isStartAsCaller = true; + auto ret = abilityMs_->CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, + isImplicit, isStartAsCaller); + EXPECT_EQ(ret, ERR_WRONG_INTERFACE_CALL); + + abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::EXTENSION; + extensionType = AppExecFwk::ExtensionAbilityType::SERVICE; + ret = abilityMs_->CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, + isImplicit, isStartAsCaller); + EXPECT_EQ(ret, ERR_WRONG_INTERFACE_CALL); + + extensionType = AppExecFwk::ExtensionAbilityType::SERVICE; + abilityRequest.abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::SERVICE; + abilityRequest.want.SetElementName(TEST_BUNDLE_NAME, CONTACTS_ABILITY_NAME); + ret = abilityMs_->CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, + isImplicit, isStartAsCaller); + EXPECT_EQ(ret, ERR_OK); + + extensionType = AppExecFwk::ExtensionAbilityType::DATASHARE; + abilityRequest.abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::DATASHARE; + ret = abilityMs_->CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, + isImplicit, isStartAsCaller); + EXPECT_EQ(ret, ERR_OK); + + extensionType = AppExecFwk::ExtensionAbilityType::UI_SERVICE; + abilityRequest.abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::UI_SERVICE; + ret = abilityMs_->CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, + isImplicit, isStartAsCaller); + EXPECT_EQ(ret, ERR_OK); + + isStartAsCaller = false; + extensionType = ExtensionAbilityType::FORM; + abilityRequest.abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::FORM; + ret = abilityMs_->CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, + isImplicit, isStartAsCaller); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest CheckOptExtensionAbility_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: StartExtensionAbility + * SubFunction: NA + * FunctionPoints: AbilityManagerService StartExtensionAbility + */ +HWTEST_F(AbilityManagerServiceSixthTest, StartExtensionAbility_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest StartExtensionAbility_001 start"); + auto abilityMs = MockAbilityManagerService(); + Want want; + AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UI_SERVICE; + auto ret = abilityMs->StartExtensionAbility(want, nullptr, -1, extensionType); + EXPECT_EQ(ret, ERR_CAPABILITY_NOT_SUPPORT); + + extensionType = AppExecFwk::ExtensionAbilityType::VPN; + ret = abilityMs->StartExtensionAbility(want, nullptr, -1, extensionType); + EXPECT_EQ(ret, ERR_IMPLICIT_START_ABILITY_FAIL); // implicit start ability failed + + auto callerToken = sptr::MakeSptr(); // callerToken not null + ret = abilityMs->StartExtensionAbility(want, callerToken, -1, extensionType); + EXPECT_EQ(ret, ERR_INVALID_CALLER); // caller is not null,expect Invalid caller + + extensionType = AppExecFwk::ExtensionAbilityType::DATASHARE; + ret = abilityMs->StartExtensionAbility(want, nullptr, -1, extensionType); + EXPECT_EQ(ret, ERR_IMPLICIT_START_ABILITY_FAIL); // expect implicit start fail +} + +/* + * Feature: AbilityManagerService + * Function: RecordProcessExitReason + * SubFunction: NA + * FunctionPoints: AbilityManagerService RecordProcessExitReason + */ +HWTEST_F(AbilityManagerServiceSixthTest, RecordProcessExitReason_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest RecordProcessExitReason_001 start"); + auto abilityMs = MockAbilityManagerService(); + MyFlag::flag_ = 0; + ExitReason exitReason; + auto ret = abilityMs->RecordProcessExitReason(1, exitReason); + EXPECT_EQ(ret, ERR_PERMISSION_DENIED); + + MyFlag::flag_ = MyFlag::IS_SA_CALL; + ret = abilityMs->RecordProcessExitReason(1, exitReason); + EXPECT_EQ(ret, ERR_NAME_NOT_FOUND); // init process not record + + MyFlag::flag_ = MyFlag::IS_SHELL_CALL; + ret = abilityMs->RecordProcessExitReason(1, exitReason); + EXPECT_EQ(ret, ERR_NAME_NOT_FOUND); // init process not record + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest RecordProcessExitReason_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: AnonymizeDeviceId + * SubFunction: NA + * FunctionPoints: AbilityManagerService AnonymizeDeviceId + */ +HWTEST_F(AbilityManagerServiceSixthTest, AnonymizeDeviceId_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest AnonymizeDeviceId_001 start"); + auto abilityMs = MockAbilityManagerService(); + std::string deviceId; + auto ret = abilityMs->AnonymizeDeviceId(deviceId); + EXPECT_EQ(ret, EMPTY_DEVICE_ID); + + deviceId = std::string("1234567890"); + ret = abilityMs->AnonymizeDeviceId(deviceId); + EXPECT_EQ(ret, "123456******"); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest AnonymizeDeviceId_001 start"); +} + +/* + * Feature: AbilityManagerService + * Function: MinimizeAbility + * SubFunction: NA + * FunctionPoints: AbilityManagerService MinimizeAbility + */ +HWTEST_F(AbilityManagerServiceSixthTest, MinimizeAbility_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest MinimizeAbility_001 start"); + auto abilityMs = MockAbilityManagerService(); + bool fromUser = true; + auto ret = abilityMs->MinimizeAbility(nullptr, fromUser); + EXPECT_EQ(ret, ERR_INVALID_VALUE); // expect nullptr callerToken invalid + Want want; + AppExecFwk::AbilityInfo abilityInfo; + AppExecFwk::ApplicationInfo applicationInfo; + auto abilityRecord = std::make_shared(want, abilityInfo, applicationInfo); + abilityRecord->Init(); + auto token = abilityRecord->token_; + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + auto uiAbilityLifecycleManager = std::make_shared(); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + abilityMs->subManagersHelper_->uiAbilityManagers_.emplace(0, uiAbilityLifecycleManager); + } else { + auto missionListManager = std::make_shared(0); + missionListManager->terminateAbilityList_.emplace_back(abilityRecord); + abilityMs->subManagersHelper_->missionListManagers_.emplace(0, missionListManager); + ret = abilityMs->MinimizeAbility(token, fromUser); + EXPECT_EQ(ret, ERR_WRONG_INTERFACE_CALL); // expect ERR_WRONG_INTERFACE_CALL abilityRecord type not page + + abilityRecord->abilityInfo_.type = AppExecFwk::AbilityType::PAGE; + ret = abilityMs->MinimizeAbility(token, fromUser); + EXPECT_EQ(ret, ERR_INVALID_VALUE); // expect ERR_INVALID_VALUE + } + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest MinimizeAbility_001 start"); +} + +/* + * Feature: AbilityManagerService + * Function: TerminateAbility + * SubFunction: NA + * FunctionPoints: AbilityManagerService TerminateAbility + */ +HWTEST_F(AbilityManagerServiceSixthTest, TerminateAbility_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest TerminateAbility_001 start"); + auto abilityMs = MockAbilityManagerService(); + Want resultWant; + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + resultWant.SetElementName(BUNDLE_NAME_SCENEBOARD, SCENEBOARD_ABILITY_NAME); + } else { + resultWant.SetElementName(BUNDLE_NAME_LAUNCHER, LAUNCHER_ABILITY_NAME); + } + + AppExecFwk::AbilityInfo abilityInfo; + AppExecFwk::ApplicationInfo applicationInfo; + auto abilityRecord = std::make_shared(resultWant, abilityInfo, applicationInfo); + abilityRecord->Init(); + auto token = abilityRecord->token_; + int resultCode = 0; + auto ret = abilityMs->TerminateAbility(nullptr, resultCode, &resultWant); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + ret = abilityMs->TerminateAbility(token, resultCode, &resultWant); + EXPECT_EQ(ret, ERR_OK); + + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + resultWant.SetElementName(BUNDLE_NAME_SCENEBOARD, ""); + } else { + resultWant.SetElementName(BUNDLE_NAME_LAUNCHER, ""); + } + ret = abilityMs->TerminateAbility(token, resultCode, &resultWant); + EXPECT_EQ(ret, ERR_OK); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest TerminateAbility_001 start"); +} + +/* + * Feature: AbilityManagerService + * Function: MinimizeUIAbilityBySCB + * SubFunction: NA + * FunctionPoints: AbilityManagerService MinimizeUIAbilityBySCB + */ +HWTEST_F(AbilityManagerServiceSixthTest, MinimizeUIAbilityBySCB_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest MinimizeUIAbilityBySCB_001 start"); + auto abilityMs = MockAbilityManagerService(); + auto ret = abilityMs->MinimizeUIAbilityBySCB(nullptr, false, 0); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + auto sessionInfo = sptr::MakeSptr(); + ret = abilityMs->MinimizeUIAbilityBySCB(sessionInfo, false, 0); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + AppExecFwk::AbilityInfo abilityInfo; + AppExecFwk::ApplicationInfo applicationInfo; + Want resultWant; + auto abilityRecord = std::make_shared(resultWant, abilityInfo, applicationInfo); + abilityRecord->Init(); + sessionInfo->sessionToken = abilityRecord->token_; + ret = abilityMs->MinimizeUIAbilityBySCB(sessionInfo, false, 0); + if (!abilityMs->IsCallerSceneBoard()) { + EXPECT_EQ(ret, ERR_WRONG_INTERFACE_CALL); + } else { + EXPECT_EQ(ret, ERR_INVALID_VALUE); + } + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest MinimizeUIAbilityBySCB_001 start"); +} + +/* + * Feature: AbilityManagerService + * Function: DumpState + * SubFunction: NA + * FunctionPoints: AbilityManagerService DumpState + */ +HWTEST_F(AbilityManagerServiceSixthTest, DumpState_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest DumpState_001 start"); + auto abilityMs = MockAbilityManagerService(); + std::string args; + std::vector info; + MyFlag::flag_ = 0; + abilityMs->DumpState(args, info); + EXPECT_TRUE(info.empty()); // permission deny + + MyFlag::flag_ = MyFlag::IS_SHELL_CALL; + args = std::string(""); + abilityMs->DumpState(args, info); + EXPECT_TRUE(info.empty()); // null string + args = std::string("-e"); + abilityMs->DumpState(args, info); // KEY_DUMP_SERVICE + EXPECT_TRUE(info.empty()); + args = std::string("-d"); + abilityMs->DumpState(args, info); // KEY_DUMP_DATA + args = std::string("-a"); // KEY_DUMP_ALL + abilityMs->DumpState(args, info); + args = std::string("-m"); // KEY_DUMP_MISSION + abilityMs->DumpState(args, info); + EXPECT_FALSE(info.empty()); + args = std::string("-m 999999999"); // KEY_DUMP_MISSION 999999999 means missionID + abilityMs->DumpState(args, info); + args = std::string("-L"); // KEY_DUMP_MISSION_LIST + abilityMs->DumpState(args, info); + args = std::string("-S"); + abilityMs->DumpState(args, info); + info.clear(); + args = std::string("-NAN"); // not exsist + abilityMs->DumpState(args, info); + EXPECT_TRUE(info.empty()); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest DumpState_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: DumpSysState + * SubFunction: NA + * FunctionPoints: AbilityManagerService DumpSysState + */ +HWTEST_F(AbilityManagerServiceSixthTest, DumpSysState_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest DumpSysState_001 start"); + auto abilityMs = MockAbilityManagerService(); + std::string args; + std::vector info; + MyFlag::flag_ = 0; + abilityMs->DumpSysState(args, info, false, true, 0); + EXPECT_TRUE(info.empty()); // permission deny + MyFlag::flag_ = MyFlag::IS_SHELL_CALL; + args = std::string(""); + abilityMs->DumpState(args, info); + EXPECT_TRUE(info.empty()); // null string + args = std::string("-a"); + abilityMs->DumpSysState(args, info, false, true, 0); // KEY_DUMP_SYS_ALL + EXPECT_FALSE(info.empty()); + info.clear(); + args = std::string("-p"); + abilityMs->DumpSysState(args, info, false, true, 0); // KEY_DUMP_SYS_PENDING + args = std::string("-r"); + abilityMs->DumpSysState(args, info, false, true, INT_MAX); // KEY_DUMP_SYS_PROCESS + info.clear(); + args = std::string("-d"); // KEY_DUMP_SYS_DATA + abilityMs->DumpSysState(args, info, false, true, INT_MAX); // int_max MEANS userid + args = std::string("--mission-list"); // KEY_DUMP_SYS_MISSION_LIST + abilityMs->DumpSysState(args, info, false, true, 0); + args = std::string("-i"); // KEY_DUMP_MISSION 999999999 means missionID + abilityMs->DumpSysState(args, info, false, true, 0); + info.clear(); + args = std::string("-NAN"); // not exsist + abilityMs->DumpSysState(args, info, false, true, 0); + EXPECT_TRUE(info.empty()); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSixthTest DumpSysState_001 end"); +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/ability_manager_service_sixth_test/mock/include/mock_my_flag.h b/test/unittest/ability_manager_service_sixth_test/mock/include/mock_my_flag.h new file mode 100644 index 0000000000..2ee3eafe7f --- /dev/null +++ b/test/unittest/ability_manager_service_sixth_test/mock/include/mock_my_flag.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 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 MOCK_MY_FLAG_H +#define MOCK_MY_FLAG_H +namespace OHOS { +namespace AAFwk { +class MyFlag { +public: + enum FLAG { + IS_SA_CALL = 1, + IS_SHELL_CALL, + IS_SA_AND_SHELL_CALL, + }; + static int flag_; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // MOCK_MY_FLAG_H \ No newline at end of file diff --git a/test/unittest/ability_manager_service_sixth_test/mock/include/mock_permission_verification.h b/test/unittest/ability_manager_service_sixth_test/mock/include/mock_permission_verification.h new file mode 100644 index 0000000000..a2552bfa7b --- /dev/null +++ b/test/unittest/ability_manager_service_sixth_test/mock/include/mock_permission_verification.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 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_PERMISSION_VERIFICATION_H +#define OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H + +#include + +#include "ipc_skeleton.h" +#include "singleton.h" +#include "want.h" +#include "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { + +class PermissionVerification : public DelayedSingleton { +public: +struct VerificationInfo { + bool visible = false; + bool isBackgroundCall = true; + bool associatedWakeUp = false; + uint32_t accessTokenId = 0; + int32_t apiTargetVersion = 0; +}; + + PermissionVerification() = default; + ~PermissionVerification() = default; + + bool VerifyCallingPermission(const std::string &permissionName) const; + + bool IsSACall() const; + + bool IsShellCall() const; + + bool CheckSpecificSystemAbilityAccessPermission(const std::string &processName) const; + + bool VerifyRunningInfoPerm() const; + + bool VerifyControllerPerm() const; + + bool VerifyDlpPermission(Want &want) const; + + int VerifyAccountPermission() const; + + bool VerifyMissionPermission() const; + + int VerifyAppStateObserverPermission() const; + + int32_t VerifyUpdateConfigurationPerm() const; + + bool VerifyInstallBundlePermission() const; + + bool VerifyGetBundleInfoPrivilegedPermission() const; + + int CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const; + + int CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const; + + int CheckStartByCallPermission(const VerificationInfo &verificationInfo) const; + + unsigned int GetCallingTokenID() const; + + bool JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const; + + bool JudgeStartAbilityFromBackground(const bool isBackgroundCall) const; + + bool JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const; + + int JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const; + + inline bool IsCallFromSameAccessToken(const uint32_t accessTokenId) const + { + return IPCSkeleton::GetCallingTokenID() == accessTokenId; + } + + bool JudgeCallerIsAllowedToUseSystemAPI() const; + bool IsSystemAppCall() const; + + bool VerifyPrepareTerminatePermission() const; + + bool VerifySetProcessCachePermission() const; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H \ No newline at end of file diff --git a/test/unittest/ability_manager_service_sixth_test/mock/src/mock_my_flag.cpp b/test/unittest/ability_manager_service_sixth_test/mock/src/mock_my_flag.cpp new file mode 100644 index 0000000000..c509149c67 --- /dev/null +++ b/test/unittest/ability_manager_service_sixth_test/mock/src/mock_my_flag.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 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 "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { +int MyFlag::flag_ = 0; +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_manager_service_sixth_test/mock/src/mock_permission_verification.cpp b/test/unittest/ability_manager_service_sixth_test/mock/src/mock_permission_verification.cpp new file mode 100644 index 0000000000..53db0c7b7f --- /dev/null +++ b/test/unittest/ability_manager_service_sixth_test/mock/src/mock_permission_verification.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 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 "mock_permission_verification.h" + +namespace OHOS { +namespace AAFwk { + +bool PermissionVerification::VerifyCallingPermission(const std::string &permissionName) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::IsSACall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SA_CALL); +} +bool PermissionVerification::IsShellCall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SHELL_CALL); +} + +bool PermissionVerification::CheckSpecificSystemAbilityAccessPermission(const std::string &processName) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyRunningInfoPerm() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyControllerPerm() const +{ + return !!(MyFlag::flag_); +} +#ifdef WITH_DLP +bool PermissionVerification::VerifyDlpPermission(Want &want) const +{ + return !!(MyFlag::flag_); +} +#endif // WITH_DLP +int PermissionVerification::VerifyAccountPermission() const +{ + return MyFlag::flag_; +} +bool PermissionVerification::VerifyMissionPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::VerifyAppStateObserverPermission() const +{ + return MyFlag::flag_; +} +int32_t PermissionVerification::VerifyUpdateConfigurationPerm() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::VerifyInstallBundlePermission() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyGetBundleInfoPrivilegedPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckStartByCallPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +unsigned int PermissionVerification::GetCallingTokenID() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartAbilityFromBackground(const bool isBackgroundCall) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +bool PermissionVerification::JudgeCallerIsAllowedToUseSystemAPI() const +{ + return true; +} +bool PermissionVerification::VerifyPrepareTerminatePermission() const +{ + return true; +} +bool PermissionVerification::IsSystemAppCall() const +{ + return true; +} + +bool PermissionVerification::VerifySetProcessCachePermission() const +{ + return true; +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/dialog_session_manager_test/BUILD.gn b/test/unittest/dialog_session_manager_test/BUILD.gn new file mode 100644 index 0000000000..cc4fe5593a --- /dev/null +++ b/test/unittest/dialog_session_manager_test/BUILD.gn @@ -0,0 +1,74 @@ +# Copyright (c) 2024 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. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/abilitymgr" + +ohos_unittest("dialog_session_manager_test") { + module_out_path = module_output_path + + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } + + include_dirs = [ + "${ability_runtime_path}/services/abilitymgr/include/dialog_session", + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + ] + + sources = [ + "${ability_runtime_path}/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp", + "${ability_runtime_path}/services/abilitymgr/src/dialog_session/dialog_session_info.cpp", + "${ability_runtime_path}/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp", + "${ability_runtime_path}/services/abilitymgr/src/start_ability_utils.cpp", + "dialog_session_manager_test.cpp", + ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + + deps = [ + "${ability_base_path}:base", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "//third_party/googletest:gmock_main", + ] + + external_deps = [ + "ability_base:want", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "ffrt:libffrt", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", + "ipc:ipc_core", + "jsoncpp:jsoncpp", + "samgr:samgr_proxy", + "window_manager:libmodal_system_ui_extension_client", + ] +} + +group("unittest") { + testonly = true + + deps = [ ":dialog_session_manager_test" ] +} diff --git a/test/unittest/dialog_session_manager_test/dialog_session_manager_test.cpp b/test/unittest/dialog_session_manager_test/dialog_session_manager_test.cpp new file mode 100644 index 0000000000..2dec4d9e38 --- /dev/null +++ b/test/unittest/dialog_session_manager_test/dialog_session_manager_test.cpp @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2024 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 "gtest/gtest.h" + +#define private public +#include "dialog_session_manager.h" +#undef private +#include "hilog_tag_wrapper.h" +#include "mock_ability_token.h" +#include "start_ability_utils.h" + +using OHOS::AppExecFwk::AbilityType; +using namespace testing::ext; + +namespace OHOS { +namespace AAFwk { +namespace { +constexpr int32_t TEST_USER_ID = 10001; +constexpr int32_t TEST_ERMS_ISALLOW_RESULTCODE = 9; +const std::string TEST_BUNDLE_NAME = "com.test.demo"; +const std::string TEST_DIALOG_SESSION_ID = "dialogSessionId"; +} + +class DialogSessionManagerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + std::shared_ptr MockAbilityRecord(AbilityType); + sptr MockToken(AbilityType); +}; + +void DialogSessionManagerTest::SetUpTestCase(void) +{} + +void DialogSessionManagerTest::TearDownTestCase(void) +{} + +void DialogSessionManagerTest::SetUp() +{} + +void DialogSessionManagerTest::TearDown() +{} + +std::shared_ptr DialogSessionManagerTest::MockAbilityRecord(AbilityType abilityType) +{ + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = TEST_BUNDLE_NAME; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = abilityType; + return AbilityRecord::CreateAbilityRecord(abilityRequest); +} + +sptr DialogSessionManagerTest::MockToken(AbilityType abilityType) +{ + std::shared_ptr abilityRecord = MockAbilityRecord(abilityType); + if (!abilityRecord) { + return nullptr; + } + return abilityRecord->GetToken(); +} + +/** + * @tc.name: GetStartupSessionInfoTest_0100 + * @tc.desc: Test GetStartupSessionInfo + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, GetStartupSessionInfoTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "GetStartupSessionInfoTest_0100 start"; + DialogSessionManager dialogSessionManager; + std::shared_ptr ret = dialogSessionManager.GetStartupSessionInfo(TEST_DIALOG_SESSION_ID); + EXPECT_EQ(ret, nullptr); + + AbilityRequest abilityRequest; + dialogSessionManager.SetStartupSessionInfo(TEST_DIALOG_SESSION_ID, abilityRequest); + ret = dialogSessionManager.GetStartupSessionInfo(TEST_DIALOG_SESSION_ID); + EXPECT_NE(ret, nullptr); + GTEST_LOG_(INFO) << "GetStartupSessionInfoTest_0100 end"; +} + +/** + * @tc.name: SendDialogResultTest_0100 + * @tc.desc: Test SendDialogResult + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, SendDialogResultTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SendDialogResultTest_0100 start"; + AbilityRequest abilityRequest; + DialogSessionManager dialogSessionManager; + Want want; + bool isAllowed = false; + int32_t ret = dialogSessionManager.SendDialogResult(want, TEST_DIALOG_SESSION_ID, isAllowed); + EXPECT_EQ(ret, ERR_OK); + + isAllowed = true; + ret = dialogSessionManager.SendDialogResult(want, TEST_DIALOG_SESSION_ID, isAllowed); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + dialogSessionManager.SetStartupSessionInfo(TEST_DIALOG_SESSION_ID, abilityRequest); + ret = dialogSessionManager.SendDialogResult(want, TEST_DIALOG_SESSION_ID, isAllowed); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + GTEST_LOG_(INFO) << "SendDialogResultTest_0100 end"; +} + +/** + * @tc.name: SendDialogResultTest_0200 + * @tc.desc: Test SendDialogResult + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, SendDialogResultTest_0200, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SendDialogResultTest_0200 start"; + AbilityRequest abilityRequest; + DialogSessionManager dialogSessionManager; + Want want; + bool isAllowed = true; + sptr dilogSessionInfo = nullptr; + std::shared_ptr dialogCallerInfo = std::make_shared(); + + dialogSessionManager.SetDialogSessionInfo(TEST_DIALOG_SESSION_ID, dilogSessionInfo, dialogCallerInfo); + int32_t ret = dialogSessionManager.SendDialogResult(want, TEST_DIALOG_SESSION_ID, isAllowed); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + want.SetParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0); + ret = dialogSessionManager.SendDialogResult(want, TEST_DIALOG_SESSION_ID, isAllowed); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + GTEST_LOG_(INFO) << "SendDialogResultTest_0200 end"; +} + +/** + * @tc.name: NotifySCBToRecoveryAfterInterceptionTest_0100 + * @tc.desc: Test NotifySCBToRecoveryAfterInterception + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, NotifySCBToRecoveryAfterInterceptionTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "NotifySCBToRecoveryAfterInterceptionTest_0100 start"; + AbilityRequest abilityRequest; + DialogSessionManager dialogSessionManager; + + int32_t ret = dialogSessionManager.NotifySCBToRecoveryAfterInterception(TEST_DIALOG_SESSION_ID, abilityRequest); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + GTEST_LOG_(INFO) << "NotifySCBToRecoveryAfterInterceptionTest_0100 end"; +} + +/** + * @tc.name: CreateJumpModalDialogTest_0100 + * @tc.desc: Test CreateJumpModalDialog + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, CreateJumpModalDialogTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CreateJumpModalDialogTest_0100 start"; + AbilityRequest abilityRequest; + Want replaceWant; + DialogSessionManager dialogSessionManager; + + int32_t ret = dialogSessionManager.CreateJumpModalDialog(abilityRequest, TEST_USER_ID, replaceWant); + EXPECT_EQ(ret, INNER_ERR); + GTEST_LOG_(INFO) << "CreateJumpModalDialogTest_0100 end"; +} + +/** + * @tc.name: CreateCloneSelectorModalDialogTest_0100 + * @tc.desc: Test CreateCloneSelectorModalDialog + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, CreateCloneSelectorModalDialogTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CreateCloneSelectorModalDialogTest_0100 start"; + AbilityRequest abilityRequest; + std::string replaceWant = "replaceWant"; + Want want; + std::vector dialogAppInfos; + DialogSessionManager dialogSessionManager; + + int32_t ret = dialogSessionManager.CreateCloneSelectorModalDialog(abilityRequest, + want, TEST_USER_ID, dialogAppInfos, replaceWant); + EXPECT_EQ(ret, INNER_ERR); + + replaceWant = ""; + ret = dialogSessionManager.CreateCloneSelectorModalDialog(abilityRequest, + want, TEST_USER_ID, dialogAppInfos, replaceWant); + EXPECT_EQ(ret, INNER_ERR); + GTEST_LOG_(INFO) << "CreateCloneSelectorModalDialogTest_0100 end"; +} + +/** + * @tc.name: CreateModalDialogCommonTest_0100 + * @tc.desc: Test CreateModalDialogCommon + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, CreateModalDialogCommonTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CreateModalDialogCommonTest_0100 start"; + Want replaceWant; + sptr callerToken = MockToken(AbilityType::PAGE); + DialogSessionManager dialogSessionManager; + + int32_t ret = dialogSessionManager.CreateModalDialogCommon(replaceWant, callerToken, TEST_DIALOG_SESSION_ID); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + GTEST_LOG_(INFO) << "CreateModalDialogCommonTest_0100 end"; +} + +/** + * @tc.name: HandleErmsResultTest_0100 + * @tc.desc: Test HandleErmsResult + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, HandleErmsResultTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "HandleErmsResultTest_0100 start"; + AbilityRequest abilityRequest; + Want replaceWant; + DialogSessionManager dialogSessionManager; + + int32_t ret = dialogSessionManager.HandleErmsResult(abilityRequest, TEST_USER_ID, replaceWant); + EXPECT_EQ(ret, INNER_ERR); + + StartAbilityUtils::ermsResultCode = TEST_ERMS_ISALLOW_RESULTCODE; + ret = dialogSessionManager.HandleErmsResult(abilityRequest, TEST_USER_ID, replaceWant); + EXPECT_EQ(ret, INNER_ERR); + GTEST_LOG_(INFO) << "HandleErmsResultTest_0100 end"; +} + +/** + * @tc.name: HandleErmsResultBySCBTest_0100 + * @tc.desc: Test HandleErmsResultBySCB + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, HandleErmsResultBySCBTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "HandleErmsResultBySCBTest_0100 start"; + AbilityRequest abilityRequest; + Want replaceWant; + DialogSessionManager dialogSessionManager; + + int32_t ret = dialogSessionManager.HandleErmsResultBySCB(abilityRequest, replaceWant); + EXPECT_EQ(ret, INNER_ERR); + GTEST_LOG_(INFO) << "HandleErmsResultBySCBTest_0100 end"; +} + +/** + * @tc.name: IsCreateCloneSelectorDialogTest_0100 + * @tc.desc: Test IsCreateCloneSelectorDialog + * @tc.type: FUNC + */ +HWTEST_F(DialogSessionManagerTest, IsCreateCloneSelectorDialogTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "IsCreateCloneSelectorDialogTest_0100 start"; + DialogSessionManager dialogSessionManager; + + StartAbilityUtils::isWantWithAppCloneIndex = true; + bool ret = dialogSessionManager.IsCreateCloneSelectorDialog(TEST_BUNDLE_NAME, TEST_USER_ID); + EXPECT_FALSE(ret); + GTEST_LOG_(INFO) << "IsCreateCloneSelectorDialogTest_0100 end"; +} +} // namespace AAFwk +} // namespace OHOS From f153b49ab9835fcb4670dd163e404f2ba0abb453 Mon Sep 17 00:00:00 2001 From: zhangyafei-echo Date: Mon, 23 Sep 2024 10:12:10 +0800 Subject: [PATCH 18/26] independent compilation Signed-off-by: zhangyafei-echo Change-Id: Id0a141f8c88a8c62991607a53c535dc896acccf2 --- bundle.json | 8 ++ frameworks/native/ability/native/BUILD.gn | 70 +++++++++++++- .../ability/native/ability_local_record.cpp | 35 ++----- .../native/extension_ability_thread.cpp | 2 - .../ability/native/fa_ability_thread.cpp | 8 -- .../ability/native/ui_ability_thread.cpp | 4 - frameworks/native/appkit/BUILD.gn | 1 + .../native/appkit/app/ability_record_mgr.cpp | 26 ----- frameworks/native/appkit/app/main_thread.cpp | 4 +- .../ability/native/ability_local_record.h | 58 ++---------- .../native/ability/native/ability_thread.h | 1 + .../native/appkit/app/ability_record_mgr.h | 8 -- .../mock_ability_thread_for_data_observer.h | 2 +- .../ability_test/ability_context_test.cpp | 26 ++--- test/moduletest/ability_test/ability_test.cpp | 81 ++++++---------- .../ability_extension_base_test.cpp | 15 +-- .../ability_extension_context_test.cpp | 9 +- .../ability_extension_test.cpp | 27 ++---- .../ability_record_mgr_test.cpp | 33 +------ .../ability_service_extension_test/BUILD.gn | 1 + .../ability_service_extension_test.cpp | 4 +- .../main_thread_test/main_thread_test.cpp | 12 +-- .../ohos_application_test.cpp | 18 ++-- .../cj_ability_stage_object_test/BUILD.gn | 1 + test/unittest/cj_ability_stage_test/BUILD.gn | 1 + test/unittest/cj_ui_ability_test/BUILD.gn | 1 + .../cj_ui_ability_test/cj_ui_ability_test.cpp | 42 ++++----- .../BUILD.gn | 16 ++++ .../ability_impl_active_test.cpp | 12 +-- .../ability_impl_test.cpp | 84 ++++++++--------- .../ability_local_record_test.cpp | 39 +------- .../ability_thread_dataability_test.cpp | 15 +-- .../ability_thread_test.cpp | 73 +++++--------- .../action_extension_test.cpp | 2 +- .../auto_fill_extension_test.cpp | 14 +-- ...data_ability_impl_file_secondpart_test.cpp | 6 +- .../data_ability_impl_file_test.cpp | 12 +-- .../data_ability_impl_test.cpp | 94 +++++++++---------- .../embedded_ui_extension_test.cpp | 2 +- .../extension_ability_thread_test.cpp | 40 +++----- .../extension_impl_test.cpp | 30 +++--- .../extension_second_test.cpp | 2 +- .../extension_test.cpp | 6 +- .../fa_ability_thread_test.cpp | 18 ++-- .../form_extension_test.cpp | 4 +- .../new_ability_impl_test.cpp | 4 +- .../page_ability_impl_test.cpp | 52 +++++----- .../service_ability_impl_test.cpp | 8 +- .../share_extension_module_loader_test.cpp | 2 +- .../share_extension_test.cpp | 2 +- .../ui_ability_impl_test.cpp | 52 +++++----- .../ui_ability_test.cpp | 71 +++++++------- .../ui_ability_thread_test.cpp | 42 ++++----- .../BUILD.gn | 6 ++ .../ability_stage_test.cpp | 8 +- .../js_auto_fill_extension_test.cpp | 2 +- .../js_service_extension_test.cpp | 2 +- .../js_ui_service_extension_test.cpp | 3 +- .../photo_editor_extension_test.cpp | 2 +- .../ui_service_extension_test.cpp | 6 +- 60 files changed, 532 insertions(+), 697 deletions(-) diff --git a/bundle.json b/bundle.json index 83769e4673..36eeda5029 100644 --- a/bundle.json +++ b/bundle.json @@ -270,6 +270,14 @@ }, "name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:extensionkit_native" }, + { + "header": { + "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/", + "header_files": [ + ] + }, + "name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:abilitykit_utils" + }, { "header": { "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/", diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index 8d4c4ea535..e6e0d96820 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -137,12 +137,10 @@ ohos_shared_library("abilitykit_utils") { sources = [ "${ability_runtime_native_path}/ability/native/ability_handler.cpp", "${ability_runtime_native_path}/ability/native/ability_local_record.cpp", - "${ability_runtime_native_path}/ability/native/application_configuration_manager.cpp", "${ability_runtime_native_path}/ability/native/configuration_utils.cpp", - "${ability_runtime_native_path}/ability/native/resource_config_helper.cpp", ] - deps = [] + deps = [ ":configuration_helper" ] configs = [ ":abilitykit_utils_exceptions" ] @@ -190,6 +188,68 @@ ohos_shared_library("abilitykit_utils") { part_name = "ability_runtime" } +ohos_shared_library("configuration_helper") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + + branch_protector_ret = "pac_ret" + + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/ability/native", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app", + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_innerkits_path}/wantagent/include", + "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_services_path}/common/include", + ] + + sources = [ + "${ability_runtime_native_path}/ability/native/application_configuration_manager.cpp", + "${ability_runtime_native_path}/ability/native/resource_config_helper.cpp", + ] + + deps = [] + + external_deps = [ + "ability_base:configuration", + "ability_base:want", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "ipc:ipc_napi", + "json:nlohmann_json_static", + "jsoncpp:jsoncpp", + "napi:ace_napi", + "resource_management:global_resmgr", + ] + + if (ability_runtime_graphics) { + external_deps += [ + "ability_base:session_info", + "graphic_2d:color_manager", + "icu:shared_icuuc", + "image_framework:image_native", + "window_manager:libdm", + "window_manager:libwm", + "window_manager:libwmutil", + ] + } + + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("abilitykit_native") { branch_protector_ret = "pac_ret" @@ -241,6 +301,7 @@ ohos_shared_library("abilitykit_native") { ] deps = [ + ":configuration_helper", ":continuation_ipc", ":extension_blocklist_config", ":ui_service_extension_connection", @@ -377,6 +438,7 @@ config("extensionkit_public_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime", "${ability_runtime_path}/interfaces/kits/native/appkit/app", "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_services_path}/common/include", ] if (ability_runtime_graphics) { @@ -412,6 +474,7 @@ ohos_shared_library("extensionkit_native") { public_configs = [ ":extensionkit_public_config" ] deps = [ + ":configuration_helper", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", @@ -546,6 +609,7 @@ ohos_shared_library("uiabilitykit_native") { deps = [ ":abilitykit_native", + ":configuration_helper", ":continuation_ipc", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", diff --git a/frameworks/native/ability/native/ability_local_record.cpp b/frameworks/native/ability/native/ability_local_record.cpp index d6a715ad5e..4787d099be 100644 --- a/frameworks/native/ability/native/ability_local_record.cpp +++ b/frameworks/native/ability/native/ability_local_record.cpp @@ -19,8 +19,9 @@ namespace OHOS { namespace AppExecFwk { -AbilityLocalRecord::AbilityLocalRecord(const std::shared_ptr &info, const sptr &token) - : abilityInfo_(info), token_(token) {} +AbilityLocalRecord::AbilityLocalRecord(const std::shared_ptr &info, const sptr &token, + const std::shared_ptr &want, int32_t abilityRecordId) + : abilityInfo_(info), token_(token), want_(want), abilityRecordId_(abilityRecordId) {} AbilityLocalRecord::~AbilityLocalRecord() {} @@ -29,31 +30,16 @@ const std::shared_ptr &AbilityLocalRecord::GetAbilityInfo() return abilityInfo_; } -const std::shared_ptr &AbilityLocalRecord::GetEventHandler() -{ - return handler_; -} - -void AbilityLocalRecord::SetEventHandler(const std::shared_ptr &handler) -{ - handler_ = handler; -} - -const std::shared_ptr &AbilityLocalRecord::GetEventRunner() -{ - return runner_; -} - -void AbilityLocalRecord::SetEventRunner(const std::shared_ptr &runner) -{ - runner_ = runner; -} - const sptr &AbilityLocalRecord::GetToken() { return token_; } +int32_t AbilityLocalRecord::GetAbilityRecordId() const +{ + return abilityRecordId_; +} + const sptr &AbilityLocalRecord::GetAbilityThread() { return abilityThread_; @@ -64,11 +50,6 @@ void AbilityLocalRecord::SetAbilityThread(const sptr &abilityThre abilityThread_ = abilityThread; } -void AbilityLocalRecord::SetWant(const std::shared_ptr &want) -{ - want_ = want; -} - const std::shared_ptr &AbilityLocalRecord::GetWant() { return want_; diff --git a/frameworks/native/ability/native/extension_ability_thread.cpp b/frameworks/native/ability/native/extension_ability_thread.cpp index 9c39ae4a7b..5f79ff22b9 100644 --- a/frameworks/native/ability/native/extension_ability_thread.cpp +++ b/frameworks/native/ability/native/extension_ability_thread.cpp @@ -239,8 +239,6 @@ void ExtensionAbilityThread::HandleAttach(const std::shared_ptrGetToken(); - abilityRecord->SetEventHandler(abilityHandler_); - mainRunner == nullptr ? abilityRecord->SetEventRunner(runner_) : abilityRecord->SetEventRunner(mainRunner); abilityRecord->SetAbilityThread(this); HandleAttachInner(application, abilityRecord); } diff --git a/frameworks/native/ability/native/fa_ability_thread.cpp b/frameworks/native/ability/native/fa_ability_thread.cpp index eb9e652f43..6826f0fe4b 100644 --- a/frameworks/native/ability/native/fa_ability_thread.cpp +++ b/frameworks/native/ability/native/fa_ability_thread.cpp @@ -285,8 +285,6 @@ void FAAbilityThread::Attach(const std::shared_ptr } currentAbility_.reset(ability); token_ = abilityRecord->GetToken(); - abilityRecord->SetEventHandler(abilityHandler_); - abilityRecord->SetEventRunner(mainRunner); abilityRecord->SetAbilityThread(this); std::shared_ptr abilityObject = currentAbility_; std::shared_ptr contextDeal = @@ -357,8 +355,6 @@ void FAAbilityThread::AttachExtension(const std::shared_ptrGetToken(); - abilityRecord->SetEventHandler(abilityHandler_); - abilityRecord->SetEventRunner(mainRunner); abilityRecord->SetAbilityThread(this); extensionImpl_ = std::make_shared(); if (extensionImpl_ == nullptr) { @@ -406,8 +402,6 @@ void FAAbilityThread::AttachExtension(const std::shared_ptrGetToken(); - abilityRecord->SetEventHandler(abilityHandler_); - abilityRecord->SetEventRunner(runner_); abilityRecord->SetAbilityThread(this); extensionImpl_ = std::make_shared(); if (extensionImpl_ == nullptr) { @@ -461,8 +455,6 @@ void FAAbilityThread::Attach(const std::shared_ptr } currentAbility_.reset(ability); token_ = abilityRecord->GetToken(); - abilityRecord->SetEventHandler(abilityHandler_); - abilityRecord->SetEventRunner(runner_); abilityRecord->SetAbilityThread(this); std::shared_ptr abilityObject = currentAbility_; std::shared_ptr contextDeal = diff --git a/frameworks/native/ability/native/ui_ability_thread.cpp b/frameworks/native/ability/native/ui_ability_thread.cpp index 05d9d8bdd2..fce44588f6 100644 --- a/frameworks/native/ability/native/ui_ability_thread.cpp +++ b/frameworks/native/ability/native/ui_ability_thread.cpp @@ -140,8 +140,6 @@ void UIAbilityThread::Attach(const std::shared_ptr ability->SetAbilityRecordId(abilityRecord->GetAbilityRecordId()); currentAbility_.reset(ability); token_ = abilityRecord->GetToken(); - abilityRecord->SetEventHandler(abilityHandler_); - abilityRecord->SetEventRunner(mainRunner); abilityRecord->SetAbilityThread(this); std::shared_ptr abilityObject = currentAbility_; std::shared_ptr contextDeal = @@ -213,8 +211,6 @@ void UIAbilityThread::Attach(const std::shared_ptr ability->SetAbilityRecordId(abilityRecord->GetAbilityRecordId()); currentAbility_.reset(ability); token_ = abilityRecord->GetToken(); - abilityRecord->SetEventHandler(abilityHandler_); - abilityRecord->SetEventRunner(runner_); abilityRecord->SetAbilityThread(this); std::shared_ptr abilityObject = currentAbility_; std::shared_ptr contextDeal = diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index fe9d6575e7..f27a4a7939 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -159,6 +159,7 @@ ohos_shared_library("appkit_native") { "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:app_context_utils", diff --git a/frameworks/native/appkit/app/ability_record_mgr.cpp b/frameworks/native/appkit/app/ability_record_mgr.cpp index 24ed12757c..fd4d7867a5 100644 --- a/frameworks/native/appkit/app/ability_record_mgr.cpp +++ b/frameworks/native/appkit/app/ability_record_mgr.cpp @@ -41,32 +41,6 @@ void AbilityRecordMgr::SetToken(const sptr &token) tokens_ = token; } -/** - * @brief Set the eventRunner of abilitythread to the AbilityRecordMgr. - * - * @param eventRunner The runner of the abilitythread. - * - */ -void AbilityRecordMgr::SetEventRunner(const std::shared_ptr &eventRunner) -{ - if (eventRunner == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "eventRunner is nullptr"); - return; - } - sptr token = GetToken(); - if (token == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "token is nullptr"); - return; - } - - std::shared_ptr abilityInstance = GetAbilityItem(token); - if (abilityInstance != nullptr) { - abilityInstance->SetEventRunner(eventRunner); - } else { - TAG_LOGW(AAFwkTag::APPKIT, "ability record not exist"); - } -} - /** * @brief Save the token and abilityRecord to the AbilityRecordMgr. * diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 46531f9bd1..2d798ccc51 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -706,9 +706,7 @@ void MainThread::ScheduleLaunchAbility(const AbilityInfo &info, const sptr abilityInfo = std::make_shared(info); - auto abilityRecord = std::make_shared(abilityInfo, token); - abilityRecord->SetWant(want); - abilityRecord->SetAbilityRecordId(abilityRecordId); + auto abilityRecord = std::make_shared(abilityInfo, token, want, abilityRecordId); auto tmpWatchdog = watchdog_; if (tmpWatchdog != nullptr) { tmpWatchdog->SetBgWorkingThreadStatus(IsBgWorkingThread(info)); diff --git a/interfaces/kits/native/ability/native/ability_local_record.h b/interfaces/kits/native/ability/native/ability_local_record.h index 0689b7c430..e9af2de92a 100644 --- a/interfaces/kits/native/ability/native/ability_local_record.h +++ b/interfaces/kits/native/ability/native/ability_local_record.h @@ -19,16 +19,13 @@ #include #include "iremote_object.h" -#include "event_runner.h" #include "ability_info.h" -#include "application_info.h" #include "refbase.h" #include "want.h" namespace OHOS { namespace AppExecFwk { class AbilityThread; -class AbilityImpl; class AbilityLocalRecord { public: /** @@ -36,7 +33,8 @@ public: * default constructor * */ - AbilityLocalRecord(const std::shared_ptr &info, const sptr &token); + AbilityLocalRecord(const std::shared_ptr &info, const sptr &token, + const std::shared_ptr &want, int32_t abilityRecordId); /** * @@ -52,48 +50,13 @@ public: */ const std::shared_ptr &GetAbilityInfo(); - /** - * @description: Get an EventHandler in an ability. - * - * @return Returns a pointer to EventHandler - */ - const std::shared_ptr &GetEventHandler(); - - /** - * @description: Set an EventHandler in an ability. - * @param handler EventHandler object - * @return None. - */ - void SetEventHandler(const std::shared_ptr &handler); - - /** - * @description: Get an EventRunner in an ability. - * - * @return Returns a pointer to EventRunner - */ - const std::shared_ptr &GetEventRunner(); - - /** - * @description: Set an EventRunner in an ability. - * @param runner EventHandler object - * @return None. - */ - void SetEventRunner(const std::shared_ptr &runner); - /** * @description: Gets the identity of the ability * @return return the identity of the ability. */ const sptr &GetToken(); - int32_t GetAbilityRecordId() const - { - return abilityRecordId_; - } - void SetAbilityRecordId(int32_t abilityRecordId) - { - abilityRecordId_ = abilityRecordId; - } + int32_t GetAbilityRecordId() const; /** * @description: Obtains the information based on ability thread. @@ -113,14 +76,11 @@ public: const std::shared_ptr &GetWant(); private: std::shared_ptr abilityInfo_ = nullptr; - sptr token_; - int32_t abilityRecordId_ = 0; - std::shared_ptr runner_ = nullptr; - std::shared_ptr handler_ = nullptr; - std::shared_ptr abilityImpl_ = nullptr; // store abilityImpl - sptr abilityThread_; + sptr token_ = nullptr; std::shared_ptr want_ = nullptr; + int32_t abilityRecordId_ = 0; + sptr abilityThread_; }; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ABILITY_LOCAL_RECORD_H +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_ABILITY_LOCAL_RECORD_H diff --git a/interfaces/kits/native/ability/native/ability_thread.h b/interfaces/kits/native/ability/native/ability_thread.h index b1c5f293be..3ad1873200 100644 --- a/interfaces/kits/native/ability/native/ability_thread.h +++ b/interfaces/kits/native/ability/native/ability_thread.h @@ -18,6 +18,7 @@ #include "ability_scheduler_stub.h" #include "context.h" +#include "event_runner.h" #include "ohos_application.h" namespace OHOS { diff --git a/interfaces/kits/native/appkit/app/ability_record_mgr.h b/interfaces/kits/native/appkit/app/ability_record_mgr.h index 14e9f575e2..99fc3d1cc2 100644 --- a/interfaces/kits/native/appkit/app/ability_record_mgr.h +++ b/interfaces/kits/native/appkit/app/ability_record_mgr.h @@ -28,14 +28,6 @@ public: AbilityRecordMgr() = default; ~AbilityRecordMgr() = default; - /** - * @brief Set the eventRunner of abilitythread to the AbilityRecordMgr. - * - * @param eventRunner The runner of the abilitythread. - * - */ - void SetEventRunner(const std::shared_ptr &eventRunner); - /** * @brief Get the token witch is set to the AbilityRecordMgr. * diff --git a/test/mock/frameworks_kits_test/DemoObServer/mock_ability_thread_for_data_observer.h b/test/mock/frameworks_kits_test/DemoObServer/mock_ability_thread_for_data_observer.h index 73c54cbabf..2ee30e7515 100644 --- a/test/mock/frameworks_kits_test/DemoObServer/mock_ability_thread_for_data_observer.h +++ b/test/mock/frameworks_kits_test/DemoObServer/mock_ability_thread_for_data_observer.h @@ -55,7 +55,7 @@ sptr MockCreateAbilityThread() sptr token = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(info->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); diff --git a/test/moduletest/ability_test/ability_context_test.cpp b/test/moduletest/ability_test/ability_context_test.cpp index a195cedd4c..f687eed373 100644 --- a/test/moduletest/ability_test/ability_context_test.cpp +++ b/test/moduletest/ability_test/ability_context_test.cpp @@ -89,7 +89,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_ConnectAbility_0100, Function std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -115,7 +115,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_DisconnectAbility_0100, Funct std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -142,7 +142,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_StartAbility_0100, Function | std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); Want want; @@ -163,7 +163,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_TerminateAbility_0100, Functi std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); Want want; @@ -190,7 +190,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_TerminateAbility_0200, Functi std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -214,7 +214,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_StopService_0100, Function | std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -243,7 +243,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_StopService_0200, Function | std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); std::shared_ptr deal = std::make_shared(); @@ -331,7 +331,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_ConnectAbility_0300, Function std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::DATA; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); std::shared_ptr deal = std::make_shared(); deal->SetAbilityInfo(abilityInfo); @@ -353,7 +353,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_StopService_0300, Function | std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::DATA; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); std::shared_ptr deal = std::make_shared(); @@ -555,7 +555,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetAbilityInfoType_0200, Func std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); std::shared_ptr deal = std::make_shared(); @@ -602,7 +602,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_GetResourceManager_0200, Func std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); std::shared_ptr deal = std::make_shared(); deal->SetAbilityInfo(abilityInfo); @@ -651,7 +651,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_VerifyPermission_0300, Functi std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::SERVICE; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); std::shared_ptr deal = std::make_shared(); deal->SetAbilityInfo(abilityInfo); @@ -896,7 +896,7 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_Context_SetColorMode_0100, Function | std::shared_ptr application = std::make_shared(); sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); std::shared_ptr deal = std::make_shared(); deal->SetAbilityInfo(abilityInfo); diff --git a/test/moduletest/ability_test/ability_test.cpp b/test/moduletest/ability_test/ability_test.cpp index 5ff98d231e..621773963e 100644 --- a/test/moduletest/ability_test/ability_test.cpp +++ b/test/moduletest/ability_test/ability_test.cpp @@ -93,8 +93,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Start_Test_0100, Function | M abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); usleep(AbilityBaseTest::TEST_WAIT_TIME); @@ -117,8 +116,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Start_Test_0200, Function | M abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); usleep(AbilityBaseTest::TEST_WAIT_TIME); @@ -154,8 +152,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Start_Test_0400, Function | M if (abilityToken != nullptr) { std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::PAGE; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); usleep(AbilityBaseTest::TEST_WAIT_TIME); @@ -177,8 +174,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Start_Test_0500, Function | M std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); usleep(AbilityBaseTest::TEST_WAIT_TIME); @@ -218,8 +214,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Start_Test_0600, Function | M abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -252,8 +247,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_Lifecycle_Test_0100, Function | MediumTe abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -283,8 +277,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Lifecycle_Test_0200, Function abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -315,8 +308,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Lifecycle_Test_0300, Function abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -350,8 +342,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Lifecycle_Test_0400, Function abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -384,8 +375,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Lifecycle_Test_0500, Function abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -420,8 +410,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_AbilityFwk_Lifecycle_Test_0600, Function abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -457,8 +446,7 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_TerminateAbility_ForResult_Test_0100, Fu abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -527,8 +515,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0100, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_001 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -564,8 +551,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0200, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_002 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -601,8 +587,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0300, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_0300 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -638,8 +623,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0400, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_0400 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -675,8 +659,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0500, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_005 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -707,8 +690,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0600, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_006 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -739,8 +721,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0700, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_007 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -771,8 +752,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_Ability_Terminate_test_0800, Function | Med abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_Ability_Terminate_test_008 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -803,8 +783,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_WMS_window_test_0100, Function | MediumTest abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_WMS_window_test_001 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -836,8 +815,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_WMS_window_test_0200, Function | MediumTest abilityInfo->type = AppExecFwk::AbilityType::PAGE; abilityInfo->name = ABILITY_NAME; abilityInfo->isNativeAbility = true; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); GTEST_LOG_(INFO) << "AaFwk_WMS_window_test_002 AbilityThreadMain"; AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -873,8 +851,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_DataAbility_Launch_0100, Function | MediumT std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::DATA; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -906,8 +883,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_DataAbility_Start_0100, Function | MediumTe std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::DATA; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -939,8 +915,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_DataAbility_Start_0200, Function | MediumTe std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::DATA; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -972,8 +947,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_DataAbility_Start_0300, Function | MediumTe std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::DATA; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); @@ -1005,8 +979,7 @@ HWTEST_F(AbilityTerminateTest, AaFwk_DataAbility_Start_0400, Function | MediumTe std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->type = AppExecFwk::AbilityType::DATA; abilityInfo->name = "DemoAbility"; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); AbilityThread::AbilityThreadMain(application, abilityRecord, nullptr); diff --git a/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp b/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp index db15e3be09..d2a7d45dfb 100644 --- a/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp +++ b/test/unittest/ability_extension_base_test/ability_extension_base_test.cpp @@ -96,8 +96,7 @@ HWTEST_F(AbilityExtensionBaseTest, CreateAndInitContext_0100, TestSize.Level1) std::shared_ptr info = std::make_shared(); info->name = "ExtensionBaseTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -127,8 +126,7 @@ HWTEST_F(AbilityExtensionBaseTest, GetContext_0100, TestSize.Level1) std::shared_ptr info = std::make_shared(); info->name = "ExtensionBaseTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -157,8 +155,7 @@ HWTEST_F(AbilityExtensionBaseTest, OnConfigurationUpdated_0100, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "OnConfigurationUpdated start"); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -190,8 +187,7 @@ HWTEST_F(AbilityExtensionBaseTest, OnMemoryLevel_0100, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "OnMemoryLevel start"); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -222,8 +218,7 @@ HWTEST_F(AbilityExtensionBaseTest, SetExtensionCommon_0100, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "SetExtensionCommon start"); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); diff --git a/test/unittest/ability_extension_context_test/ability_extension_context_test.cpp b/test/unittest/ability_extension_context_test/ability_extension_context_test.cpp index 610ef4f108..8e9acd67dc 100644 --- a/test/unittest/ability_extension_context_test/ability_extension_context_test.cpp +++ b/test/unittest/ability_extension_context_test/ability_extension_context_test.cpp @@ -65,8 +65,7 @@ HWTEST_F(AbilityExtensionContextTest, GetAbilityInfo_0100, TestSize.Level1) std::shared_ptr info = std::make_shared(); info->name = "ExtensionContextTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -98,8 +97,7 @@ HWTEST_F(AbilityExtensionContextTest, SetAbilityInfo_0100, TestSize.Level1) std::shared_ptr info = std::make_shared(); info->name = "ExtensionContextTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -137,8 +135,7 @@ HWTEST_F(AbilityExtensionContextTest, SetAbilityInfo_0200, TestSize.Level1) std::shared_ptr info = std::make_shared(); info->name = "ExtensionContextTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); diff --git a/test/unittest/ability_extension_test/ability_extension_test.cpp b/test/unittest/ability_extension_test/ability_extension_test.cpp index 7da1035311..b4495d4f01 100644 --- a/test/unittest/ability_extension_test/ability_extension_test.cpp +++ b/test/unittest/ability_extension_test/ability_extension_test.cpp @@ -182,8 +182,7 @@ HWTEST_F(AbilityExtensionTest, Init_0200, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "Init start"); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = nullptr; std::shared_ptr handler = std::make_shared(nullptr); sptr token = nullptr; @@ -206,8 +205,7 @@ HWTEST_F(AbilityExtensionTest, Init_0300, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "Init start"); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = nullptr; sptr token = nullptr; @@ -230,8 +228,7 @@ HWTEST_F(AbilityExtensionTest, Init_0400, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "Init start"); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = nullptr; @@ -254,8 +251,7 @@ HWTEST_F(AbilityExtensionTest, Init_0500, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "Init start"); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -280,8 +276,7 @@ HWTEST_F(AbilityExtensionTest, OnStart_0100, TestSize.Level1) Extension extension; // Init extension std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -319,8 +314,7 @@ HWTEST_F(AbilityExtensionTest, OnStop_0100, TestSize.Level1) Extension extension; // Init extension std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -346,8 +340,7 @@ HWTEST_F(AbilityExtensionTest, OnConnect_0100, TestSize.Level1) Extension extension; // Init extension std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -385,8 +378,7 @@ HWTEST_F(AbilityExtensionTest, OnDisconnect_0100, TestSize.Level1) Extension extension; // Init extension std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -424,8 +416,7 @@ HWTEST_F(AbilityExtensionTest, OnDisconnect_0200, TestSize.Level1) Extension extension; // Init extension std::shared_ptr info = std::make_shared(); - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); diff --git a/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp b/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp index a6730d6206..dff5fb363a 100644 --- a/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp +++ b/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp @@ -97,29 +97,6 @@ HWTEST_F(AbilityRecordMgrTest, SetToken_0100, TestSize.Level0) GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetToken_0100 end"; } -/** - * @tc.number: SetEventRunner_0100 - * @tc.name: SetEventRunner - * @tc.desc: SetEventRunner Test, return is not nullptr. - */ -HWTEST_F(AbilityRecordMgrTest, SetEventRunner_0100, TestSize.Level0) -{ - GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetEventRunner_0100 start"; - auto recordMgr = std::make_shared(); - EXPECT_NE(recordMgr, nullptr); - recordMgr->SetEventRunner(nullptr); - - std::shared_ptr runner = EventRunner::GetMainEventRunner(); - EXPECT_NE(runner, nullptr); - recordMgr->tokens_ = nullptr; - recordMgr->SetEventRunner(runner); - - sptr token = new (std::nothrow) AbilityMgrToken(); - recordMgr->SetToken(token); - recordMgr->SetEventRunner(runner); - GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetEventRunner_0100 end"; -} - /** * @tc.number: AddAbilityRecord_0100 * @tc.name: AddAbilityRecord @@ -136,7 +113,7 @@ HWTEST_F(AbilityRecordMgrTest, AddAbilityRecord_0100, TestSize.Level0) token = new (std::nothrow) AbilityMgrToken(); recordMgr->AddAbilityRecord(token, nullptr); - auto abilityRecord = std::make_shared(nullptr, nullptr); + auto abilityRecord = std::make_shared(nullptr, nullptr, nullptr, 0); EXPECT_NE(abilityRecord, nullptr); recordMgr->AddAbilityRecord(token, abilityRecord); @@ -158,7 +135,7 @@ HWTEST_F(AbilityRecordMgrTest, RemoveAbilityRecord_0100, TestSize.Level0) recordMgr->RemoveAbilityRecord(token); token = new (std::nothrow) AbilityMgrToken(); - auto abilityRecord = std::make_shared(nullptr, nullptr); + auto abilityRecord = std::make_shared(nullptr, nullptr, nullptr, 0); recordMgr->AddAbilityRecord(token, abilityRecord); EXPECT_EQ(recordMgr->abilityRecords_.size(), 1); @@ -179,7 +156,7 @@ HWTEST_F(AbilityRecordMgrTest, GetRecordCount_0100, TestSize.Level0) EXPECT_EQ(recordMgr->GetRecordCount(), 0); sptr token = new (std::nothrow) AbilityMgrToken(); - auto abilityRecord = std::make_shared(nullptr, nullptr); + auto abilityRecord = std::make_shared(nullptr, nullptr, nullptr, 0); recordMgr->AddAbilityRecord(token, abilityRecord); EXPECT_EQ(recordMgr->GetRecordCount(), 1); GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetRecordCount_0100 end"; @@ -198,7 +175,7 @@ HWTEST_F(AbilityRecordMgrTest, GetAbilityItem_0100, TestSize.Level0) EXPECT_EQ(recordMgr->GetAbilityItem(token), nullptr); token = new (std::nothrow) AbilityMgrToken(); - auto abilityRecord = std::make_shared(nullptr, nullptr); + auto abilityRecord = std::make_shared(nullptr, nullptr, nullptr, 0); recordMgr->AddAbilityRecord(token, abilityRecord); EXPECT_NE(recordMgr->GetAbilityItem(token), nullptr); @@ -219,7 +196,7 @@ HWTEST_F(AbilityRecordMgrTest, GetAllTokens_0100, TestSize.Level0) auto recordMgr = std::make_shared(); sptr token = new (std::nothrow) AbilityMgrToken(); - auto abilityRecord = std::make_shared(nullptr, nullptr); + auto abilityRecord = std::make_shared(nullptr, nullptr, nullptr, 0); recordMgr->AddAbilityRecord(token, abilityRecord); EXPECT_EQ(recordMgr->GetAllTokens().size(), 1); diff --git a/test/unittest/ability_service_extension_test/BUILD.gn b/test/unittest/ability_service_extension_test/BUILD.gn index a554bbe461..6e1093bfbd 100644 --- a/test/unittest/ability_service_extension_test/BUILD.gn +++ b/test/unittest/ability_service_extension_test/BUILD.gn @@ -45,6 +45,7 @@ ohos_unittest("ability_service_extension_test") { deps = [ "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:service_extension", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", diff --git a/test/unittest/ability_service_extension_test/ability_service_extension_test.cpp b/test/unittest/ability_service_extension_test/ability_service_extension_test.cpp index c91cf9661b..976756c164 100644 --- a/test/unittest/ability_service_extension_test/ability_service_extension_test.cpp +++ b/test/unittest/ability_service_extension_test/ability_service_extension_test.cpp @@ -82,7 +82,7 @@ HWTEST_F(AbilityServiceExtensionTest, CreateAndInitContext_0100, TestSize.Level1 applicationContext->AttachContextImpl(contextImpl); application->SetApplicationContext(applicationContext); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr handler = std::make_shared(nullptr); ServiceExtension* serviceExtension = ServiceExtension::Create(nullptr); @@ -115,7 +115,7 @@ HWTEST_F(AbilityServiceExtensionTest, Init_0100, TestSize.Level1) applicationContext->AttachContextImpl(contextImpl); application->SetApplicationContext(applicationContext); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr handler = std::make_shared(nullptr); ServiceExtension* serviceExtension = ServiceExtension::Create(nullptr); diff --git a/test/unittest/appkit/main_thread_test/main_thread_test.cpp b/test/unittest/appkit/main_thread_test/main_thread_test.cpp index 0fe86c7ca0..bd49733c8d 100644 --- a/test/unittest/appkit/main_thread_test/main_thread_test.cpp +++ b/test/unittest/appkit/main_thread_test/main_thread_test.cpp @@ -666,7 +666,7 @@ HWTEST_F(MainThreadTest, CheckAbilityItem_0100, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); EXPECT_FALSE(mainThread_->CheckAbilityItem(record)); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } @@ -680,7 +680,7 @@ HWTEST_F(MainThreadTest, CheckAbilityItem_0100, TestSize.Level1) HWTEST_F(MainThreadTest, CheckAbilityItem_0200, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); - std::shared_ptr record = std::make_shared(nullptr, nullptr); + auto record = std::make_shared(nullptr, nullptr, nullptr, 0); EXPECT_FALSE(mainThread_->CheckAbilityItem(record)); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } @@ -991,7 +991,7 @@ HWTEST_F(MainThreadTest, PrepareAbilityDelegator_0400, TestSize.Level1) HWTEST_F(MainThreadTest, HandleLaunchAbility_0100, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); - std::shared_ptr abilityRecord = std::make_shared(nullptr, nullptr); + auto abilityRecord = std::make_shared(nullptr, nullptr, nullptr, 0); ASSERT_NE(abilityRecord, nullptr); mainThread_->HandleLaunchAbility(abilityRecord); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); @@ -1903,11 +1903,11 @@ HWTEST_F(MainThreadTest, HandleLaunchAbility_0200, TestSize.Level1) const std::shared_ptr info1 = nullptr; const sptr token = nullptr; - const std::shared_ptr abilityRecord2 = std::make_shared(info1, token); + const auto abilityRecord2 = std::make_shared(info1, token, nullptr, 0); mainThread_->HandleLaunchAbility(abilityRecord2); const std::shared_ptr info2 = std::make_shared(); - const std::shared_ptr abilityRecord3 = std::make_shared(info2, token); + const auto abilityRecord3 = std::make_shared(info2, token, nullptr, 0); mainThread_->application_ = std::make_shared(); mainThread_->HandleLaunchAbility(abilityRecord3); @@ -1954,7 +1954,7 @@ HWTEST_F(MainThreadTest, HandleCleanAbility_0100, TestSize.Level1) mainThread_->HandleCleanAbility(token); std::shared_ptr info = nullptr; - abilityRecord = std::make_shared(info, token); + abilityRecord = std::make_shared(info, token, nullptr, 0); mainThread_->abilityRecordMgr_->AddAbilityRecord(token, abilityRecord); mainThread_->HandleCleanAbility(token); diff --git a/test/unittest/appkit/ohos_application_test/ohos_application_test.cpp b/test/unittest/appkit/ohos_application_test/ohos_application_test.cpp index 4d1fb6bca2..57f07e54d8 100644 --- a/test/unittest/appkit/ohos_application_test/ohos_application_test.cpp +++ b/test/unittest/appkit/ohos_application_test/ohos_application_test.cpp @@ -129,7 +129,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_DumpApplication_010 ohosApplication_->abilityRecordMgr_ = std::make_shared(); sptr token = new (std::nothrow) Notification::MockIRemoteObject(); std::shared_ptr info = nullptr; - std::shared_ptr record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); ohosApplication_->abilityRecordMgr_->abilityRecords_.emplace(token, record); ohosApplication_->DumpApplication(); EXPECT_TRUE(record != nullptr); @@ -147,7 +147,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_DumpApplication_020 ohosApplication_->abilityRecordMgr_ = std::make_shared(); sptr token = new (std::nothrow) Notification::MockIRemoteObject(); std::shared_ptr info = std::make_shared(); - std::shared_ptr record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); info->permissions.push_back(std::string("abc")); ohosApplication_->abilityRecordMgr_->abilityRecords_.emplace(token, record); ohosApplication_->DumpApplication(); @@ -291,7 +291,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_OnConfigurationUpda ohosApplication_->configuration_ = std::make_shared(); sptr token = new (std::nothrow) Notification::MockIRemoteObject(); std::shared_ptr info = nullptr; - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); ohosApplication_->abilityRecordMgr_->abilityRecords_.emplace(token, abilityRecord); sptr abilityThread = new (std::nothrow) AbilityRuntime::FAAbilityThread(); abilityRecord->SetAbilityThread(abilityThread); @@ -371,7 +371,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_OnMemoryLevel_0100, ohosApplication_->abilityRecordMgr_ = std::make_shared(); std::shared_ptr info = nullptr; sptr token = new (std::nothrow) Notification::MockIRemoteObject(); - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); EXPECT_TRUE(abilityRecord != nullptr); ohosApplication_->abilityRecordMgr_->abilityRecords_.emplace(token, abilityRecord); sptr abilityThread = new (std::nothrow) AbilityRuntime::FAAbilityThread(); @@ -450,7 +450,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_AddAbilityStage_030 GTEST_LOG_(INFO) << "AppExecFwk_OHOSApplicationTest_AddAbilityStage_0300 start."; sptr token = new (std::nothrow) Notification::MockIRemoteObject(); std::shared_ptr info = nullptr; - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); EXPECT_TRUE(ohosApplication_->abilityStages_.empty()); auto callback = [](const std::shared_ptr &) {}; bool isAsyncCallback = false; @@ -469,7 +469,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_AddAbilityStage_040 std::shared_ptr info = std::make_shared(); info->applicationInfo.multiProjects = true; sptr token = new (std::nothrow) Notification::MockIRemoteObject(); - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); auto want = std::make_shared(); abilityRecord->SetWant(want); auto callback = [](const std::shared_ptr &) {}; @@ -490,7 +490,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_AddAbilityStage_050 sptr token = new (std::nothrow) Notification::MockIRemoteObject(); std::shared_ptr info = nullptr; std::string moduleName = "entry"; - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); EXPECT_TRUE(ohosApplication_->abilityStages_.empty()); std::shared_ptr abilityStages = std::make_shared(); ohosApplication_->abilityStages_.emplace(moduleName, abilityStages); @@ -513,7 +513,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_AddAbilityStage_060 sptr token; std::shared_ptr info = std::make_shared(); info->moduleName = "entry"; - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); auto callback = [](const std::shared_ptr &) {}; bool isAsyncCallback = false; ohosApplication_->AddAbilityStage(abilityRecord, callback, isAsyncCallback); @@ -532,7 +532,7 @@ HWTEST_F(OHOSApplicationTest, AppExecFwk_OHOSApplicationTest_AddAbilityStage_070 GTEST_LOG_(INFO) << "AppExecFwk_OHOSApplicationTest_AddAbilityStage_0700 start."; sptr token = new (std::nothrow) Notification::MockIRemoteObject(); std::shared_ptr info = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(info, token); + auto abilityRecord = std::make_shared(info, token, nullptr, 0); abilityRecord->token_ = new (std::nothrow) Notification::MockIRemoteObject(); auto callback = [](const std::shared_ptr &) {}; bool isAsyncCallback = false; diff --git a/test/unittest/cj_ability_stage_object_test/BUILD.gn b/test/unittest/cj_ability_stage_object_test/BUILD.gn index d2b3754015..3bb281c9bf 100644 --- a/test/unittest/cj_ability_stage_object_test/BUILD.gn +++ b/test/unittest/cj_ability_stage_object_test/BUILD.gn @@ -52,6 +52,7 @@ ohos_unittest("cj_ability_stage_object_test") { "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", diff --git a/test/unittest/cj_ability_stage_test/BUILD.gn b/test/unittest/cj_ability_stage_test/BUILD.gn index b659e389ba..314575185e 100644 --- a/test/unittest/cj_ability_stage_test/BUILD.gn +++ b/test/unittest/cj_ability_stage_test/BUILD.gn @@ -55,6 +55,7 @@ ohos_unittest("cj_ability_stage_test") { "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", diff --git a/test/unittest/cj_ui_ability_test/BUILD.gn b/test/unittest/cj_ui_ability_test/BUILD.gn index 2d57d7621a..3707769671 100644 --- a/test/unittest/cj_ui_ability_test/BUILD.gn +++ b/test/unittest/cj_ui_ability_test/BUILD.gn @@ -57,6 +57,7 @@ ohos_unittest("cj_ui_ability_test") { "${ability_runtime_native_path}/ability:ability_context_native", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:insight_intent_executor", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", diff --git a/test/unittest/cj_ui_ability_test/cj_ui_ability_test.cpp b/test/unittest/cj_ui_ability_test/cj_ui_ability_test.cpp index c2b39dac2e..124c746fad 100644 --- a/test/unittest/cj_ui_ability_test/cj_ui_ability_test.cpp +++ b/test/unittest/cj_ui_ability_test/cj_ui_ability_test.cpp @@ -139,11 +139,11 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_Init_0100, Function | MediumTest | Level1) sptr token = nullptr; cjAbility_->Init(nullptr, application, handler, token); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); abilityInfo->isModuleJson = true; - abilityLocalRecord = std::make_shared(abilityInfo, token); + abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); GTEST_LOG_(INFO) << "CJRuntime_Init_0100 end"; @@ -185,7 +185,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnNewWant_0100, Function | MediumTest | Leve std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); Want want; cjAbility_->OnNewWant(want); @@ -202,7 +202,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnStart_0100, Function | MediumTest | Level1 std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); Want want; cjAbility_->OnStart(want); @@ -240,7 +240,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnStop_0100, Function | MediumTest | Level1) std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); cjAbility_->OnStop(); AbilityLifecycleExecutor::LifecycleState state = cjAbility_->GetState(); @@ -266,7 +266,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnBackground_0300, Function | MediumTest | L std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); cjAbility_->OnBackground(); AbilityLifecycleExecutor::LifecycleState state = cjAbility_->GetState(); @@ -334,7 +334,7 @@ HWTEST_F(CjUIAbilityTest, CJUIAbility_OnStop_AsyncCallback_0100, TestSize.Level1 std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); bool isAsyncCallback = false; cjAbility_->OnStop(nullptr, isAsyncCallback); @@ -398,7 +398,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnForeground_0100, Function | MediumTest | L std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); Want want; cjAbility_->OnForeground(want); @@ -442,7 +442,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnForeground_0300, Function | MediumTest | L std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); Want want; cjAbility_->OnForeground(want); @@ -469,8 +469,7 @@ HWTEST_F(CjUIAbilityTest, CJUIAbilityVirtualFunc_0100, TestSize.Level1) pageAbilityInfo->isStageBasedModel = true; auto eventRunner = EventRunner::Create(pageAbilityInfo->name); auto handler = std::make_shared(eventRunner); - std::shared_ptr abilityLocalRecord = - std::make_shared(pageAbilityInfo, nullptr); + auto abilityLocalRecord = std::make_shared(pageAbilityInfo, nullptr, nullptr, 0); cjAbility_->Init(abilityLocalRecord, nullptr, handler, nullptr); cjAbility_->UpdateContextConfiguration(); int requestCode = 0; @@ -520,8 +519,7 @@ HWTEST_F(CjUIAbilityTest, CJUIAbilityRequestFocus_0100, TestSize.Level1) pageAbilityInfo->isStageBasedModel = true; auto eventRunner = EventRunner::Create(pageAbilityInfo->name); auto handler = std::make_shared(eventRunner); - std::shared_ptr abilityLocalRecord = - std::make_shared(pageAbilityInfo, nullptr); + auto abilityLocalRecord = std::make_shared(pageAbilityInfo, nullptr, nullptr, 0); cjAbility_->Init(abilityLocalRecord, nullptr, handler, nullptr); // window is nullptr @@ -546,7 +544,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnBackground_0100, Function | MediumTest | L std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); cjAbility_->OnBackground(); AbilityLifecycleExecutor::LifecycleState state = cjAbility_->GetState(); @@ -569,7 +567,7 @@ HWTEST_F(CjUIAbilityTest, CJRuntime_OnBackground_0200, Function | MediumTest | L std::shared_ptr application = nullptr; std::shared_ptr handler = nullptr; sptr token = nullptr; - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); cjAbility_->Init(abilityLocalRecord, application, handler, token); cjAbility_->OnBackground(); AbilityLifecycleExecutor::LifecycleState state = cjAbility_->GetState(); @@ -612,7 +610,7 @@ HWTEST_F(CjUIAbilityTest, InitedCJUIAbilityTest_0100, TestSize.Level1) sptr token = nullptr; abilityInfo->isModuleJson = false; PreSetCJAbilityStageFuncs(); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); initedCJUIAbility_->Init(abilityLocalRecord, application, handler, token); Want want; @@ -633,7 +631,7 @@ HWTEST_F(CjUIAbilityTest, InitedCJUIAbilityTest_0200, TestSize.Level1) sptr token = nullptr; abilityInfo->isModuleJson = false; PreSetCJAbilityStageFuncs(); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); initedCJUIAbility_->Init(abilityLocalRecord, application, handler, token); Want want; @@ -661,7 +659,7 @@ HWTEST_F(CjUIAbilityTest, InitedCJUIAbilityTest_0300, TestSize.Level1) sptr token = nullptr; abilityInfo->isModuleJson = false; PreSetCJAbilityStageFuncs(); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); initedCJUIAbility_->Init(abilityLocalRecord, application, handler, token); Want want; @@ -686,7 +684,7 @@ HWTEST_F(CjUIAbilityTest, InitedCJUIAbilityTest_0400, TestSize.Level1) sptr token = nullptr; abilityInfo->isModuleJson = false; PreSetCJAbilityStageFuncs(); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); initedCJUIAbility_->Init(abilityLocalRecord, application, handler, token); Want want; @@ -722,7 +720,7 @@ HWTEST_F(CjUIAbilityTest, InitedCJUIAbilityTest_0500, TestSize.Level1) sptr token = nullptr; abilityInfo->isModuleJson = false; PreSetCJAbilityStageFuncs(); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); initedCJUIAbility_->Init(abilityLocalRecord, application, handler, token); Want want; @@ -760,7 +758,7 @@ HWTEST_F(CjUIAbilityTest, InitedCJUIAbilityTest_0600, TestSize.Level1) sptr token = nullptr; abilityInfo->isModuleJson = false; PreSetCJAbilityStageFuncs(); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); initedCJUIAbility_->Init(abilityLocalRecord, application, handler, token); Want want; @@ -793,7 +791,7 @@ HWTEST_F(CjUIAbilityTest, InitedCJUIAbilityTest_0700, TestSize.Level1) sptr token = nullptr; abilityInfo->isModuleJson = false; PreSetCJAbilityStageFuncs(); - std::shared_ptr abilityLocalRecord = std::make_shared(abilityInfo, token); + auto abilityLocalRecord = std::make_shared(abilityInfo, token, nullptr, 0); initedCJUIAbility_->Init(abilityLocalRecord, application, handler, token); Want want; diff --git a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn index af64435466..b3f499df50 100644 --- a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn @@ -99,6 +99,7 @@ ohos_unittest("ability_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -618,6 +619,7 @@ ohos_unittest("ability_impl_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -675,6 +677,7 @@ ohos_unittest("ui_ability_impl_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -748,6 +751,7 @@ ohos_unittest("ability_thread_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -826,6 +830,7 @@ ohos_unittest("fa_ability_thread_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -936,6 +941,7 @@ ohos_unittest("ui_ability_thread_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -1319,6 +1325,7 @@ ohos_unittest("data_ability_impl_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -1390,6 +1397,7 @@ ohos_unittest("data_ability_impl_file_secondpart_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -1450,6 +1458,7 @@ ohos_unittest("data_ability_impl_file_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -1512,6 +1521,7 @@ ohos_unittest("ability_thread_dataability_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -1746,6 +1756,7 @@ ohos_unittest("ui_ability_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -1860,6 +1871,7 @@ ohos_unittest("form_host_client_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -1911,6 +1923,7 @@ ohos_unittest("continuation_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -2136,6 +2149,7 @@ ohos_unittest("ability_window_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -2199,6 +2213,7 @@ ohos_unittest("ability_handler_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:app_context_utils", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -2251,6 +2266,7 @@ ohos_unittest("ability_impl_factory_test") { "${ability_runtime_native_path}/ability/native:ability_business_error", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:continuation_ipc", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:app_context_utils", diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_impl_active_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_impl_active_test.cpp index c6e3c79e0f..1d6d7193a5 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_impl_active_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_impl_active_test.cpp @@ -125,7 +125,7 @@ HWTEST_F(AbilityImplActiveTest, AaFwk_AbilityImpl_Active_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mockAbility = std::make_shared(); std::shared_ptr ability = std::static_pointer_cast(mockAbility); std::shared_ptr handler = std::make_shared(nullptr); @@ -165,7 +165,7 @@ HWTEST_F(AbilityImplActiveTest, AaFwk_AbilityImpl_Active_002, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mockAbility = std::make_shared(); std::shared_ptr ability = std::static_pointer_cast(mockAbility); std::shared_ptr handler = std::make_shared(nullptr); @@ -205,7 +205,7 @@ HWTEST_F(AbilityImplActiveTest, AaFwk_AbilityImpl_Active_003, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mockAbility = std::make_shared(); std::shared_ptr ability = std::static_pointer_cast(mockAbility); std::shared_ptr handler = std::make_shared(nullptr); @@ -244,7 +244,7 @@ HWTEST_F(AbilityImplActiveTest, AaFwk_AbilityImpl_InActive_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mockAbility = std::make_shared(); std::shared_ptr ability = std::static_pointer_cast(mockAbility); std::shared_ptr handler = std::make_shared(nullptr); @@ -284,7 +284,7 @@ HWTEST_F(AbilityImplActiveTest, AaFwk_AbilityImpl_InActive_002, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mockAbility = std::make_shared(); std::shared_ptr ability = std::static_pointer_cast(mockAbility); std::shared_ptr handler = std::make_shared(nullptr); @@ -324,7 +324,7 @@ HWTEST_F(AbilityImplActiveTest, AaFwk_AbilityImpl_InActive_003, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mockAbility = std::make_shared(); std::shared_ptr ability = std::static_pointer_cast(mockAbility); std::shared_ptr handler = std::make_shared(nullptr); diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp index 477c0032f3..2e532dd6c6 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp @@ -87,7 +87,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_001, Tes sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr pMocKPageAbility = std::make_shared(); @@ -135,7 +135,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_002, Tes sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr pMocKPageAbility = std::make_shared(); @@ -192,7 +192,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_003, Tes sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr pMocKPageAbility = std::make_shared(); @@ -254,7 +254,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Init_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -285,7 +285,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Start_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -324,7 +324,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Stop_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -362,7 +362,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Active_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -403,7 +403,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Inactive_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -444,7 +444,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Foreground_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -480,7 +480,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Background_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -523,7 +523,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -567,7 +567,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_002, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -611,7 +611,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Background_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -654,7 +654,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Background_002, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -699,7 +699,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_001, TestS sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -744,7 +744,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_002, TestS sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -790,7 +790,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_003, TestS sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -835,7 +835,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_004, TestS sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -879,7 +879,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DispatchSaveAbilityState_001, TestSi sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -907,7 +907,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DispatchSaveAbilityState_002, TestSi sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -935,7 +935,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DispatchRestoreAbilityState_001, Tes sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -966,7 +966,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DispatchRestoreAbilityState_002, Tes sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -996,7 +996,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ConnectAbility_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1034,7 +1034,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CommandAbility_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1142,7 +1142,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_SendResult_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1182,7 +1182,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NewWant_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1220,7 +1220,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_GetFileTypes_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1260,7 +1260,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_OpenFile_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1298,7 +1298,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Insert_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1337,7 +1337,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Update_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1377,7 +1377,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Delete_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1416,7 +1416,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Query_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1457,7 +1457,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CheckAndSave_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1493,7 +1493,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CheckAndRestore_001, TestSize.Level1 sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1522,7 +1522,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Init_0200, TestSize.Level1) std::shared_ptr application; std::shared_ptr abilityInfo = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKPageAbility = std::make_shared(); std::shared_ptr ability = pMocKPageAbility; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); @@ -1563,7 +1563,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Init_0400, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr ability; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -1583,7 +1583,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Init_0500, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKPageAbility = std::make_shared(); std::shared_ptr ability = pMocKPageAbility; std::shared_ptr handler; @@ -1603,7 +1603,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Init_0600, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = nullptr; std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKPageAbility = std::make_shared(); std::shared_ptr ability = pMocKPageAbility; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); @@ -1624,7 +1624,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Init_0700, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKPageAbility = std::make_shared(); std::shared_ptr ability = pMocKPageAbility; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); @@ -1651,7 +1651,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Start_0200, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1689,7 +1689,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Start_0300, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; @@ -1888,7 +1888,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Stop_0800, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability; diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_local_record_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_local_record_test.cpp index f084059a0a..507b8dde0a 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_local_record_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_local_record_test.cpp @@ -51,36 +51,6 @@ void AbilityLocalRecordTest::SetUp() void AbilityLocalRecordTest::TearDown() {} -/** - * @tc.number: GetEventHandler_0100 - * @tc.name: GetEventHandler - * @tc.desc: GetEventHandler Test, return is not nullptr. - */ -HWTEST_F(AbilityLocalRecordTest, GetEventHandler_0100, TestSize.Level0) -{ - GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetEventHandler_0100 start"; - auto record = std::make_shared(nullptr, nullptr); - auto handler = std::make_shared(EventRunner::Create()); - record->SetEventHandler(handler); - EXPECT_TRUE(record->GetEventHandler() != nullptr); - GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetEventHandler_0100 end"; -} - -/** - * @tc.number: GetEventRunner_0100 - * @tc.name: GetEventRunner - * @tc.desc: GetEventRunner Test, return is not nullptr. - */ -HWTEST_F(AbilityLocalRecordTest, GetEventRunner_0100, TestSize.Level0) -{ - GTEST_LOG_(INFO) << "AbilityLocalRecordTest SetEventHandler_0100 start"; - auto record = std::make_shared(nullptr, nullptr); - std::shared_ptr runner = EventRunner::GetMainEventRunner(); - record->SetEventRunner(runner); - EXPECT_TRUE(record->GetEventRunner() != nullptr); - GTEST_LOG_(INFO) << "AbilityLocalRecordTest SetEventHandler_0100 end"; -} - /** * @tc.number: GetAbilityThread_0100 * @tc.name: GetAbilityThread @@ -89,7 +59,7 @@ HWTEST_F(AbilityLocalRecordTest, GetEventRunner_0100, TestSize.Level0) HWTEST_F(AbilityLocalRecordTest, GetAbilityThread_0100, TestSize.Level0) { GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetAbilityThread_0100 start"; - auto record = std::make_shared(nullptr, nullptr); + auto record = std::make_shared(nullptr, nullptr, nullptr, 0); auto abilityThread = sptr(nullptr); record->SetAbilityThread(abilityThread); EXPECT_TRUE(record->GetAbilityThread() == nullptr); @@ -104,9 +74,8 @@ HWTEST_F(AbilityLocalRecordTest, GetAbilityThread_0100, TestSize.Level0) HWTEST_F(AbilityLocalRecordTest, GetWant_0100, TestSize.Level0) { GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetWant_0100 start"; - auto record = std::make_shared(nullptr, nullptr); std::shared_ptr want; - record->SetWant(want); + auto record = std::make_shared(nullptr, nullptr, want, 0); EXPECT_TRUE(record->GetWant() == nullptr); GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetWant_0100 end"; } @@ -121,7 +90,7 @@ HWTEST_F(AbilityLocalRecordTest, GetAbilityInfo_0100, TestSize.Level0) GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetAbilityInfo_0100 start"; auto info = std::make_shared(); sptr token = new (std::nothrow) MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); EXPECT_TRUE(record->GetAbilityInfo() != nullptr); GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetAbilityInfo_0100 end"; } @@ -136,7 +105,7 @@ HWTEST_F(AbilityLocalRecordTest, GetToken_0100, TestSize.Level0) GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetToken_0100 start"; auto info = std::make_shared(); sptr token = new (std::nothrow) MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); EXPECT_TRUE(record->GetToken() != nullptr); GTEST_LOG_(INFO) << "AbilityLocalRecordTest GetToken_0100 end"; } \ No newline at end of file diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_thread_dataability_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_thread_dataability_test.cpp index 5693796af4..c6dd3d939b 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_thread_dataability_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_thread_dataability_test.cpp @@ -94,8 +94,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Query_0100, Function | MediumTes EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); std::shared_ptr mockdataability = std::make_shared(); @@ -159,8 +158,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_GetFileTypes_0100, Function | Me EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); std::shared_ptr mockdataability = std::make_shared(); @@ -223,8 +221,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_OpenFile_0100, Function | Medium EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); std::shared_ptr mockdataability = std::make_shared(); @@ -283,8 +280,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Insert_0100, Function | MediumTe EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); std::shared_ptr mockdataability = std::make_shared(); @@ -339,8 +335,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Update_0100, Function | MediumTe EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); std::shared_ptr mockdataability = std::make_shared(); diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_thread_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_thread_test.cpp index f798388c79..8217ba8a76 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_thread_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_thread_test.cpp @@ -88,7 +88,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_DumpAbilityInfo_0100, Function | abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -127,8 +127,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleSaveAbilityState_0100, F EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -176,8 +175,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleRestoreAbilityState_0100 EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); PacMap state; @@ -225,8 +223,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Attach_3_Param_0100, Function | EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); sleep(1); @@ -253,8 +250,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Attach_3_Param_0200, Function | EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -282,8 +278,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Attach_2_Param_0100, Function | EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); abilitythread->Attach(application, abilityRecord, nullptr); sleep(1); @@ -310,8 +305,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Attach_2_Param_0200, Function | EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, nullptr); @@ -341,8 +335,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleAbilityTransaction_0100, EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -374,8 +367,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleAbilityTransaction_0200, EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); abilitythread->Attach(application, abilityRecord, nullptr); Want want; @@ -405,8 +397,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleConnectAbility_0100, Fun EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -436,8 +427,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleConnectAbility_0200, Fun abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -466,8 +456,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleDisconnectAbility_0100, EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -497,8 +486,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleDisconnectAbility_0200, abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -528,8 +516,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleCommandAbility_0100, Fun EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -562,8 +549,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleCommandAbility_0200, Fun abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -594,8 +580,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleCommandAbilityWindow_010 EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -628,8 +613,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_SendResult_0100, Function | Medi EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr abilityimpl = std::make_shared(); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -662,8 +646,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_SendResult_0200, Function | Medi abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -693,8 +676,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_AbilityThreadMain_0100, Function EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->AbilityThreadMain(application, abilityRecord, mainRunner, nullptr); @@ -721,8 +703,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_AbilityThreadMain_0200, Function EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->AbilityThreadMain(application, abilityRecord, mainRunner, nullptr); @@ -749,8 +730,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_AbilityThreadMain_0300, Function EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->AbilityThreadMain(application, abilityRecord, nullptr); @@ -777,8 +757,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_AbilityThreadMain_0400, Function EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->AbilityThreadMain(application, abilityRecord, nullptr); @@ -804,7 +783,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_AttachExtension_0100, Function | abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); @@ -833,7 +812,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_AttachExtension_0200, Function | abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, application); auto extension = AbilityLoader::GetInstance().GetExtensionByName(abilityName); @@ -858,7 +837,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_AttachExtension_0201, Function | abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, nullptr); auto extension = AbilityLoader::GetInstance().GetExtensionByName(abilityName); @@ -1287,7 +1266,7 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_SendResult_0300, Function | Medi abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); auto application = std::make_shared(); - auto abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); diff --git a/test/unittest/frameworks_kits_ability_native_test/action_extension_test.cpp b/test/unittest/frameworks_kits_ability_native_test/action_extension_test.cpp index 9367b3f31c..772994e0c2 100644 --- a/test/unittest/frameworks_kits_ability_native_test/action_extension_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/action_extension_test.cpp @@ -84,7 +84,7 @@ HWTEST_F(ActionExtensionTest, Action_Extension_0300, Function | MediumTest | Lev GTEST_LOG_(INFO) << "Action_Extension_0300 start"; auto abilityInfo = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto application = std::make_shared(); auto contextImpl = std::make_shared(); auto applicationContext = ApplicationContext::GetInstance(); diff --git a/test/unittest/frameworks_kits_ability_native_test/auto_fill_extension_test.cpp b/test/unittest/frameworks_kits_ability_native_test/auto_fill_extension_test.cpp index c0ea4c7bfe..3130dfc9f8 100644 --- a/test/unittest/frameworks_kits_ability_native_test/auto_fill_extension_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/auto_fill_extension_test.cpp @@ -98,7 +98,7 @@ HWTEST_F(AutoFillExtensionTest, Init_0100, Function | MediumTest | Level1) auto abilityInfo = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); EXPECT_NE(token, nullptr); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); EXPECT_NE(record, nullptr); auto application = std::make_shared(); EXPECT_NE(application, nullptr); @@ -108,7 +108,7 @@ HWTEST_F(AutoFillExtensionTest, Init_0100, Function | MediumTest | Level1) application->SetApplicationContext(applicationContext); auto handler = std::make_shared(nullptr); EXPECT_NE(handler, nullptr); - + autoFillExtension->Init(record, application, handler, token); EXPECT_TRUE(autoFillExtension->context_ != nullptr); GTEST_LOG_(INFO) << "Init_0100 end"; @@ -135,7 +135,7 @@ HWTEST_F(AutoFillExtensionTest, CreateAndInitContext_0100, Function | MediumTest abilityInfo->bundleName = BUNDLE_NAME; sptr token = new AppExecFwk::MockAbilityToken(); EXPECT_NE(token, nullptr); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); EXPECT_NE(record, nullptr); auto application = std::make_shared(); EXPECT_NE(application, nullptr); @@ -145,7 +145,7 @@ HWTEST_F(AutoFillExtensionTest, CreateAndInitContext_0100, Function | MediumTest application->SetApplicationContext(applicationContext); auto handler = std::make_shared(nullptr); EXPECT_NE(handler, nullptr); - + auto context = autoFillExtension->CreateAndInitContext(record, application, handler, token); EXPECT_NE(context, nullptr); @@ -157,7 +157,7 @@ HWTEST_F(AutoFillExtensionTest, CreateAndInitContext_0100, Function | MediumTest auto resourceManager = appContext->GetResourceManager(); EXPECT_EQ(context->GetResourceManager(), resourceManager); EXPECT_EQ(context->parentContext_, appContext); - + EXPECT_EQ(context->GetAbilityInfo(), abilityInfo); EXPECT_EQ(context->GetConfiguration(), appContext->GetConfiguration()); @@ -193,7 +193,7 @@ HWTEST_F(AutoFillExtensionTest, CreateAndInitContext_0200, Function | MediumTest auto handler = std::make_shared(nullptr); EXPECT_NE(handler, nullptr); std::shared_ptr record = nullptr; - + auto context = autoFillExtension->CreateAndInitContext(record, application, handler, token); EXPECT_NE(context, nullptr); @@ -205,7 +205,7 @@ HWTEST_F(AutoFillExtensionTest, CreateAndInitContext_0200, Function | MediumTest auto resourceManager = appContext->GetResourceManager(); EXPECT_EQ(context->GetResourceManager(), resourceManager); EXPECT_EQ(context->parentContext_, appContext); - + EXPECT_EQ(context->GetAbilityInfo(), nullptr); EXPECT_EQ(context->GetConfiguration(), nullptr); diff --git a/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_secondpart_test.cpp b/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_secondpart_test.cpp index d2973c6ccf..06cd67ccfa 100644 --- a/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_secondpart_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_secondpart_test.cpp @@ -69,7 +69,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_BatchInsert_001, Functio abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr handler = std::make_shared(nullptr); std::shared_ptr ability = std::make_shared(); dataabilityimpl->Init(application, record, ability, handler, token); @@ -117,7 +117,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_HandleAbilityTransaction abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr handler = std::make_shared(nullptr); std::shared_ptr ability = std::make_shared(); dataabilityimpl->Init(application, record, ability, handler, token); @@ -144,7 +144,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_HandleAbilityTransaction abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr handler = std::make_shared(nullptr); std::shared_ptr ability = std::make_shared(); dataabilityimpl->Init(application, record, ability, handler, token); diff --git a/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_test.cpp b/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_test.cpp index 33fa440111..e29bf550c4 100644 --- a/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_file_test.cpp @@ -69,7 +69,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetType_001, Function | abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -97,7 +97,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetType_002, Function | abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = nullptr; @@ -123,7 +123,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetFileTypes_001, Functi abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -178,7 +178,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenFile_001, Function | abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -229,7 +229,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenRawFile_001, Functio abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -280,7 +280,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Reload_001, Function | M abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); diff --git a/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_test.cpp index f1e1d4bebf..4a87cc7f2c 100644 --- a/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/data_ability_impl_test.cpp @@ -77,7 +77,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Insert_0100, Function | abilityInfo->type = AbilityType::DATA; abilityInfo->isNativeAbility = true; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -129,7 +129,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Insert_0300, Function | abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -163,7 +163,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Update_0100, Function | abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -214,7 +214,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Update_0300, Function | abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -247,7 +247,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Delete_0100, Function | abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -297,7 +297,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Delete_0300, Function | abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -330,7 +330,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Query_0100, Function | M abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -383,7 +383,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Query_0300, Function | M abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -418,7 +418,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenFile_0100, Function abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -466,7 +466,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenFile_0300, Function abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -497,7 +497,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenRawFile_0100, Functi abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -545,7 +545,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_OpenRawFile_0300, Functi abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -576,7 +576,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Call_0100, Function | Me abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -627,7 +627,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetFileTypes_0100, Funct abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -677,7 +677,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetType_0100, Function | abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -722,7 +722,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_Reload_0100, Function | abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -767,7 +767,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_BatchInsert_0100, Functi abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -816,7 +816,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_BatchInsert_0300, Functi abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -848,7 +848,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_NormalizeUri_0100, Funct abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -895,7 +895,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_NormalizeUri_0300, Funct abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -926,7 +926,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_DenormalizeUri_0100, Fun abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -973,7 +973,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_DenormalizeUri_0300, Fun abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1006,7 +1006,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetPermissionInfo_0100, abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1039,7 +1039,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetPermissionInfo_0200, abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1072,7 +1072,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetPermissionInfo_0300, abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1105,7 +1105,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetPermissionInfo_0400, abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1135,7 +1135,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_GetPermissionInfo_0500, abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1166,7 +1166,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1202,7 +1202,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1235,7 +1235,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1268,7 +1268,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1304,7 +1304,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1339,7 +1339,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_CheckOpenFilePermission_ abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1374,7 +1374,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_CheckOpenFilePermission_ abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1409,7 +1409,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_CheckOpenFilePermission_ abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1444,7 +1444,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_CheckOpenFilePermission_ abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1479,7 +1479,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_CheckOpenFilePermission_ abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1512,7 +1512,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_ExecuteBatch_0100, Funct abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1559,7 +1559,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_ExecuteBatch_0300, Funct abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1594,7 +1594,7 @@ HWTEST_F(DataAbilityImplTest, AaFwk_DataAbilityImplTest_ExecuteBatch_0400, Funct abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1625,7 +1625,7 @@ HWTEST_F( abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1653,7 +1653,7 @@ HWTEST_F( abilityInfo->name = "MockDataAbility"; abilityInfo->type = AbilityType::DATA; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1685,7 +1685,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1721,7 +1721,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1757,7 +1757,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1793,7 +1793,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); @@ -1829,7 +1829,7 @@ HWTEST_F( abilityInfo->readPermission = "r"; abilityInfo->writePermission = "w"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr ability = std::make_shared(); diff --git a/test/unittest/frameworks_kits_ability_native_test/embedded_ui_extension_test.cpp b/test/unittest/frameworks_kits_ability_native_test/embedded_ui_extension_test.cpp index bdaf6854e8..23c1e5763d 100644 --- a/test/unittest/frameworks_kits_ability_native_test/embedded_ui_extension_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/embedded_ui_extension_test.cpp @@ -84,7 +84,7 @@ HWTEST_F(EmbeddedUIExtensionTest, EmbeddedUI_Extension_0300, Function | MediumTe GTEST_LOG_(INFO) << "EmbeddedUI_Extension_0300 start"; auto abilityInfo = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto application = std::make_shared(); auto contextImpl = std::make_shared(); auto applicationContext = ApplicationContext::GetInstance(); diff --git a/test/unittest/frameworks_kits_ability_native_test/extension_ability_thread_test.cpp b/test/unittest/frameworks_kits_ability_native_test/extension_ability_thread_test.cpp index 414f6ce837..b7fd594f31 100644 --- a/test/unittest/frameworks_kits_ability_native_test/extension_ability_thread_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/extension_ability_thread_test.cpp @@ -68,7 +68,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_DumpAbilityInfo_0100 abilityInfo->type = AbilityType::EXTENSION; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); std::vector params; @@ -144,8 +144,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_Attach_3_Param_0100, EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); sleep(1); @@ -173,8 +172,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_Attach_3_Param_0200, EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); sleep(1); @@ -202,8 +200,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_Attach_2_Param_0100, EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); extensionabilitythread->Attach(application, abilityRecord, nullptr); sleep(1); } @@ -230,8 +227,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_Attach_2_Param_0200, EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, nullptr); sleep(1); @@ -260,8 +256,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleAbilityTrans EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -293,8 +288,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleAbilityTrans EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); extensionabilitythread->Attach(application, abilityRecord, nullptr); Want want; LifeCycleStateInfo lifeCycleStateInfo; @@ -367,8 +361,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleConnectAbili EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -397,7 +390,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleConnectAbili abilityInfo->type = AbilityType::EXTENSION; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -426,8 +419,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleDisconnectAb EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -456,7 +448,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleDisconnectAb abilityInfo->type = AbilityType::EXTENSION; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -486,8 +478,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleCommandAbili EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -518,7 +509,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleCommandAbili abilityInfo->type = AbilityType::EXTENSION; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -549,8 +540,7 @@ HWTEST_F(ExtensionAbilityThreadTest, ExtensionAbilityThread_ScheduleCommandAbili EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); extensionabilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -1007,7 +997,7 @@ HWTEST_F( abilityInfo->name = "ExtensionAbility"; abilityInfo->type = AbilityType::EXTENSION; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); std::string abilityName = extensionabilitythread->CreateAbilityName(abilityRecord, application); auto extension = AbilityLoader::GetInstance().GetExtensionByName(abilityName); diff --git a/test/unittest/frameworks_kits_ability_native_test/extension_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/extension_impl_test.cpp index 7ed127f350..0b57816a31 100644 --- a/test/unittest/frameworks_kits_ability_native_test/extension_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/extension_impl_test.cpp @@ -111,7 +111,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_0300, Function | MediumTest | Le std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); std::shared_ptr extension; std::shared_ptr handler; @@ -199,7 +199,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_0700, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -222,7 +222,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_0800, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -279,7 +279,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_1100, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -304,7 +304,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_1200, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -360,7 +360,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_1500, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -386,7 +386,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_1600, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -439,7 +439,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_1900, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -496,7 +496,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_2200, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -523,7 +523,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_2300, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -560,7 +560,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_2600, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -591,7 +591,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_2700, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -618,7 +618,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_2800, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -645,7 +645,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_2900, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -670,7 +670,7 @@ HWTEST_F(ExtensionImplTest, AaFwk_ExtensionImpl_3000, Function | MediumTest | Le auto application = std::make_shared(); std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto extension = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); diff --git a/test/unittest/frameworks_kits_ability_native_test/extension_second_test.cpp b/test/unittest/frameworks_kits_ability_native_test/extension_second_test.cpp index 24db446fab..8620d25a21 100644 --- a/test/unittest/frameworks_kits_ability_native_test/extension_second_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/extension_second_test.cpp @@ -54,7 +54,7 @@ void ExtensionTest::SetUp(void) { std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto application = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); diff --git a/test/unittest/frameworks_kits_ability_native_test/extension_test.cpp b/test/unittest/frameworks_kits_ability_native_test/extension_test.cpp index ef0d14c801..70b33d0229 100644 --- a/test/unittest/frameworks_kits_ability_native_test/extension_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/extension_test.cpp @@ -54,7 +54,7 @@ void ExtensionTest::SetUp(void) { std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto application = std::make_shared(); std::shared_ptr runner; auto handler = std::make_shared(runner); @@ -97,7 +97,7 @@ HWTEST_F(ExtensionTest, AaFwk_Extension_0200, Function | MediumTest | Level1) OHOS::AppExecFwk::AbilityInfo abilityInfo; std::shared_ptr info = std::make_shared(); sptr token = nullptr; - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); std::shared_ptr application; std::shared_ptr handler; @@ -162,7 +162,7 @@ HWTEST_F(ExtensionTest, AaFwk_Extension_0500, Function | MediumTest | Level1) GTEST_LOG_(INFO) << "AaFwk_Extension_0500 start"; std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); auto application = std::make_shared(); diff --git a/test/unittest/frameworks_kits_ability_native_test/fa_ability_thread_test.cpp b/test/unittest/frameworks_kits_ability_native_test/fa_ability_thread_test.cpp index 7a75a8b023..6199eaf37b 100644 --- a/test/unittest/frameworks_kits_ability_native_test/fa_ability_thread_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/fa_ability_thread_test.cpp @@ -231,7 +231,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_CreateAbilityName_0100, Functi abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, nullptr); EXPECT_EQ(abilityName, ""); @@ -271,7 +271,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_CreateExtensionAbilityName_010 std::string abilityName = "MockPageAbility"; abilitythread->CreateExtensionAbilityName(application, abilityInfo, abilityName); sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string ret = abilitythread->CreateAbilityName(abilityRecord, application); EXPECT_EQ(abilityName, "MockPageAbility"); GTEST_LOG_(INFO) << "AaFwk_AbilityThread_CreateExtensionAbilityName_0101 end"; @@ -295,7 +295,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_CreateExtensionAbilityName_020 std::string abilityName = ""; abilitythread->CreateExtensionAbilityName(application, abilityInfo, abilityName); sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string ret = abilitythread->CreateAbilityName(abilityRecord, application); EXPECT_EQ(abilityName, "ServiceExtension"); GTEST_LOG_(INFO) << "AaFwk_AbilityThread_CreateExtensionAbilityName_0200 end"; @@ -316,7 +316,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_AttachExtension_0300, Function abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); @@ -370,7 +370,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_AttachExtension_0500, Function abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, application); auto extension = AbilityLoader::GetInstance().GetExtensionByName(abilityName); @@ -398,7 +398,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_CreateAndInitContextDeal_0500, abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, application); auto extension = AbilityLoader::GetInstance().GetExtensionByName(abilityName); @@ -424,7 +424,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_CreateAndInitContextDeal_0600, abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr abilityObject = std::make_shared(); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, nullptr); @@ -453,7 +453,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_InitExtensionFlag_0200, Functi abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, application); auto extension = AbilityLoader::GetInstance().GetExtensionByName(abilityName); @@ -485,7 +485,7 @@ HWTEST_F(FaAbilityThreadTest, AaFwk_AbilityThread_InitExtensionFlag_0300, Functi abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::string abilityName = abilitythread->CreateAbilityName(abilityRecord, application); auto extension = AbilityLoader::GetInstance().GetExtensionByName(abilityName); diff --git a/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp b/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp index 31c4b67e9c..660022660d 100644 --- a/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp @@ -94,7 +94,7 @@ HWTEST_F(FormExtensionTest, AaFwk_Form_Extension_0300, Function | MediumTest | L GTEST_LOG_(INFO) << "AaFwk_Form_Extension_0300 start"; std::shared_ptr abilityInfo = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr contextImpl = std::make_shared(); @@ -141,7 +141,7 @@ HWTEST_F(FormExtensionTest, AaFwk_Form_Extension_0500, Function | MediumTest | L GTEST_LOG_(INFO) << "AaFwk_Form_Extension_0500 start"; std::shared_ptr info = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(info, token); + auto record = std::make_shared(info, token, nullptr, 0); std::shared_ptr application; std::shared_ptr handler; AbilityRuntime::Runtime::Options options; diff --git a/test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp index 4ba8752d79..97e5ac539e 100644 --- a/test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp @@ -79,7 +79,7 @@ HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_HandleAbilityTransaction_0100, std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "newAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -136,7 +136,7 @@ HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_HandleAbilityTransaction_0300, std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "newAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); diff --git a/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp index d9b15a7c79..ca42188510 100644 --- a/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp @@ -73,7 +73,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyDown_0100, Function | M std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -106,7 +106,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyDown_0200, Function | M std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -138,7 +138,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyUp_0100, Function | Med std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -171,7 +171,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyUp_0200, Function | Med std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -204,7 +204,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoTouchEvent_0100, Function std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -237,7 +237,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoTouchEvent_0200, Function std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -269,7 +269,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_010 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -303,7 +303,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_020 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -333,7 +333,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_030 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -363,7 +363,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_040 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -393,7 +393,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_050 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -425,7 +425,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_060 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -458,7 +458,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_070 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -493,7 +493,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_080 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -527,7 +527,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_090 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -563,7 +563,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DispatchSaveAbilityState_010 std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -590,7 +590,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DispatchRestoreAbilityState_ std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -618,7 +618,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_SendResult_0100, Function | std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -648,7 +648,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_NewWant_0100, Function | Med std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -674,7 +674,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_100 auto abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto eventRunner = EventRunner::Create(abilityInfo->name); auto handler = std::make_shared(eventRunner); @@ -705,7 +705,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_110 auto abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto eventRunner = EventRunner::Create(abilityInfo->name); auto handler = std::make_shared(eventRunner); @@ -736,7 +736,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_120 auto abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto eventRunner = EventRunner::Create(abilityInfo->name); auto handler = std::make_shared(eventRunner); @@ -767,7 +767,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_130 auto abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto eventRunner = EventRunner::Create(abilityInfo->name); auto handler = std::make_shared(eventRunner); @@ -798,7 +798,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_140 auto abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto eventRunner = EventRunner::Create(abilityInfo->name); auto handler = std::make_shared(eventRunner); @@ -829,7 +829,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_150 auto abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto eventRunner = EventRunner::Create(abilityInfo->name); auto handler = std::make_shared(eventRunner); @@ -861,7 +861,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_160 auto abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto eventRunner = EventRunner::Create(abilityInfo->name); auto handler = std::make_shared(eventRunner); diff --git a/test/unittest/frameworks_kits_ability_native_test/service_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/service_ability_impl_test.cpp index e2d3be03be..754ce81650 100644 --- a/test/unittest/frameworks_kits_ability_native_test/service_ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/service_ability_impl_test.cpp @@ -72,7 +72,7 @@ HWTEST_F(ServiceAbilityImplTest, AaFwk_ServiceAbilityImpl_HandleAbilityTransacti std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "MockServiceAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); sptr abilityThread = @@ -113,7 +113,7 @@ HWTEST_F(ServiceAbilityImplTest, AaFwk_ServiceAbilityImpl_HandleAbilityTransacti abilityInfo->name = "MockServiceAbility"; abilityInfo->type = AppExecFwk::AbilityType::SERVICE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); sptr abilityThread = @@ -150,7 +150,7 @@ HWTEST_F(ServiceAbilityImplTest, AaFwk_ServiceAbilityImpl_HandleAbilityTransacti std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "MockServiceAbility"; sptr token = nullptr; - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -186,7 +186,7 @@ HWTEST_F(ServiceAbilityImplTest, AaFwk_ServiceAbilityImpl_HandleAbilityTransacti abilityInfo->name = "MockServiceAbility"; abilityInfo->type = AppExecFwk::AbilityType::SERVICE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); diff --git a/test/unittest/frameworks_kits_ability_native_test/share_extension_module_loader_test.cpp b/test/unittest/frameworks_kits_ability_native_test/share_extension_module_loader_test.cpp index 5347bf1668..b899969a58 100644 --- a/test/unittest/frameworks_kits_ability_native_test/share_extension_module_loader_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/share_extension_module_loader_test.cpp @@ -84,7 +84,7 @@ HWTEST_F(ShareExtensionTest, Share_Extension_0300, Function | MediumTest | Level GTEST_LOG_(INFO) << "Share_Extension_0300 start"; auto abilityInfo = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto application = std::make_shared(); auto contextImpl = std::make_shared(); auto applicationContext = ApplicationContext::GetInstance(); diff --git a/test/unittest/frameworks_kits_ability_native_test/share_extension_test.cpp b/test/unittest/frameworks_kits_ability_native_test/share_extension_test.cpp index 24d65287b1..b681e822fd 100644 --- a/test/unittest/frameworks_kits_ability_native_test/share_extension_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/share_extension_test.cpp @@ -84,7 +84,7 @@ HWTEST_F(ShareExtensionTest, Share_Extension_0300, Function | MediumTest | Level GTEST_LOG_(INFO) << "Share_Extension_0300 start"; auto abilityInfo = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto application = std::make_shared(); auto contextImpl = std::make_shared(); auto applicationContext = ApplicationContext::GetInstance(); diff --git a/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp index 2e6267800e..f7cea9c254 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp @@ -80,7 +80,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_ScheduleUpdateConfiguration_001, Test sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr pMocKUIAbility = std::make_shared(); @@ -128,7 +128,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_ScheduleUpdateConfiguration_002, Test sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr pMocKUIAbility = std::make_shared(); @@ -184,7 +184,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_ScheduleUpdateConfiguration_003, Test sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr pMocKUIAbility = std::make_shared(); @@ -244,7 +244,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Init_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = std::make_shared(); @@ -274,7 +274,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Start_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability; @@ -313,7 +313,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Stop_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability; @@ -353,7 +353,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -397,7 +397,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_002, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -439,7 +439,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Background_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -482,7 +482,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Background_002, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -527,7 +527,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_001, TestSi sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -572,7 +572,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_002, TestSi sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -618,7 +618,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_003, TestSi sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -663,7 +663,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_004, TestSi sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -707,7 +707,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_DispatchRestoreAbilityState_001, Test sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = std::make_shared(); @@ -737,7 +737,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_DispatchRestoreAbilityState_002, Test sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability = nullptr; @@ -767,7 +767,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_SendResult_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability; @@ -806,7 +806,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_NewWant_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability; @@ -843,7 +843,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_CheckAndRestore_001, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability; @@ -872,7 +872,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Init_0200, TestSize.Level1) std::shared_ptr application; std::shared_ptr abilityInfo = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKUIAbility = std::make_shared(); std::shared_ptr uiability = pMocKUIAbility; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); @@ -913,7 +913,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Init_0400, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr uiability; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); @@ -933,7 +933,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Init_0500, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKUIAbility = std::make_shared(); std::shared_ptr uiability = pMocKUIAbility; std::shared_ptr handler; @@ -953,7 +953,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Init_0600, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = nullptr; std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKUIAbility = std::make_shared(); std::shared_ptr uiability = pMocKUIAbility; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); @@ -974,7 +974,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Init_0700, TestSize.Level1) std::shared_ptr application = std::make_shared(); sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr pMocKUIAbility = std::make_shared(); std::shared_ptr uiability = pMocKUIAbility; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); @@ -1002,7 +1002,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Start_0300, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability; @@ -1201,7 +1201,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Stop_0800, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); EXPECT_NE(token, nullptr); if (token != nullptr) { - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); std::shared_ptr uiability; diff --git a/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp index 0ab938e2fd..e7af954413 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp @@ -72,11 +72,11 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_Name_0100, Function | MediumTest | Le std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); EXPECT_STREQ(abilityInfo->name.c_str(), ability_->GetAbilityName().c_str()); - std::shared_ptr abilityRecord2 = std::make_shared(nullptr, abilityToken); + auto abilityRecord2 = std::make_shared(nullptr, abilityToken, nullptr, 0); ability_->Init(abilityRecord2, application, handler, token); EXPECT_EQ("", ability_->GetAbilityName()); @@ -106,7 +106,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_GetAbilityName_0100, Function | Mediu std::string name = "LOL"; abilityInfo->name = name; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); EXPECT_STREQ(ability_->GetAbilityName().c_str(), name.c_str()); GTEST_LOG_(INFO) << "AbilityRuntime_GetAbilityName_0100 end"; @@ -127,12 +127,11 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_GetModuleName_0100, Function | Medium std::string name = "LOL"; abilityInfo->moduleName = name; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(nullptr, abilityToken); + auto abilityRecord = std::make_shared(nullptr, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); EXPECT_EQ(ability_->GetModuleName(), ""); - std::shared_ptr abilityRecord2 = std::make_shared(abilityInfo, - abilityToken); + auto abilityRecord2 = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord2, application, handler, token); EXPECT_STREQ(ability_->GetModuleName().c_str(), name.c_str()); } @@ -151,7 +150,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_GetLifecycle_0100, Function | MediumT std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); std::shared_ptr lifeCycle = ability_->GetLifecycle(); EXPECT_NE(lifeCycle, nullptr); @@ -201,7 +200,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnNewWant_0100, Function | MediumTest std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); Want want; ability_->OnNewWant(want); @@ -222,7 +221,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnRestoreAbilityState_0100, Function std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); PacMap inState; ability_->OnRestoreAbilityState(inState); @@ -243,7 +242,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_GetWindow_001, Function | MediumTest std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); EXPECT_EQ(ability_->GetWindow(), nullptr); GTEST_LOG_(INFO) << "AbilityRuntime_GetWindow_0100 end"; @@ -265,7 +264,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnStart_0100, Function | MediumTest | std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); Want want; ability_->OnStart(want); @@ -318,7 +317,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnStart_0300, TestSize.Level1) auto handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, application, handler, token); Want want; ability->OnStart(want); @@ -364,7 +363,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnStop_0100, Function | MediumTest | std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); ability_->OnStop(); AbilityLifecycleExecutor::LifecycleState state = ability_->GetState(); @@ -442,7 +441,7 @@ HWTEST_F(UIAbilityBaseTest, DestroyInstance_0100, TestSize.Level1) auto handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, application, handler, token); ability->DestroyInstance(); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); @@ -463,7 +462,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnForeground_0100, Function | MediumT std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); Want want; bool prevSilentForground = ability_->CheckIsSilentForeground(); @@ -513,7 +512,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnForeground_0300, Function | MediumT std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); Want want; ability_->OnForeground(want); @@ -540,7 +539,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnBackground_0100, Function | MediumT std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); ability_->OnBackground(); AbilityLifecycleExecutor::LifecycleState state = ability_->GetState(); @@ -564,7 +563,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnBackground_0200, Function | MediumT std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); ability_->OnBackground(); AbilityLifecycleExecutor::LifecycleState state = ability_->GetState(); @@ -590,7 +589,7 @@ HWTEST_F(UIAbilityBaseTest, AaFwk_Ability_OnBackground_0300, Function | MediumTe std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); ability_->OnBackground(); AbilityLifecycleExecutor::LifecycleState state = ability_->GetState(); @@ -627,7 +626,7 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnBackground_0400, TestSize.Level1) auto handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, application, handler, token); int32_t displayId = 0; sptr option = new Rosen::WindowOption(); @@ -771,8 +770,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityContinuation_0300, TestSize.Level1) auto eventRunner = EventRunner::Create(pageAbilityInfo->name); auto handler = std::make_shared(eventRunner); sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = - std::make_shared(pageAbilityInfo, abilityToken); + auto abilityRecord = std::make_shared(pageAbilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, nullptr, handler, nullptr); Want want; bool success = false; @@ -1090,8 +1088,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbilitySetMissionLabel_0100, TestSize.Level1) std::shared_ptr eventRunner = EventRunner::Create(pageAbilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = - std::make_shared(pageAbilityInfo, abilityToken); + auto abilityRecord = std::make_shared(pageAbilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, nullptr, handler, nullptr); ret = ability->SetMissionLabel(label); EXPECT_EQ(ret, -1); @@ -1124,8 +1121,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbilitySetMissionIcon_0100, TestSize.Level1) std::shared_ptr eventRunner = EventRunner::Create(pageAbilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = - std::make_shared(pageAbilityInfo, abilityToken); + auto abilityRecord = std::make_shared(pageAbilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, nullptr, handler, nullptr); ret = ability->SetMissionIcon(icon); EXPECT_EQ(ret, -1); @@ -1153,8 +1149,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityOnChange_0100, TestSize.Level1) auto eventRunner = EventRunner::Create(pageAbilityInfo->name); auto handler = std::make_shared(eventRunner); sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = - std::make_shared(pageAbilityInfo, abilityToken); + auto abilityRecord = std::make_shared(pageAbilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, nullptr, handler, nullptr); // application is nullptr @@ -1188,8 +1183,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityOnDisplayMove_0100, TestSize.Level1) auto eventRunner = EventRunner::Create(pageAbilityInfo->name); auto handler = std::make_shared(eventRunner); sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = - std::make_shared(pageAbilityInfo, abilityToken); + auto abilityRecord = std::make_shared(pageAbilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, nullptr, handler, nullptr); // application is nullptr @@ -1228,8 +1222,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityRequestFocus_0100, TestSize.Level1) auto eventRunner = EventRunner::Create(pageAbilityInfo->name); auto handler = std::make_shared(eventRunner); sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = - std::make_shared(pageAbilityInfo, abilityToken); + auto abilityRecord = std::make_shared(pageAbilityInfo, abilityToken, nullptr, 0); ability->Init(abilityRecord, nullptr, handler, nullptr); // window is nullptr @@ -1269,7 +1262,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_OnStop_AsyncCallback_0100, TestSize.Level1 std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); bool isAsyncCallback = false; ability_->OnStop(nullptr, isAsyncCallback); @@ -1298,7 +1291,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_OnConfigurationUpdatedNotify_0100, TestSiz std::shared_ptr handler = nullptr; sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); auto abilityContext = std::make_shared(); ability_->AttachAbilityContext(abilityContext); @@ -1325,7 +1318,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_InitWindow_0100, TestSize.Level1) std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); int32_t displayId = 0; sptr option = new Rosen::WindowOption(); @@ -1366,7 +1359,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_GetWindowOption_0100, TestSize.Level1) std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); CustomizeData custData = CustomizeData("ShowOnLockScreen", "0", ""); std::vector vecCustData; @@ -1396,7 +1389,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_DoOnForeground_0100, TestSize.Level1) std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); Want want; ability_->DoOnForeground(want); @@ -1422,7 +1415,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_DoOnForeground_0200, TestSize.Level1) std::shared_ptr handler = std::make_shared(eventRunner); sptr token = nullptr; sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + auto abilityRecord = std::make_shared(abilityInfo, abilityToken, nullptr, 0); ability_->Init(abilityRecord, application, handler, token); Want want; ability_->DoOnForeground(want); @@ -1455,7 +1448,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_RegisterAbilityLifecycleObserver_0100, Fun // init UIAbility to make sure lifecycle is created. std::shared_ptr abilityInfo = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, nullptr); + auto abilityRecord = std::make_shared(abilityInfo, nullptr, nullptr, 0); std::shared_ptr handler = std::make_shared(nullptr); ability->Init(abilityRecord, nullptr, handler, nullptr); std::shared_ptr lifeCycle = ability->GetLifecycle(); diff --git a/test/unittest/frameworks_kits_ability_native_test/ui_ability_thread_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ui_ability_thread_test.cpp index d4373d913f..7e11ad8836 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ui_ability_thread_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ui_ability_thread_test.cpp @@ -74,8 +74,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_DumpAbilityInfo_0100, Function | Me EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); @@ -169,8 +168,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_ScheduleSaveAbilityState_0100, Func EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); abilitythread->ScheduleSaveAbilityState(); @@ -214,8 +212,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_ScheduleRestoreAbilityState_0100, F EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); PacMap state; @@ -260,8 +257,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_Attach_3_Param_0100, Function | Med EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); sleep(1); @@ -288,8 +284,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_Attach_3_Param_0200, Function | Med EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); sleep(1); @@ -316,8 +311,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_Attach_2_Param_0100, Function | Med EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); abilitythread->Attach(application, abilityRecord, nullptr); sleep(1); } @@ -343,8 +337,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_Attach_2_Param_0200, Function | Med EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = nullptr; - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, nullptr); sleep(1); @@ -371,8 +364,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_ScheduleAbilityTransaction_0100, Fu EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); Want want; @@ -402,8 +394,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_ScheduleAbilityTransaction_0200, Fu EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); abilitythread->Attach(application, abilityRecord, nullptr); Want want; LifeCycleStateInfo lifeCycleStateInfo; @@ -491,8 +482,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_SendResult_0100, Function | MediumT EXPECT_NE(token, nullptr); if (token != nullptr) { std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = - std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr abilityimpl = std::make_shared(); @@ -523,7 +513,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_SendResult_0200, Function | MediumT abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); int requestCode = 0; @@ -549,7 +539,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_SendResult_0300, Function | MediumT abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); auto application = std::make_shared(); - auto abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); abilitythread->abilityImpl_ = std::make_shared(); @@ -937,7 +927,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_CreateAndInitContextDeal_0100, Func abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); auto ret = abilitythread->CreateAndInitContextDeal(application, abilityRecord, nullptr); EXPECT_EQ(ret, nullptr); GTEST_LOG_(INFO) << "AbilityRuntime_CreateAndInitContextDeal_0100 end"; @@ -959,7 +949,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_CreateAndInitContextDeal_0200, Func abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr abilityObject = std::make_shared(); auto ret = abilitythread->CreateAndInitContextDeal(application, abilityRecord, abilityObject); EXPECT_NE(ret, nullptr); @@ -982,7 +972,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_CreateAndInitContextDeal_0300, Func abilityInfo->name = "MockPageAbility"; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr abilityObject = std::make_shared(); auto ret = abilitythread->CreateAndInitContextDeal(nullptr, abilityRecord, abilityObject); EXPECT_EQ(ret, nullptr); @@ -1026,7 +1016,7 @@ HWTEST_F(UIAbilityThreadTest, AbilityRuntime_Attach_0100, Function | MediumTest abilityInfo->name = ""; abilityInfo->type = AbilityType::PAGE; sptr token = sptr(new (std::nothrow) MockAbilityToken()); - std::shared_ptr abilityRecord = std::make_shared(abilityInfo, token); + auto abilityRecord = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr mainRunner = EventRunner::Create(abilityInfo->name); abilitythread->Attach(application, abilityRecord, mainRunner, nullptr); auto ret = abilitythread->CreateAbilityName(abilityRecord); diff --git a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn index dc59a98949..5cfe2335e5 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn @@ -115,6 +115,7 @@ ohos_unittest("application_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -174,6 +175,7 @@ ohos_unittest("context_impl_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:uiabilitykit_native", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", @@ -226,6 +228,7 @@ ohos_unittest("context_container_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -415,6 +418,7 @@ ohos_unittest("context_deal_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -473,6 +477,7 @@ ohos_unittest("application_impl_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_native_path}/appkit:appkit_native", @@ -609,6 +614,7 @@ ohos_unittest("form_extension_context_test") { "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_native_path}/ability/native:ability_thread", "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:configuration_helper", "${ability_runtime_native_path}/ability/native:form_extension", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:appkit_manager_helper", diff --git a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp index 9d2d792083..72e5cc57d4 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp @@ -143,7 +143,7 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_AddAbility_002, Function | Me GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 start"; sptr token = new (std::nothrow) MockToken(); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 111"; - abilityStage_->AddAbility(token, std::make_shared(nullptr, nullptr)); + abilityStage_->AddAbility(token, std::make_shared(nullptr, nullptr, nullptr, 0)); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 222"; EXPECT_TRUE(abilityStage_->ContainsAbility()); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 end"; @@ -160,7 +160,7 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_AddAbility_003, Function | Me { GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_003 start"; EXPECT_FALSE(abilityStage_->ContainsAbility()); - abilityStage_->AddAbility(nullptr, std::make_shared(nullptr, nullptr)); + abilityStage_->AddAbility(nullptr, std::make_shared(nullptr, nullptr, nullptr, 0)); EXPECT_FALSE(abilityStage_->ContainsAbility()); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_003 end"; } @@ -209,7 +209,7 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_RemoveAbility_002, Function | { GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_RemoveAbility_002 start"; sptr token = new MockToken(); - abilityStage_->AddAbility(token, std::make_shared(nullptr, nullptr)); + abilityStage_->AddAbility(token, std::make_shared(nullptr, nullptr, nullptr, 0)); EXPECT_TRUE(abilityStage_->ContainsAbility()); abilityStage_->RemoveAbility(token); EXPECT_FALSE(abilityStage_->ContainsAbility()); @@ -241,7 +241,7 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_ContainsAbility_002, Function { GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_ContainsAbility_002 start"; sptr token = new MockToken(); - abilityStage_->AddAbility(token, std::make_shared(nullptr, nullptr)); + abilityStage_->AddAbility(token, std::make_shared(nullptr, nullptr, nullptr, 0)); EXPECT_TRUE(abilityStage_->ContainsAbility()); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_ContainsAbility_002 end"; } diff --git a/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp b/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp index bdcd82d9da..f9ce763e4f 100644 --- a/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp +++ b/test/unittest/js_auto_fill_extension_test/js_auto_fill_extension_test.cpp @@ -89,7 +89,7 @@ void JsAutoFillExtensionTest::CreateJsAutoFillExtension() { std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr contextImpl = std::make_shared(); diff --git a/test/unittest/js_service_extension_test/js_service_extension_test.cpp b/test/unittest/js_service_extension_test/js_service_extension_test.cpp index 943437a609..b9f02ea8cc 100644 --- a/test/unittest/js_service_extension_test/js_service_extension_test.cpp +++ b/test/unittest/js_service_extension_test/js_service_extension_test.cpp @@ -91,7 +91,7 @@ void JsServiceExtensionTest::CreateJsServiceExtension() { std::shared_ptr abilityInfo = std::make_shared(); sptr token(new (std::nothrow) MockAbilityToken()); - std::shared_ptr record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr contextImpl = std::make_shared(); diff --git a/test/unittest/js_ui_service_extension_test/js_ui_service_extension_test.cpp b/test/unittest/js_ui_service_extension_test/js_ui_service_extension_test.cpp index 4a14933d8e..051393d22f 100644 --- a/test/unittest/js_ui_service_extension_test/js_ui_service_extension_test.cpp +++ b/test/unittest/js_ui_service_extension_test/js_ui_service_extension_test.cpp @@ -104,8 +104,7 @@ void JsUIServiceExtensionTest::SetUp() std::shared_ptr info = std::make_shared(); info->name = "JsUIServiceExtensionTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); diff --git a/test/unittest/photo_editor_extension_test/photo_editor_extension_test.cpp b/test/unittest/photo_editor_extension_test/photo_editor_extension_test.cpp index d4cb80b467..b66ddcd3b2 100644 --- a/test/unittest/photo_editor_extension_test/photo_editor_extension_test.cpp +++ b/test/unittest/photo_editor_extension_test/photo_editor_extension_test.cpp @@ -84,7 +84,7 @@ HWTEST_F(PhotoEditorExtensionTest, PhotoEditor_Extension_0300, Function | Medium GTEST_LOG_(INFO) << "PhotoEditor_Extension_0300 start"; auto abilityInfo = std::make_shared(); sptr token = new AppExecFwk::MockAbilityToken(); - auto record = std::make_shared(abilityInfo, token); + auto record = std::make_shared(abilityInfo, token, nullptr, 0); auto application = std::make_shared(); auto contextImpl = std::make_shared(); auto applicationContext = ApplicationContext::GetInstance(); diff --git a/test/unittest/ui_service_extension_test/ui_service_extension_test.cpp b/test/unittest/ui_service_extension_test/ui_service_extension_test.cpp index 693b051b1b..46ba7157f9 100644 --- a/test/unittest/ui_service_extension_test/ui_service_extension_test.cpp +++ b/test/unittest/ui_service_extension_test/ui_service_extension_test.cpp @@ -97,8 +97,7 @@ HWTEST_F(UIServiceExtensionTest, CreateAndInitContext_0100, TestSize.Level1) std::shared_ptr info = std::make_shared(); info->name = "UIServiceExtensionTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); @@ -125,8 +124,7 @@ HWTEST_F(UIServiceExtensionTest, Init_0100, TestSize.Level1) std::shared_ptr info = std::make_shared(); info->name = "UIServiceExtensionTest"; - std::shared_ptr record = - std::make_shared(info, nullptr); + auto record = std::make_shared(info, nullptr, nullptr, 0); std::shared_ptr application = std::make_shared(); std::shared_ptr handler = std::make_shared(nullptr); sptr token = new AppExecFwk::MockAbilityToken(); From 4eb00ef7d3d401ea361295710ca689a097d1503a Mon Sep 17 00:00:00 2001 From: wangzhen Date: Tue, 24 Sep 2024 15:52:04 +0800 Subject: [PATCH 19/26] Add comments for functions Signed-off-by: wangzhen Change-Id: Iae96bdfbedb6267570d67dd80d516efc28eade53 --- .../napi_ability_common/js_napi_common.cpp | 2 +- .../distributed_mission_manager.h | 2 +- .../continuation_register_manager.cpp | 2 +- .../remote_register_service_proxy.cpp | 2 +- .../include/ability_manager_client.h | 36 +-- .../include/ability_manager_interface.h | 144 ++++++++++- .../remote_register_service_interface.h | 2 +- .../include/appmgr/ams_mgr_interface.h | 69 ++++- .../include/appmgr/ams_mgr_proxy.h | 70 +++++- .../include/appmgr/app_mgr_client.h | 88 +++++-- .../include/appmgr/app_mgr_interface.h | 86 +++++-- .../include/appmgr/app_mgr_proxy.h | 70 +++++- .../include/appmgr/app_scheduler_interface.h | 27 ++ .../include/appmgr/app_scheduler_proxy.h | 58 +++++ .../appmgr/application_state_observer_proxy.h | 5 + .../appmgr/iapplication_state_observer.h | 5 + .../include/appmgr/irender_scheduler.h | 6 +- .../include/appmgr/irender_state_observer.h | 5 + .../istart_specified_ability_response.h | 11 + .../include/appmgr/render_scheduler_proxy.h | 6 +- .../appmgr/render_state_observer_proxy.h | 5 + .../start_specified_ability_response_proxy.h | 11 + .../app_manager/src/appmgr/app_mgr_client.cpp | 4 +- .../app_manager/src/appmgr/app_mgr_proxy.cpp | 4 +- .../app_manager/src/appmgr/app_mgr_stub.cpp | 4 +- .../continuation_register_manager.h | 2 +- .../remote_register_service_proxy.h | 2 +- .../include/ability_connect_manager.h | 6 +- .../include/ability_manager_proxy.h | 146 ++++++++++- .../include/ability_manager_service.h | 25 +- services/abilitymgr/include/ability_record.h | 10 +- services/abilitymgr/include/app_scheduler.h | 105 +++++++- services/abilitymgr/include/lifecycle_deal.h | 21 ++ .../include/resident_process_manager.h | 21 ++ .../src/ability_connect_manager.cpp | 2 +- .../src/ability_manager_service.cpp | 16 +- services/abilitymgr/src/ability_record.cpp | 2 +- .../appmgr/include/ability_running_record.h | 21 ++ services/appmgr/include/ams_mgr_scheduler.h | 89 ++++++- services/appmgr/include/app_lifecycle_deal.h | 51 +++- services/appmgr/include/app_mgr_service.h | 185 +++++++++++++- .../appmgr/include/app_mgr_service_inner.h | 235 +++++++++++++++++- services/appmgr/include/app_running_manager.h | 4 +- services/appmgr/include/app_running_record.h | 105 +++++++- .../include/exit_resident_process_manager.h | 2 +- services/appmgr/src/ams_mgr_scheduler.cpp | 2 +- services/appmgr/src/app_mgr_service.cpp | 4 +- services/appmgr/src/app_mgr_service_inner.cpp | 44 ++-- services/appmgr/src/app_running_manager.cpp | 12 +- services/appmgr/src/app_running_record.cpp | 20 +- .../src/exit_resident_process_manager.cpp | 2 +- .../include/appmgr/app_mgr_client.h | 4 +- .../include/appmgr/app_mgr_interface.h | 4 +- .../include/mock_app_mgr_service_inner.h | 2 +- .../ability_connect_manager_test.cpp | 2 +- .../ams_app_running_record_test.cpp | 6 +- .../ams_mgr_scheduler_second_test.cpp | 6 +- .../ams_mgr_scheduler_test.cpp | 6 +- .../app_mgr_client_test.cpp | 4 +- .../app_mgr_service_inner_test.cpp | 10 +- .../app_running_manager_second_test.cpp | 8 +- .../exit_resident_process_manager_test.cpp | 4 +- 62 files changed, 1695 insertions(+), 219 deletions(-) diff --git a/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp b/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp index a6727390b4..5549931254 100644 --- a/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp +++ b/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp @@ -1714,7 +1714,7 @@ void UvWorkOnAbilityDisconnectDone(uv_work_t *work, int status) (abilityName == obj.first.want.GetElement().GetAbilityName()); }); if (item != connects_.end()) { - // match deviceid & bundlename && abilityname + // match deviceId & bundlename && abilityname connects_.erase(item); TAG_LOGI(AAFwkTag::JSNAPI, "erase connects_.size:%{public}zu", connects_.size()); } diff --git a/frameworks/js/napi/mission_manager/distributed_mission_manager.h b/frameworks/js/napi/mission_manager/distributed_mission_manager.h index c5760591dd..a2195a3ae7 100644 --- a/frameworks/js/napi/mission_manager/distributed_mission_manager.h +++ b/frameworks/js/napi/mission_manager/distributed_mission_manager.h @@ -284,7 +284,7 @@ enum ErrorCode { */ MISSION_FOR_CONTINUING_IS_NOT_ALIVE = 29360224, /* - * Result(29360144) for get local deviceid fail. + * Result(29360144) for get local deviceId fail. */ GET_LOCAL_DEVICE_ERR = 29360144, /** diff --git a/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp b/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp index 2353301661..ec4792526f 100644 --- a/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp +++ b/frameworks/native/ability/native/continuation/remote_register_service/continuation_register_manager.cpp @@ -68,7 +68,7 @@ void ContinuationRegisterManager::Unregister(int token, const std::shared_ptr listener); /** - * @brief UnRegister mission listener from ams. + * @brief UnRegister mission listener from ability mgr. * @param listener The handler of listener. * * @return Returns ERR_OK on success, others on failure. @@ -773,8 +773,8 @@ public: ErrCode UnRegisterMissionListener(const std::string &deviceId, sptr listener); /** - * @brief Get mission infos from ams. - * @param deviceId local or remote deviceid. + * @brief Get mission infos from ability mgr. + * @param deviceId local or remote deviceId. * @param numMax max number of missions. * @param missionInfos mission info result. * @@ -784,9 +784,9 @@ public: /** * @brief Get mission info by id. - * @param deviceId local or remote deviceid. + * @param deviceId local or remote deviceId. * @param missionId Id of target mission. - * @param missionInfo mision info of target mission. + * @param missionInfo mission info of target mission. * * @return Returns ERR_OK on success, others on failure. */ @@ -794,7 +794,7 @@ public: /** * @brief Get the Mission Snapshot Info object - * @param deviceId local or remote deviceid. + * @param deviceId local or remote deviceId. * @param missionId Id of target mission. * @param snapshot snapshot of target mission. * @param isLowResolution get low resolution snapshot. @@ -1022,7 +1022,7 @@ public: * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. * * @param sessionInfo the session info of the ability to terminate. - * @param isPrepareTerminate the result of ability onPrepareToTermiante. + * @param isPrepareTerminate the result of ability onPrepareToTerminate. * @return Returns ERR_OK on success, others on failure. */ ErrCode PrepareTerminateAbilityBySCB(sptr sessionInfo, bool &isPrepareTerminate); @@ -1030,7 +1030,7 @@ public: /** * Set mission continue state of this ability. * - * @param token Indidate token of ability. + * @param token Indicate token of ability. * @param state the mission continuation state of this ability. * @return Returns ERR_OK if success. */ @@ -1041,8 +1041,8 @@ public: /** * Set mission label of this ability. * - * @param abilityToken Indidate token of ability. - * @param label Indidate the label showed of the ability in recent missions. + * @param abilityToken Indicate token of ability. + * @param label Indicate the label showed of the ability in recent missions. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetMissionLabel(sptr abilityToken, const std::string &label); @@ -1050,8 +1050,8 @@ public: /** * Set mission icon of this ability. * - * @param abilityToken Indidate token of ability. - * @param icon Indidate the icon showed of the ability in recent missions. + * @param abilityToken Indicate token of ability. + * @param icon Indicate the icon showed of the ability in recent missions. * @return Returns ERR_OK on success, others on failure. */ ErrCode SetMissionIcon(sptr abilityToken, @@ -1060,7 +1060,7 @@ public: /** * Register the WindowManagerService handler * - * @param handler Indidate handler of WindowManagerService. + * @param handler Indicate handler of WindowManagerService. * @return ErrCode Returns ERR_OK on success, others on failure. */ ErrCode RegisterWindowManagerServiceHandler(sptr handler, @@ -1069,14 +1069,14 @@ public: /** * WindowManager notification AbilityManager after the first frame is drawn. * - * @param abilityToken Indidate token of ability. + * @param abilityToken Indicate token of ability. */ void CompleteFirstFrameDrawing(sptr abilityToken); /** * WindowManager notification AbilityManager after the first frame is drawn. * - * @param sessionId Indidate session id. + * @param sessionId Indicate session id. */ void CompleteFirstFrameDrawing(int32_t sessionId); diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 386f4834e2..112a2a4db0 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -863,36 +863,108 @@ public: return; } + /** + * @brief Register mission listener to ability mgr. + * @param listener The handler of listener. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int RegisterMissionListener(const sptr &listener) = 0; + /** + * @brief UnRegister mission listener from ability mgr. + * @param listener The handler of listener. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int UnRegisterMissionListener(const sptr &listener) = 0; + /** + * @brief Get mission infos from ability mgr. + * @param deviceId local or remote deviceId. + * @param numMax max number of missions. + * @param missionInfos mission info result. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetMissionInfos( const std::string &deviceId, int32_t numMax, std::vector &missionInfos) = 0; + /** + * @brief Get mission info by id. + * @param deviceId local or remote deviceId. + * @param missionId Id of target mission. + * @param missionInfo mission info of target mission. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetMissionInfo(const std::string &deviceId, int32_t missionId, MissionInfo &missionInfo) = 0; + /** + * @brief Get the Mission Snapshot Info object + * @param deviceId local or remote deviceId. + * @param missionId Id of target mission. + * @param snapshot snapshot of target mission. + * @param isLowResolution get low resolution snapshot. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot, bool isLowResolution) = 0; + /** + * @brief Clean mission by id. + * @param missionId Id of target mission. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int CleanMission(int32_t missionId) = 0; + /** + * @brief Clean all missions in system. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int CleanAllMissions() = 0; virtual int MoveMissionToFront(int32_t missionId) = 0; + /** + * @brief Move a mission to front. + * @param missionId Id of target mission. + * @param startOptions Special startOptions for target mission. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) = 0; + /** + * Move missions to front + * @param missionIds Ids of target missions + * @param topMissionId Indicate which mission will be moved to top, if set to -1, missions' order won't change + * @return Returns ERR_OK on success, others on failure. + */ virtual int MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) { return 0; } + /** + * Move missions to background + * @param missionIds Ids of target missions + * @param result The result of move missions to background, and the array is sorted by zOrder + * @return Returns ERR_OK on success, others on failure. + */ virtual int MoveMissionsToBackground(const std::vector& missionIds, std::vector& result) { return 0; } + /** + * @brief Register session handler. + * @param object The handler. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int RegisterSessionHandler(const sptr &object) { return 0; @@ -925,10 +997,29 @@ public: */ virtual int ReleaseCall(const sptr &connect, const AppExecFwk::ElementName &element) = 0; + /** + * @brief start user. + * @param accountId accountId. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int StartUser(int userId, sptr callback) = 0; + /** + * @brief stop user. + * @param accountId accountId. + * @param callback callback. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int StopUser(int userId, const sptr &callback) = 0; + /** + * @brief logout user. + * @param accountId accountId. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int LogoutUser(int32_t userId) { return 0; @@ -956,7 +1047,7 @@ public: /** * Register the WindowManagerService handler * - * @param handler Indidate handler of WindowManagerService. + * @param handler Indicate handler of WindowManagerService. * @return ErrCode Returns ERR_OK on success, others on failure. */ virtual int RegisterWindowManagerServiceHandler(const sptr& handler, @@ -968,14 +1059,14 @@ public: /** * WindowManager notification AbilityManager after the first frame is drawn. * - * @param abilityToken Indidate token of ability. + * @param abilityToken Indicate token of ability. */ virtual void CompleteFirstFrameDrawing(const sptr &abilityToken) = 0; /** * WindowManager notification AbilityManager after the first frame is drawn. * - * @param sessionId Indidate session id. + * @param sessionId Indicate session id. */ virtual void CompleteFirstFrameDrawing(int32_t sessionId) {} @@ -1025,11 +1116,29 @@ public: } #endif - + /** + * @brief Get the ability running information. + * + * @param info Ability running information. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetAbilityRunningInfos(std::vector &info) = 0; + /** + * @brief Get the extension running information. + * + * @param upperLimit The maximum limit of information wish to get. + * @param info Extension running information. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetExtensionRunningInfos(int upperLimit, std::vector &info) = 0; + /** + * @brief Get running process information. + * + * @param info Running process information. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetProcessRunningInfos(std::vector &info) = 0; /** @@ -1048,6 +1157,13 @@ public: */ virtual int StopSyncRemoteMissions(const std::string &devId) = 0; + /** + * @brief Register mission listener to ability manager service. + * @param deviceId The remote device Id. + * @param listener The handler of listener. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int RegisterMissionListener(const std::string &deviceId, const sptr &listener) = 0; virtual int RegisterOnListener(const std::string &type, const sptr &listener) @@ -1086,8 +1202,23 @@ public: */ virtual int RegisterSnapshotHandler(const sptr& handler) = 0; + /** + * @brief start user test. + * @param want the want of the ability user test to start. + * @param observer test observer callback. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int StartUserTest(const Want &want, const sptr &observer) = 0; + /** + * @brief Finish user test. + * @param msg user test message. + * @param resultCode user test result Code. + * @param bundleName user test bundleName. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName) = 0; /** @@ -1197,6 +1328,11 @@ public: virtual void ScheduleRecoverAbility(const sptr &token, int32_t reason, const Want *want = nullptr) {}; + /** + * @brief Schedule clear recovery page stack. + * + * @param bundleName application bundleName. + */ virtual void ScheduleClearRecoveryPageStack() {}; /** diff --git a/interfaces/inner_api/ability_manager/include/continuation/remote_register_service_interface.h b/interfaces/inner_api/ability_manager/include/continuation/remote_register_service_interface.h index 7346d4b6e7..ad05df1d87 100644 --- a/interfaces/inner_api/ability_manager/include/continuation/remote_register_service_interface.h +++ b/interfaces/inner_api/ability_manager/include/continuation/remote_register_service_interface.h @@ -52,7 +52,7 @@ public: * notify continuation status to controlcenter continuation register service. * * @param registerToken token from register. - * @param deviceId deviceid. + * @param deviceId deviceId. * @param status device status. */ virtual bool UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) = 0; diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h index ee2036054d..2acce57ba4 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h @@ -103,8 +103,19 @@ public: */ virtual void KillProcessesByUserId(int32_t userId) = 0; + /** + * KillProcessesByPids, only in process call is allowed, + * kill the processes by pid list given. + * + * @param pids, the pid list of processes are going to be killed. + */ virtual void KillProcessesByPids(std::vector &pids) {} + /** + * Set child and parent relationship + * @param token child process + * @param callerToken parent process + */ virtual void AttachPidToParent(const sptr &token, const sptr &callerToken) {} /** @@ -174,23 +185,73 @@ public: return ERR_OK; } + /** + * Ability attach timeout. If start ability encounter failure, attach timeout to terminate. + * + * @param token Ability identify. + */ virtual void AbilityAttachTimeOut(const sptr &token) = 0; + /** + * Prepare terminate. + * + * @param token Ability identify. + * @param clearMissionFlag Clear mission flag. + */ virtual void PrepareTerminate(const sptr &token, bool clearMissionFlag = false) = 0; + /** + * Get running process information by ability token. + * + * @param token Ability identify. + * @param info Running process info. + */ virtual void GetRunningProcessInfoByToken( const sptr &token, OHOS::AppExecFwk::RunningProcessInfo &info) = 0; + /** + * Set AbilityForegroundingFlag of an app-record to true. + * + * @param pid, pid. + * + */ virtual void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) = 0; + /** + * Start specified ability. + * + * @param want Want contains information of the ability to start. + * @param abilityInfo Ability information. + * @param requestId request id to callback + */ virtual void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) = 0; + /** + * Register response of start specified ability. + * + * @param response Response of start specified ability. + */ virtual void RegisterStartSpecifiedAbilityResponse(const sptr &response) = 0; + /** + * Start specified process. + * + * @param want Want contains information wish to start. + * @param abilityInfo Ability information. + * @param requestId for callback + */ virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) = 0; + /** + * Get application info by process id. + * + * @param pid Process id. + * @param application Application information got. + * @param debug Whether IsDebugApp. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) = 0; /** @@ -307,6 +368,7 @@ public: * @brief Set resident process enable status. * @param bundleName The application bundle name. * @param enable The current updated enable status. + * @param uid indicates user, 0 for all users */ virtual void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) {}; @@ -318,8 +380,8 @@ public: virtual void ClearProcessByToken(sptr token) {} /** - * whether memory size is sufficent. - * @return Returns true is sufficent memory size, others return false. + * whether memory size is sufficient. + * @return Returns true is sufficient memory size, others return false. */ virtual bool IsMemorySizeSufficent() = 0; @@ -368,6 +430,9 @@ public: return false; } + /** + * Whether a process is attached, refer to AttachApplication + */ virtual bool IsProcessAttached(sptr token) { return false; diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h index 745d101432..86a94f4b82 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h @@ -93,8 +93,19 @@ public: */ virtual void KillProcessesByUserId(int32_t userId) override; + /** + * KillProcessesByPids, only in process call is allowed, + * kill the processes by pid list given. + * + * @param pids, the pid list of processes are going to be killed. + */ virtual void KillProcessesByPids(std::vector &pids) override; + /** + * Set child and parent relationship + * @param token child process + * @param callerToken parent process + */ virtual void AttachPidToParent(const sptr &token, const sptr &callerToken) override; /** @@ -157,15 +168,47 @@ public: virtual int KillApplicationSelf(const bool clearPageStack = false) override; + /** + * Get application info by process id. + * + * @param pid Process id. + * @param application Application information got. + * @param debug Whether IsDebugApp. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) override; + /** + * Record process exit reason to appRunningRecord + * @param pid pid + * @param reason reason enum + * @param exitMsg exitMsg + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) override; + /** + * Ability attach timeout. If start ability encounter failure, attach timeout to terminate. + * + * @param token Ability identify. + */ virtual void AbilityAttachTimeOut(const sptr &token) override; + /** + * Prepare terminate. + * + * @param token Ability identify. + * @param clearMissionFlag Clear mission flag. + */ virtual void PrepareTerminate(const sptr &token, bool clearMissionFlag = false) override; + /** + * Get running process information by ability token. + * + * @param token Ability identify. + * @param info Running process info. + */ void GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info) override; /** @@ -176,11 +219,30 @@ public: */ void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) override; + /** + * Start specified ability. + * + * @param want Want contains information of the ability to start. + * @param abilityInfo Ability information. + * @param requestId request id to callback + */ virtual void StartSpecifiedAbility( const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override; + /** + * Register response of start specified ability. + * + * @param response Response of start specified ability. + */ virtual void RegisterStartSpecifiedAbilityResponse(const sptr &response) override; + /** + * Start specified process. + * + * @param want Want contains information wish to start. + * @param abilityInfo Ability information. + * @param requestId for callback + */ virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override; @@ -268,6 +330,7 @@ public: * @brief Set resident process enable status. * @param bundleName The application bundle name. * @param enable The current updated enable status. + * @param uid indicates user, 0 for all users */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) override; @@ -279,8 +342,8 @@ public: virtual void ClearProcessByToken(sptr token) override; /** - * whether memory size is sufficent. - * @return Returns true is sufficent memory size, others return false. + * whether memory size is sufficient. + * @return Returns true is sufficient memory size, others return false. */ virtual bool IsMemorySizeSufficent() override; @@ -320,6 +383,9 @@ public: */ virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override; + /** + * Whether a process is attached, refer to AttachApplication + */ virtual bool IsProcessAttached(sptr token) override; virtual bool IsAppKilling(sptr token) override; diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index 7aefcf17b9..52a2e5a3a5 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -126,8 +126,19 @@ public: */ virtual AppMgrResultCode KillProcessesByUserId(int32_t userId); + /** + * KillProcessesByPids, only in process call is allowed, + * kill the processes by pid list given. + * + * @param pids, the pid list of processes are going to be killed. + */ virtual AppMgrResultCode KillProcessesByPids(std::vector &pids); + /** + * Set child and parent relationship + * @param token child process + * @param callerToken parent process + */ virtual AppMgrResultCode AttachPidToParent(const sptr &token, const sptr &callerToken); @@ -236,10 +247,10 @@ public: /** * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. - * Obtains running isntance keys of multi-instance app that are running on the device. + * Obtains running instance keys of multi-instance app that are running on the device. * * @param bundlename, bundle name in Application record. - * @param instanceKeys, output instance keys of the multi-insatnce app. + * @param instanceKeys, output instance keys of the multi-instance app. * @return ERR_OK ,return back success,others fail. */ virtual AppMgrResultCode GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, @@ -303,7 +314,7 @@ public: /** * GetConfiguration * - * @param info, configuration. + * @param info to retrieve configuration data. * @return ERR_OK ,return back success,others fail. */ virtual AppMgrResultCode GetConfiguration(Configuration& config); @@ -362,7 +373,7 @@ public: /** * Update config by bundle name. * - * @param config Application enviroment change parameters. + * @param config Application environment change parameters. * @param name Application bundle name. * @return Returns ERR_OK on success, others on failure. */ @@ -403,8 +414,9 @@ public: /** * Start specified ability. * - * @param want Want contains information wish to start. + * @param want Want contains information of the ability to start. * @param abilityInfo Ability information. + * @param requestId request id to callback */ virtual void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0); @@ -421,6 +433,7 @@ public: * * @param want Want contains information wish to start. * @param abilityInfo Ability information. + * @param requestId for callback */ virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0); @@ -453,10 +466,10 @@ public: /** * Start nweb render process, called by nweb host. * - * @param renderParam, params passed to renderprocess. - * @param ipcFd, ipc file descriptior for web browser and render process. - * @param sharedFd, shared memory file descriptior. - * @param crashFd, crash signal file descriptior. + * @param renderParam, params passed to renderProcess. + * @param ipcFd, ipc file descriptor for web browser and render process. + * @param sharedFd, shared memory file descriptor. + * @param crashFd, crash signal file descriptor. * @param renderPid, created render pid. * @return Returns ERR_OK on success, others on failure. */ @@ -465,7 +478,7 @@ public: int32_t crashFd, pid_t &renderPid, bool isGPU = false); /** - * Render process call this to attach app manager service. + * Render process call this to attach to app manager service. * * @param renderScheduler, scheduler of render process. */ @@ -491,12 +504,9 @@ public: int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug); /** - * Get application info by process id. + * start native process for debugger. * - * @param pid Process id. - * @param application Application information got. - * @param debug Whether IsDebugApp. - * @return Returns ERR_OK on success, others on failure. + * @param want param to start a process. */ int32_t StartNativeProcessForDebugger(const AAFwk::Want &want); @@ -646,6 +656,7 @@ public: * @brief Set resident process enable status. * @param bundleName The application bundle name. * @param enable The current updated enable status. + * @param uid indicates user, 0 for all users */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid); @@ -711,12 +722,34 @@ public: */ bool IsFinalAppProcess(); + /** + * Register render state observer. + * @param observer Render process state observer. + * @return Returns ERR_OK on success, others on failure. + */ int32_t RegisterRenderStateObserver(const sptr &observer); + /** + * Unregister render state observer. + * @param observer Render process state observer. + * @return Returns ERR_OK on success, others on failure. + */ int32_t UnregisterRenderStateObserver(const sptr &observer); + /** + * Update render state. + * @param renderPid Render pid. + * @param state foreground or background state. + * @return Returns ERR_OK on success, others on failure. + */ int32_t UpdateRenderState(pid_t renderPid, int32_t state); + /** + * Get appRunningUniqueId by pid. + * @param pid pid. + * @param appRunningUniqueId appRunningUniqueId. + * @return Returns ERR_OK on success, others on failure. + */ int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId); /** @@ -738,15 +771,15 @@ public: int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector &providerPids); /** - * @brief Notify memory size state changed to sufficient or insufficent. - * @param isMemorySizeSufficent Indicates the memory size state. + * @brief Notify memory size state changed to sufficient or insufficient. + * @param isMemorySizeSufficient Indicates the memory size state. * @return Returns ERR_OK on success, others on failure. */ - int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent); + int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient); /** - * whether memory size is sufficent. - * @return Returns true is sufficent memory size, others return false. + * whether memory size is sufficient. + * @return Returns true is sufficient memory size, others return false. */ bool IsMemorySizeSufficent() const; @@ -771,10 +804,16 @@ public: virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId, AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0); + /** + * @brief set support process cache by self + */ int32_t SetSupportedProcessCacheSelf(bool isSupport); int32_t SetSupportedProcessCache(int32_t pid, bool isSupport); + /** + * set browser channel for caller + */ void SaveBrowserChannel(sptr browser); /** @@ -793,8 +832,14 @@ public: */ virtual AppMgrResultCode AttachedToStatusBar(const sptr &token); + /** + * Notify that the process depends on web by itself. + */ int32_t NotifyProcessDependedOnWeb(); + /** + * Kill process depended on web by sa. + */ void KillProcessDependedOnWeb(); /** @@ -826,6 +871,9 @@ public: */ bool IsProcessContainsOnlyUIAbility(const pid_t pid); + /** + * Whether a process is attached, refer to AttachApplication + */ bool IsProcessAttached(sptr token) const; bool IsAppKilling(sptr token) const; diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index ba13c3b721..c76c56ce84 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -160,10 +160,10 @@ public: /** * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. - * Obtains running isntance keys of multi-instance app that are running on the device. + * Obtains running instance keys of multi-instance app that are running on the device. * * @param bundlename, bundle name in Application record. - * @param instanceKeys, output instance keys of the multi-insatnce app. + * @param instanceKeys, output instance keys of the multi-instance app. * @return ERR_OK ,return back success,others fail. */ virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, @@ -332,6 +332,13 @@ public: */ virtual int FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName) = 0; + /** + * Schedule accept want done. + * + * @param recordId Application record. + * @param want Want. + * @param flag flag get from OnAcceptWant. + */ virtual void ScheduleAcceptWantDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag) = 0; virtual void ScheduleNewProcessRequestDone(const int32_t recordId, const AAFwk::Want &want, @@ -356,10 +363,10 @@ public: /** * Start nweb render process, called by nweb host. * - * @param renderParam, params passed to renderprocess. - * @param ipcFd, ipc file descriptior for web browser and render process. - * @param sharedFd, shared memory file descriptior. - * @param crashFd, crash signal file descriptior. + * @param renderParam, params passed to renderProcess. + * @param ipcFd, ipc file descriptor for web browser and render process. + * @param sharedFd, shared memory file descriptor. + * @param crashFd, crash signal file descriptor. * @param renderPid, created render pid. * @param isGPU, is or not gpu process * @return Returns ERR_OK on success, others on failure. @@ -384,14 +391,46 @@ public: */ virtual int GetRenderProcessTerminationStatus(pid_t renderPid, int &status) = 0; + /** + * GetConfiguration + * + * @param info to retrieve configuration data. + * @return ERR_OK ,return back success,others fail. + */ virtual int32_t GetConfiguration(Configuration& config) = 0; + /** + * UpdateConfiguration, ANotify application update system environment changes. + * + * @param config System environment change parameters. + * @param userId configuration for the user + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t UpdateConfiguration(const Configuration &config, const int32_t userId = -1) = 0; + /** + * Update config by bundle name. + * + * @param config Application environment change parameters. + * @param name Application bundle name. + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name) = 0; + /** + * Register configuration observer. + * + * @param observer Configuration observer. When configuration changed, observer will be called. + * @return Returns RESULT_OK on success, others on failure. + */ virtual int32_t RegisterConfigurationObserver(const sptr &observer) = 0; + /** + * Unregister configuration observer. + * + * @param observer Configuration observer. + * @return Returns RESULT_OK on success, others on failure. + */ virtual int32_t UnregisterConfigurationObserver(const sptr &observer) = 0; /** @@ -407,7 +446,7 @@ public: * * @param bundleName Bundle name * @param callback called when LoadPatch finished. - * @return Returns 0 on success, error code on failure. + * @return Returns ERR_OK on success, error code on failure. */ virtual int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback) = 0; @@ -416,7 +455,7 @@ public: * * @param bundleName Bundle name * @param callback called when HotReload finished. - * @return Returns 0 on success, error code on failure. + * @return Returns ERR_OK on success, error code on failure. */ virtual int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr &callback) = 0; @@ -425,7 +464,7 @@ public: * * @param bundleName Bundle name * @param callback called when UnloadPatch finished. - * @return Returns 0 on success, error code on failure. + * @return Returns ERR_OK on success, error code on failure. */ virtual int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr &callback) = 0; @@ -476,6 +515,11 @@ public: */ virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode) = 0; + /** + * start native process for debugger. + * + * @param want param to start a process. + */ virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) = 0; /** @@ -673,6 +717,12 @@ public: */ virtual int32_t UpdateRenderState(pid_t renderPid, int32_t state) = 0; + /** + * @brief mark a process which is going restart. + * @param bundleName the bundleName of the process. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t SignRestartAppFlag(const std::string &bundleName) { return 0; @@ -694,7 +744,7 @@ public: * If specified pid mismatch UIExtensionAbility type, return empty vector. * @param pid Process id. * @param hostPids All host process id. - * @return Returns 0 on success, others on failure. + * @return Returns ERR_OK on success, others on failure. */ virtual int32_t GetAllUIExtensionRootHostPid(pid_t pid, std::vector &hostPids) { @@ -706,7 +756,7 @@ public: * If specified hostPid didn't start any UIExtensionAbility, return empty vector. * @param hostPid Host process id. * @param providerPids All provider process id started by specified hostPid. - * @return Returns 0 on success, others on failure. + * @return Returns ERR_OK on success, others on failure. */ virtual int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector &providerPids) { @@ -714,17 +764,20 @@ public: } /** - * @brief Notify memory size state changed to sufficient or insufficent. - * @param isMemorySizeSufficent Indicates the memory size state. + * @brief Notify memory size state changed to sufficient or insufficient. + * @param isMemorySizeSufficient Indicates the memory size state. * @return Returns ERR_OK on success, others on failure. */ - virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) + virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) { return 0; } + /** + * @brief set support process cache by self + */ virtual int32_t SetSupportedProcessCacheSelf(bool isSupport) = 0; - + virtual int32_t SetSupportedProcessCache(int32_t pid, bool isSupport) = 0; /** @@ -744,6 +797,9 @@ public: virtual int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, const sptr &callback) = 0; + /** + * set browser channel for caller + */ virtual void SaveBrowserChannel(sptr browser) = 0; /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index cae03fc441..c016732a40 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -137,10 +137,10 @@ public: /** * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. - * Obtains running isntance keys of multi-instance app that are running on the device. + * Obtains running instance keys of multi-instance app that are running on the device. * * @param bundlename, bundle name in Application record. - * @param instanceKeys, output instance keys of the multi-insatnce app. + * @param instanceKeys, output instance keys of the multi-instance app. * @return ERR_OK ,return back success,others fail. */ virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, @@ -309,6 +309,13 @@ public: virtual int FinishUserTest( const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override; + /** + * Schedule accept want done. + * + * @param recordId Application record. + * @param want Want. + * @param flag flag get from OnAcceptWant. + */ virtual void ScheduleAcceptWantDone( const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override; @@ -334,10 +341,10 @@ public: /** * Start nweb render process, called by nweb host. * - * @param renderParam, params passed to renderprocess. - * @param ipcFd, ipc file descriptior for web browser and render process. - * @param sharedFd, shared memory file descriptior. - * @param crashFd, crash signal file descriptior. + * @param renderParam, params passed to renderProcess. + * @param ipcFd, ipc file descriptor for web browser and render process. + * @param sharedFd, shared memory file descriptor. + * @param crashFd, crash signal file descriptor. * @param renderPid, created render pid. * @param isGPU, is or not GPU process * @return Returns ERR_OK on success, others on failure. @@ -396,8 +403,21 @@ public: virtual int32_t UnregisterConfigurationObserver(const sptr &observer) override; + /** + * @brief Get the running state of application by bundle name. + * + * @param bundleName Bundle name + * @return Returns true if process is running, false if process isn't running. + */ bool GetAppRunningStateByBundleName(const std::string &bundleName) override; + /** + * @brief Notify application load patch. + * + * @param bundleName Bundle name + * @param callback called when LoadPatch finished. + * @return Returns ERR_OK on success, error code on failure. + */ int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback) override; int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr &callback) override; @@ -417,6 +437,11 @@ public: */ virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode) override; + /** + * start native process for debugger. + * + * @param want param to start a process. + */ virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) override; /** @@ -603,8 +628,20 @@ public: */ virtual int32_t UpdateRenderState(pid_t renderPid, int32_t state) override; + /** + * @brief mark a process which is going restart. + * @param bundleName the bundleName of the process. + * + * @return Returns ERR_OK on success, others on failure. + */ int32_t SignRestartAppFlag(const std::string &bundleName) override; + /** + * Get appRunningUniqueId by pid. + * @param pid pid. + * @param appRunningUniqueId appRunningUniqueId. + * @return Returns ERR_OK on success, others on failure. + */ int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId) override; /* @@ -626,11 +663,11 @@ public: int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector &providerPids) override; /** - * @brief Notify memory size state changed to sufficient or insufficent. - * @param isMemorySizeSufficent Indicates the memory size state. + * @brief Notify memory size state changed to sufficient or insufficient. + * @param isMemorySizeSufficient Indicates the memory size state. * @return Returns ERR_OK on success, others on failure. */ - virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; + virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) override; /** * Set application assertion pause state. @@ -639,10 +676,16 @@ public: */ void SetAppAssertionPauseState(bool flag) override; + /** + * @brief set support process cache by self + */ int32_t SetSupportedProcessCacheSelf(bool isSupport) override; int32_t SetSupportedProcessCache(int32_t pid, bool isSupport) override; + /** + * set browser channel for caller + */ virtual void SaveBrowserChannel(sptr browser) override; /** @@ -663,10 +706,19 @@ public: int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, const sptr &callback) override; + /** + * Notify that the process depends on web by itself. + */ virtual int32_t NotifyProcessDependedOnWeb() override; + /** + * Kill process depended on web by sa. + */ virtual void KillProcessDependedOnWeb() override; + /** + * Restart resident process depended on web. + */ virtual void RestartResidentProcessDependedOnWeb() override; /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h index 3fe83c0cdb..71176612d9 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h @@ -134,6 +134,14 @@ public: */ virtual void ScheduleAbilityStage(const HapModuleInfo &) = 0; + /** + * Notify application to launch ability. + * + * @param ability The ability info. + * @param token The ability token. + * @param want The want to start the ability. + * @param token The ability token. + */ virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr &, const std::shared_ptr &want, int32_t abilityRecordId) = 0; @@ -172,8 +180,19 @@ public: */ virtual void ScheduleProcessSecurityExit() = 0; + /** + * scheduleClearPageStack, call scheduleClearPageStack() through proxy project, + * Notify application clear recovery page stack. + * + */ virtual void ScheduleClearPageStack() = 0; + /** + * @brief Schedule the given module the onAcceptWant lifecycle call. + * + * @param want the param passed to onAcceptWant lifecycle. + * @param want the moduleName of which being scheduled. + */ virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) = 0; virtual void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) = 0; @@ -183,6 +202,7 @@ public: * * @param bundleName Bundle name * @param callback called when LoadPatch finished. + * @param recordId callback data * @return Returns 0 on success, error code on failure. */ virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName, @@ -192,6 +212,7 @@ public: * @brief Notify application reload page. * * @param callback called when HotReload finished. + * @param recordId callback data * @return Returns 0 on success, error code on failure. */ virtual int32_t ScheduleNotifyHotReloadPage(const sptr &callback, const int32_t recordId) = 0; @@ -201,6 +222,7 @@ public: * * @param bundleName Bundle name * @param callback called when UnloadPatch finished. + * @param recordId callback data * @return Returns 0 on success, error code on failure. */ virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName, @@ -264,6 +286,11 @@ public: */ virtual int32_t ScheduleDumpIpcStat(std::string& result) = 0; + /** + * + * @brief Notify application to prepare for process caching. + * + */ virtual void ScheduleCacheProcess() = 0; /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h index d05892069e..ed481f8222 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h @@ -173,25 +173,80 @@ public: */ virtual void ScheduleProcessSecurityExit() override; + /** + * scheduleClearPageStack, call scheduleClearPageStack() through proxy project, + * Notify application clear recovery page stack. + * + */ virtual void ScheduleClearPageStack() override; + /** + * @brief Schedule the given module the onAcceptWant lifecycle call. + * + * @param want the param passed to onAcceptWant lifecycle. + * @param want the moduleName of which being scheduled. + */ virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override; virtual void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) override; + /** + * @brief Notify application load patch. + * + * @param bundleName Bundle name + * @param callback called when LoadPatch finished. + * @param recordId callback data + * @return Returns 0 on success, error code on failure. + */ int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback, const int32_t recordId) override; + /** + * @brief Notify application reload page. + * + * @param callback called when HotReload finished. + * @param recordId callback data + * @return Returns 0 on success, error code on failure. + */ int32_t ScheduleNotifyHotReloadPage(const sptr &callback, const int32_t recordId) override; + /** + * @brief Notify application unload patch. + * + * @param bundleName Bundle name + * @param callback called when UnloadPatch finished. + * @param recordId callback data + * @return Returns 0 on success, error code on failure. + */ int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName, const sptr &callback, const int32_t recordId) override; + /** + * @brief Schedule Notify App Fault Data. + * + * @param faultData fault data + * @return Returns ERR_OK on success, error code on failure. + */ int32_t ScheduleNotifyAppFault(const FaultData &faultData) override; + /** + * @brief Notify NativeEngine GC of status change. + * + * @param state GC state + * @param pid pid + * + * @return Is the status change completed. + */ virtual int32_t ScheduleChangeAppGcState(int32_t state) override; + /** + * @brief Attach app debug. + */ void AttachAppDebug() override; + + /** + * @brief Detach app debug. + */ void DetachAppDebug() override; /** @@ -224,6 +279,9 @@ public: */ virtual int32_t ScheduleDumpIpcStat(std::string& result) override; + /** + * @brief Notify application to prepare for process caching. + */ virtual void ScheduleCacheProcess() override; /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/application_state_observer_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/application_state_observer_proxy.h index 8347143e64..3ddf984b05 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/application_state_observer_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/application_state_observer_proxy.h @@ -100,6 +100,11 @@ public: */ virtual void OnAppStateChanged(const AppStateData &appStateData) override; + /** + * Called when one process is reused. + * + * @param processData Process data. + */ virtual void OnProcessReused(const ProcessData &processData) override; /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/iapplication_state_observer.h b/interfaces/inner_api/app_manager/include/appmgr/iapplication_state_observer.h index b65fd55126..71a415efb0 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/iapplication_state_observer.h +++ b/interfaces/inner_api/app_manager/include/appmgr/iapplication_state_observer.h @@ -101,6 +101,11 @@ public: */ virtual void OnAppStateChanged(const AppStateData &appStateData) {} + /** + * Called when one process is reused. + * + * @param processData Process data. + */ virtual void OnProcessReused(const ProcessData &processData) {} /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h b/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h index 35c114587a..9e22fc9d83 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h +++ b/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h @@ -31,9 +31,9 @@ public: /** * Notify Browser's fd to render process. * - * @param ipcFd, ipc file descriptior for web browser and render process. - * @param sharedFd, shared memory file descriptior. - * @param crashFd, crash signal file descriptior. + * @param ipcFd, ipc file descriptor for web browser and render process. + * @param sharedFd, shared memory file descriptor. + * @param crashFd, crash signal file descriptor. */ virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, int32_t crashFd, sptr browser) = 0; diff --git a/interfaces/inner_api/app_manager/include/appmgr/irender_state_observer.h b/interfaces/inner_api/app_manager/include/appmgr/irender_state_observer.h index 8095479678..e1c64c8d34 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/irender_state_observer.h +++ b/interfaces/inner_api/app_manager/include/appmgr/irender_state_observer.h @@ -25,6 +25,11 @@ class IRenderStateObserver : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IRenderStateObserver"); + /** + * Called when one render process's state changes. + * + * @param renderStateData retrieved state data. + */ virtual void OnRenderStateChanged(const RenderStateData &renderStateData) = 0; enum { diff --git a/interfaces/inner_api/app_manager/include/appmgr/istart_specified_ability_response.h b/interfaces/inner_api/app_manager/include/appmgr/istart_specified_ability_response.h index a8327e41f4..0a36cea2a7 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/istart_specified_ability_response.h +++ b/interfaces/inner_api/app_manager/include/appmgr/istart_specified_ability_response.h @@ -26,8 +26,19 @@ class IStartSpecifiedAbilityResponse : public IRemoteBroker { public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.startSpecifiedAbilityResponse"); + /** + * @brief called when the module's onAcceptWant done to notify ability mgr to continue + * @param want request param being accepted + * @param flag specified flag return by application + * @param requestId a number represents a request + */ virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, int32_t requestId) = 0; + /** + * @brief called when the module's onAcceptWant happens time out + * @param want request param + * @param requestId a number represents a request + */ virtual void OnTimeoutResponse(const AAFwk::Want &want, int32_t requestId) = 0; virtual void OnNewProcessRequestResponse(const AAFwk::Want &want, const std::string &flag, diff --git a/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h index 5465ad97b8..46204b5b45 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h @@ -35,9 +35,9 @@ public: /** * Notify Browser's fd to render process. * - * @param ipcFd, ipc file descriptior for web browser and render process. - * @param sharedFd, shared memory file descriptior. - * @param crashFd, crash signal file descriptior. + * @param ipcFd, ipc file descriptor for web browser and render process. + * @param sharedFd, shared memory file descriptor. + * @param crashFd, crash signal file descriptor. */ virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, int32_t crashFd, sptr browser) override; diff --git a/interfaces/inner_api/app_manager/include/appmgr/render_state_observer_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/render_state_observer_proxy.h index d34302df03..024f708222 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/render_state_observer_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/render_state_observer_proxy.h @@ -26,6 +26,11 @@ public: explicit RenderStateObserverProxy(const sptr &impl); virtual ~RenderStateObserverProxy() = default; + /** + * Called when one render process's state changes. + * + * @param renderStateData retrieved state data. + */ virtual void OnRenderStateChanged(const RenderStateData &renderStateData) override; private: bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_proxy.h index c9b72bfe99..b62cea6940 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/start_specified_ability_response_proxy.h @@ -25,9 +25,20 @@ public: explicit StartSpecifiedAbilityResponseProxy(const sptr &impl); virtual ~StartSpecifiedAbilityResponseProxy() = default; + /** + * @brief called when the module's onAcceptWant done to notify ability mgr to continue + * @param want request param being accepted + * @param flag specified flag return by application + * @param requestId a number represents a request + */ virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, int32_t requestId) override; + /** + * @brief called when the module's onAcceptWant happens time out + * @param want request param + * @param requestId a number represents a request + */ virtual void OnTimeoutResponse(const AAFwk::Want &want, int32_t requestId) override; virtual void OnNewProcessRequestResponse(const AAFwk::Want &want, const std::string &flag, diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index 0424fd2884..36c73d925b 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -1197,14 +1197,14 @@ int32_t AppMgrClient::GetAllUIExtensionProviderPid(pid_t hostPid, std::vectorGetAllUIExtensionProviderPid(hostPid, providerPids); } -int32_t AppMgrClient::NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) +int32_t AppMgrClient::NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) { sptr service = iface_cast(mgrHolder_->GetRemoteObject()); if (service == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr."); return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED; } - return service->NotifyMemorySizeStateChanged(isMemorySizeSufficent); + return service->NotifyMemorySizeStateChanged(isMemorySizeSufficient); } bool AppMgrClient::IsMemorySizeSufficent() const diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index c004d04055..29bd162e0b 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -1826,13 +1826,13 @@ int32_t AppMgrProxy::GetAllUIExtensionProviderPid(pid_t hostPid, std::vector GetUIExtensioBySessionInfo(const sptr &sessionInfo); + std::shared_ptr GetUIExtensionBySessionInfo(const sptr &sessionInfo); std::shared_ptr GetExtensionByTokenFromServiceMap(const sptr &token); std::shared_ptr GetExtensionByTokenFromAbilityCache(const sptr &token); @@ -577,7 +577,7 @@ private: void HandleUIExtWindowDiedTask(const sptr &remote); /** - * Post an extension's disconnect task, auto disconnect when extension conected timeout. + * Post an extension's disconnect task, auto disconnect when extension connected timeout. */ void PostExtensionDelayDisconnectTask(const std::shared_ptr &connectRecord); diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index f7f546420d..7010a53ac5 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -695,26 +695,84 @@ public: virtual void SetLockedState(int32_t sessionId, bool lockedState) override; + /** + * @brief Register mission listener to ability mgr. + * @param listener The handler of listener. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int RegisterMissionListener(const sptr &listener) override; + /** + * @brief UnRegister mission listener from ability mgr. + * @param listener The handler of listener. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int UnRegisterMissionListener(const sptr &listener) override; + /** + * @brief Get mission infos from ability mgr. + * @param deviceId local or remote deviceId. + * @param numMax max number of missions. + * @param missionInfos mission info result. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax, std::vector &missionInfos) override; + /** + * @brief Get mission info by id. + * @param deviceId local or remote deviceId. + * @param missionId Id of target mission. + * @param missionInfo mission info of target mission. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetMissionInfo(const std::string& deviceId, int32_t missionId, MissionInfo &missionInfos) override; + /** + * @brief Clean mission by id. + * @param missionId Id of target mission. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int CleanMission(int32_t missionId) override; + /** + * @brief Clean all missions in system. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int CleanAllMissions() override; virtual int MoveMissionToFront(int32_t missionId) override; + /** + * @brief Move a mission to front. + * @param missionId Id of target mission. + * @param startOptions Special startOptions for target mission. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override; + /** + * Move missions to front + * @param missionIds Ids of target missions + * @param topMissionId Indicate which mission will be moved to top, if set to -1, missions' order won't change + * @return Returns ERR_OK on success, others on failure. + */ virtual int MoveMissionsToForeground(const std::vector& missionIds, int32_t topMissionId) override; + /** + * Move missions to background + * @param missionIds Ids of target missions + * @param result The result of move missions to background, and the array is sorted by zOrder + * @return Returns ERR_OK on success, others on failure. + */ virtual int MoveMissionsToBackground(const std::vector& missionIds, std::vector& result) override; @@ -747,10 +805,29 @@ public: virtual int ReleaseCall( const sptr &connect, const AppExecFwk::ElementName &element) override; + /** + * @brief start user. + * @param accountId accountId. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int StartUser(int userId, sptr callback) override; + /** + * @brief stop user. + * @param accountId accountId. + * @param callback callback. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int StopUser(int userId, const sptr &callback) override; + /** + * @brief logout user. + * @param accountId accountId. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int LogoutUser(int32_t userId) override; virtual int SetMissionContinueState(const sptr &token, const AAFwk::ContinueState &state) override; @@ -781,13 +858,38 @@ public: virtual int UnregisterAbilityFirstFrameStateObserver( const sptr &observer) override; #endif - + /** + * @brief Get the ability running information. + * + * @param info Ability running information. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetAbilityRunningInfos(std::vector &info) override; + /** + * @brief Get the extension running information. + * + * @param upperLimit The maximum limit of information wish to get. + * @param info Extension running information. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetExtensionRunningInfos(int upperLimit, std::vector &info) override; + /** + * @brief Get running process information. + * + * @param info Running process information. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetProcessRunningInfos(std::vector &info) override; + /** + * @brief Register mission listener to ability manager service. + * @param deviceId The remote device Id. + * @param listener The handler of listener. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int RegisterMissionListener(const std::string &deviceId, const sptr &listener) override; @@ -816,13 +918,41 @@ public: */ virtual bool IsRunningInStabilityTest() override; + /** + * @brief Register the snapshot handler + * @param handler snapshot handler + * @return ErrCode Returns ERR_OK on success, others on failure. + */ virtual int RegisterSnapshotHandler(const sptr& handler) override; + /** + * @brief Get the Mission Snapshot Info object + * @param deviceId local or remote deviceId. + * @param missionId Id of target mission. + * @param snapshot snapshot of target mission. + * @param isLowResolution get low resolution snapshot. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot, bool isLowResolution) override; + /** + * @brief start user test. + * @param want the want of the ability user test to start. + * @param observer test observer callback. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int StartUserTest(const Want &want, const sptr &observer) override; + /** + * @brief Finish user test. + * @param msg user test message. + * @param resultCode user test result Code. + * @param bundleName user test bundleName. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int FinishUserTest( const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override; @@ -929,6 +1059,11 @@ public: virtual void ScheduleRecoverAbility(const sptr &token, int32_t reason, const Want *want = nullptr) override; + /** + * @brief Schedule clear recovery page stack. + * + * @param bundleName application bundleName. + */ virtual void ScheduleClearRecoveryPageStack() override; /** @@ -1086,10 +1221,17 @@ public: * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. * * @param sessionInfo the session info of the ability to start. - * @param isPrepareTerminate the result of ability onPrepareToTermiante. + * @param isPrepareTerminate the result of ability onPrepareToTerminate. * @return Returns ERR_OK on success, others on failure. */ virtual int PrepareTerminateAbilityBySCB(const sptr &sessionInfo, bool &isPrepareTerminate) override; + + /** + * @brief Register session handler. + * @param object The handler. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int RegisterSessionHandler(const sptr &object) override; /** diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 9ced8c4761..553f50d95c 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -407,7 +407,7 @@ public: AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override; /** - * Requset modal UIExtension with want, send want to ability manager service. + * Request modal UIExtension with want, send want to ability manager service. * * @param want, the want contains ability info about caller and called. * @return Returns ERR_OK on success, others on failure. @@ -653,7 +653,7 @@ public: /** * NotifyCompleteContinuation, notify continuation complete to dms. * @param deviceId, source device which start a continuation. - * @param sessionId, represent a continuaion. + * @param sessionId, represent a continuation. * @param isSuccess, continuation result. * @return */ @@ -1558,7 +1558,7 @@ public: * PrepareTerminateAbilityBySCB, prepare to terminate ability by scb. * * @param sessionInfo the session info of the ability to start. - * @param isTerminate the result of ability onPrepareToTermiante. + * @param isTerminate the result of ability onPrepareToTerminate. * @return Returns ERR_OK on success, others on failure. */ virtual int PrepareTerminateAbilityBySCB(const sptr &sessionInfo, bool &isTerminate) override; @@ -1838,8 +1838,17 @@ protected: void NotifyStartResidentProcess(std::vector &bundleInfos) override; + /** + * @brief Notify abilityms app process pre cache + * @param pid process pid. + * @param userId userId Designation User ID. + */ void NotifyAppPreCache(int32_t pid, int32_t userId) override; + /** + * @brief Notify abilityms app process OnRemoteDied + * @param abilityTokens abilities in died process. + */ void OnAppRemoteDied(const std::vector> &abilityTokens) override; private: @@ -1862,7 +1871,7 @@ private: */ void StartHighestPriorityAbility(int32_t userId, bool isBoot); /** - * connet bms. + * connect bms. * */ void ConnectBmsService(); @@ -1928,7 +1937,7 @@ private: int StartRemoteAbilityByCall(const Want &want, const sptr &callerToken, const sptr &connect); int ReleaseRemoteAbility(const sptr &connect, const AppExecFwk::ElementName &element); - void ForceTerminateSerivceExtensionByPid(int32_t pid, int32_t userId); + void ForceTerminateServiceExtensionByPid(int32_t pid, int32_t userId); void DumpInner(const std::string &args, std::vector &info); void DumpMissionInner(const std::string &args, std::vector &info); @@ -2284,16 +2293,16 @@ private: void ReportCleanSession(const sptr &sessionInfo, const std::shared_ptr &abilityRecord, int32_t errCode); - + void SendStartAbilityOtherExtensionEvent(const AppExecFwk::AbilityInfo& abilityInfo, const Want& want, uint32_t specifyTokenId); - + void SetMinimizedDuringFreeInstall(const sptr& sessionInfo); /** * @brief Check debug app in developer mode. * @param applicationInfo. The application info. - * @return Returns ture or false. + * @return Returns true or false. */ bool CheckDebugAppNotInDeveloperMode(const AppExecFwk::ApplicationInfo &applicationInfo); diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index cd71034999..ff70159e51 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -599,7 +599,7 @@ public: /** * check whether the ability is launcher. * - * @return true : lanucher ,false: not lanucher + * @return true : launcher ,false: not launcher */ bool IsLauncherAbility() const; @@ -921,7 +921,7 @@ public: void DumpService(std::vector &info, std::vector ¶ms, bool isClient = false) const; /** - * set aconnect remote object. + * set connect remote object. * */ void SetConnRemoteObject(const sptr &remoteObject); @@ -1194,7 +1194,7 @@ private: void StartingWindowTask(bool isRecent, bool isCold, const AbilityRequest &abilityRequest, std::shared_ptr &startOptions); - void StartingWindowColdTask(bool isRecnet, const AbilityRequest &abilityRequest, + void StartingWindowColdTask(bool isRecent, const AbilityRequest &abilityRequest, std::shared_ptr &startOptions); void PostCancelStartingWindowColdTask(); void StartingWindowHot(const std::shared_ptr &startOptions, const std::shared_ptr &want, @@ -1242,14 +1242,14 @@ private: */ bool isAbilityForegrounding_ = false; - // service(ability) can be connected by multi-pages(abilites), so need to store this service's connections + // service(ability) can be connected by multi-pages(abilities), so need to store this service's connections mutable ffrt::mutex connRecordListMutex_; std::list> connRecordList_ = {}; // service(ability) onConnect() return proxy of service ability sptr connRemoteObject_ = {}; int startId_ = 0; // service(ability) start id - // page(ability) can be started by multi-pages(abilites), so need to store this ability's caller + // page(ability) can be started by multi-pages(abilities), so need to store this ability's caller std::list> callerList_ = {}; bool isUninstall_ = false; diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index 136df08fef..3d9f5ccf08 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -94,8 +94,17 @@ public: virtual void NotifyStartResidentProcess(std::vector &bundleInfos) {} + /** + * @brief Notify abilityms app process pre cache + * @param pid process pid. + * @param userId userId Designation User ID. + */ virtual void NotifyAppPreCache(int32_t pid, int32_t userId) {} + /** + * @brief Notify abilityms app process OnRemoteDied + * @param abilityTokens abilities in died process. + */ virtual void OnAppRemoteDied(const std::vector> &abilityTokens) {} }; @@ -197,8 +206,19 @@ public: */ void KillProcessesByUserId(int32_t userId); + /** + * KillProcessesByPids, only in process call is allowed, + * kill the processes by pid list given. + * + * @param pids, the pid list of processes are going to be killed. + */ void KillProcessesByPids(std::vector &pids); + /** + * Set child and parent relationship + * @param token child process + * @param callerToken parent process + */ void AttachPidToParent(const sptr &token, const sptr &callerToken); /** @@ -259,12 +279,36 @@ public: */ int UpdateApplicationInfoInstalled(const std::string &bundleName, const int32_t uid); + /** + * Ability attach timeout. If start ability encounter failure, attach timeout to terminate. + * + * @param token Ability identify. + */ void AttachTimeOut(const sptr &token); + /** + * Prepare terminate. + * + * @param token Ability identify. + * @param clearMissionFlag Clear mission flag. + */ void PrepareTerminate(const sptr &token, bool clearMissionFlag = false); + /** + * Get running process information by ability token. + * + * @param token Ability identify. + * @param info Running process info. + */ void GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info); + /** + * Get running process information by pid. + * + * @param pid process id. + * @param info Output parameters, return runningProcessInfo. + * @return Returns ERR_OK on success, others on failure. + */ void GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) const; /** @@ -280,10 +324,31 @@ public: */ void StartupResidentProcess(const std::vector &bundleInfos); + /** + * Start specified ability. + * + * @param want Want contains information of the ability to start. + * @param abilityInfo Ability information. + * @param requestId request id to callback + */ void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0); + + /** + * @brief Get running process information. + * + * @param info Running process information. + * @return Returns ERR_OK on success, others on failure. + */ int GetProcessRunningInfos(std::vector &info); + /** + * Start specified process. + * + * @param want Want contains information wish to start. + * @param abilityInfo Ability information. + * @param requestId for callback + */ void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0); @@ -303,6 +368,14 @@ public: */ int FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName); + /** + * GetProcessRunningInfosByUserId, call GetProcessRunningInfosByUserId() through proxy project. + * Obtains information about application processes that are running on the device. + * + * @param info, app name in Application record. + * @param userId, user Id in Application record. + * @return ERR_OK ,return back success,others fail. + */ int GetProcessRunningInfosByUserId(std::vector &info, int32_t userId); std::string ConvertAppState(const AppState &state); @@ -314,6 +387,12 @@ public: */ int UpdateConfiguration(const AppExecFwk::Configuration &config); + /** + * GetConfiguration + * + * @param info to retrieve configuration data. + * @return ERR_OK ,return back success,others fail. + */ int GetConfiguration(AppExecFwk::Configuration &config); /** @@ -438,8 +517,8 @@ public: void ClearProcessByToken(sptr token) const; /** - * whether memory size is sufficent. - * @return Returns true is sufficent memory size, others return false. + * whether memory size is sufficient. + * @return Returns true is sufficient memory size, others return false. */ virtual bool IsMemorySizeSufficent() const; @@ -450,6 +529,11 @@ public: */ void AttachedToStatusBar(const sptr &token); + /** + * Temporarily block the process cache feature. + * + * @param pids the pids of the processes that should be blocked. + */ void BlockProcessCacheByPids(const std::vector& pids); /** @@ -460,6 +544,12 @@ public: */ bool CleanAbilityByUserRequest(const sptr &token); + /** + * whether killed for upgrade web. + * + * @param bundleName the bundle name is killed for upgrade web. + * @return Returns true is killed for upgrade web, others return false. + */ bool IsKilledForUpgradeWeb(const std::string &bundleName); /** @@ -501,8 +591,17 @@ protected: */ virtual void NotifyStartResidentProcess(std::vector &bundleInfos) override; + /** + * @brief Notify abilityms app process OnRemoteDied + * @param abilityTokens abilities in died process. + */ virtual void OnAppRemoteDied(const std::vector> &abilityTokens) override; - + + /** + * @brief Notify abilityms app process pre cache + * @param pid process pid. + * @param userId userId Designation User ID. + */ virtual void NotifyAppPreCache(int32_t pid, int32_t userId) override; private: diff --git a/services/abilitymgr/include/lifecycle_deal.h b/services/abilitymgr/include/lifecycle_deal.h index b9e4077fcc..ceb2e4c13a 100644 --- a/services/abilitymgr/include/lifecycle_deal.h +++ b/services/abilitymgr/include/lifecycle_deal.h @@ -47,16 +47,37 @@ public: */ void Activate(const Want &want, LifeCycleStateInfo &stateInfo); void Inactivate(const Want &want, LifeCycleStateInfo &stateInfo, sptr sessionInfo = nullptr); + /** + * schedule ability life cycle to background + */ void MoveToBackground(const Want &want, LifeCycleStateInfo &stateInfo); + /** + * schedule ability onConnect + */ void ConnectAbility(const Want &want); + /** + * schedule ability onDisconnect + */ void DisconnectAbility(const Want &want); + /** + * schedule ability onDestroy + */ void Terminate(const Want &want, LifeCycleStateInfo &stateInfo, sptr sessionInfo = nullptr); + /** + * schedule ability onRequest + */ void CommandAbility(const Want &want, bool reStart, int startId); void CommandAbilityWindow(const Want &want, const sptr &sessionInfo, WindowCommand winCmd); void SaveAbilityState(); void RestoreAbilityState(const PacMap &inState); + /** + * schedule ability life cycle to foreground + */ void ForegroundNew(const Want &want, LifeCycleStateInfo &stateInfo, sptr sessionInfo = nullptr); + /** + * schedule ability life cycle to background + */ void BackgroundNew(const Want &want, LifeCycleStateInfo &stateInfo, sptr sessionInfo = nullptr); void ContinueAbility(const std::string& deviceId, uint32_t versionCode); diff --git a/services/abilitymgr/include/resident_process_manager.h b/services/abilitymgr/include/resident_process_manager.h index 0a91d6c9ba..dfa81fe9ea 100644 --- a/services/abilitymgr/include/resident_process_manager.h +++ b/services/abilitymgr/include/resident_process_manager.h @@ -66,12 +66,33 @@ public: * @return Returns ERR_OK on success, others on failure. */ int32_t SetResidentProcessEnabled(const std::string &bundleName, const std::string &callerName, bool updateEnable); + + /** + * start empty resident processes. + * + * @param bundleInfos bundles of resident processes. + */ void StartResidentProcess(const std::vector &bundleInfos); + /** + * If bundle has right main element, start the main element + */ void StartResidentProcessWithMainElement(std::vector &bundleInfos, int32_t userId); + /** + * Once one process created, query keepalive status from db and update then + */ void OnAppStateChanged(const AppInfo &info); + /** + * Before starting a resident element, store it. + */ int32_t PutResidentAbility(const std::string &bundleName, const std::string &abilityName, int32_t userId); bool IsResidentAbility(const std::string &bundleName, const std::string &abilityName, int32_t userId); + /** + * After a resident element being started, remove it + */ void RemoveResidentAbility(int32_t residentId); + /** + * query resident bundles for user + */ bool GetResidentBundleInfosForUser(std::vector &bundleInfos, int32_t userId); void StartFailedResidentAbilities(); private: diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index e96b7907f9..8e3b454eeb 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -1307,7 +1307,7 @@ std::shared_ptr AbilityConnectManager::GetExtensionByIdFromTermin return nullptr; } -std::shared_ptr AbilityConnectManager::GetUIExtensioBySessionInfo( +std::shared_ptr AbilityConnectManager::GetUIExtensionBySessionInfo( const sptr &sessionInfo) { CHECK_POINTER_AND_RETURN(sessionInfo, nullptr); diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index c7a72731f6..be8c20b5a9 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -650,7 +650,7 @@ int AbilityManagerService::StartAbilityByUIContentSession(const Want &want, cons } if (token != sessionInfo->callerToken) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken unequal to top ablity token"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken unequal to top ability token"); return NOT_TOP_ABILITY; } AbilityUtil::RemoveInstanceKey(const_cast(want)); @@ -685,7 +685,7 @@ int AbilityManagerService::StartAbilityByUIContentSession(const Want &want, cons } if (token != sessionInfo->callerToken) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken unequal to top ablity token"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken unequal to top ability token"); return NOT_TOP_ABILITY; } return StartAbility(want, startOptions, callerToken, userId, requestCode); @@ -10367,7 +10367,7 @@ void AbilityManagerService::GetConnectManagerAndUIExtensionBySessionInfo(const s TAG_LOGD(AAFwkTag::ABILITYMGR, "userId=%{public}d", userId); connectManager = GetConnectManagerByUserId(userId); if (connectManager) { - targetAbility = connectManager->GetUIExtensioBySessionInfo(sessionInfo); + targetAbility = connectManager->GetUIExtensionBySessionInfo(sessionInfo); } else { TAG_LOGW(AAFwkTag::ABILITYMGR, "connectManager null, userId:%{public}d", userId); } @@ -10375,7 +10375,7 @@ void AbilityManagerService::GetConnectManagerAndUIExtensionBySessionInfo(const s TAG_LOGD(AAFwkTag::ABILITYMGR, "try to find UIExtension in user0"); connectManager = GetConnectManagerByUserId(U0_USER_ID); if (connectManager) { - targetAbility = connectManager->GetUIExtensioBySessionInfo(sessionInfo); + targetAbility = connectManager->GetUIExtensionBySessionInfo(sessionInfo); } else { TAG_LOGW(AAFwkTag::ABILITYMGR, "connectManager null, userId:0"); } @@ -10946,7 +10946,7 @@ void AbilityManagerService::NotifyStartResidentProcess(std::vector> &abilityTokens) @@ -12179,7 +12179,7 @@ int32_t AbilityManagerService::CleanUIAbilityBySCB(const sptr &sess return errCode; } -void AbilityManagerService::ForceTerminateSerivceExtensionByPid(int32_t pid, int32_t userId) +void AbilityManagerService::ForceTerminateServiceExtensionByPid(int32_t pid, int32_t userId) { std::vector> tokens; IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->GetAbilityRecordsByProcessID( @@ -12191,7 +12191,7 @@ void AbilityManagerService::ForceTerminateSerivceExtensionByPid(int32_t pid, int if (abilityRecord && abilityRecord->GetAbilityInfo().extensionAbilityType == AppExecFwk::ExtensionAbilityType::SERVICE) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "app ForceTerminateSerivceExtensionByPid, pid is %{public}d", pid); + TAG_LOGI(AAFwkTag::ABILITYMGR, "app ForceTerminateServiceExtensionByPid, pid is %{public}d", pid); connectManager->TerminateAbility(token); } } @@ -12228,7 +12228,7 @@ void AbilityManagerService::SendStartAbilityOtherExtensionEvent(const AppExecFwk { if (abilityInfo.type != AppExecFwk::AbilityType::EXTENSION || abilityInfo.extensionAbilityType == AppExecFwk::ExtensionAbilityType::SERVICE) { - return; + return; } EventInfo eventInfo; eventInfo.bundleName = abilityInfo.bundleName; diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 2226bcfc00..31f2271495 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -1816,7 +1816,7 @@ void AbilityRecord::SendSandboxSavefileResult(const Want &want, int resultCode, } } } else { - TAG_LOGW(AAFwkTag::ABILITYMGR, "uri illigal for request: %{public}d", requestCode); + TAG_LOGW(AAFwkTag::ABILITYMGR, "uri illegal for request: %{public}d", requestCode); } auto scheduler = scheduler_; diff --git a/services/appmgr/include/ability_running_record.h b/services/appmgr/include/ability_running_record.h index f79a607149..9eb2178422 100644 --- a/services/appmgr/include/ability_running_record.h +++ b/services/appmgr/include/ability_running_record.h @@ -75,6 +75,12 @@ public: * @return Returns the ability token. */ const sptr &GetToken() const; + + /** + * @brief Obtains the record id of the ability. + * + * @return Returns the ability record id. + */ int32_t GetAbilityRecordId() const { return abilityRecordId_; @@ -116,7 +122,16 @@ public: void SetEventId(const int64_t eventId); int64_t GetEventId() const; + /** + * @brief SetOwnerUserId set the owner of the ability. + */ void SetOwnerUserId(int32_t ownerUserId); + + /** + * @brief GetOwnerUserId get the owner of the ability. + * + * @return Return the owner's userId. + */ int32_t GetOwnerUserId() const; void SetIsSingleUser(bool flag); bool IsSingleUser() const; @@ -126,6 +141,12 @@ public: int32_t GetUIExtensionAbilityId() const; void SetUserRequestCleaningStatus(); bool IsUserRequestCleaning() const; + + /** + * @brief Whether the ability is scene board. + * + * @return Returns whether the ability is scene board. + */ bool IsSceneBoard() const; private: diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index e0ba147d3e..657f287540 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -107,8 +107,19 @@ public: */ virtual void KillProcessesByUserId(int32_t userId) override; + /** + * KillProcessesByPids, only in process call is allowed, + * kill the processes by pid list given. + * + * @param pids, the pid list of processes are going to be killed. + */ virtual void KillProcessesByPids(std::vector &pids) override; + /** + * Set child and parent relationship + * @param token child process + * @param callerToken parent process + */ virtual void AttachPidToParent(const sptr &token, const sptr &callerToken) override; /** @@ -168,16 +179,54 @@ public: */ virtual int KillApplicationByUid(const std::string &bundleName, const int uid) override; + /** + * KillApplicationSelf, this allows app to terminate itself. + * + * @param clearPageStack, the flag indicates if ClearPageStack lifecycle should be scheduled. + * @return ERR_OK for success call, others for failure. + */ virtual int KillApplicationSelf(const bool clearPageStack = false) override; + /** + * Get application info by process id. + * + * @param pid Process id. + * @param application Application information got. + * @param debug Whether IsDebugApp. + * @return Returns ERR_OK on success, others on failure. + */ int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) override; + /** + * Record process exit reason to appRunningRecord + * @param pid pid + * @param reason reason enum + * @param exitMsg exitMsg + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) override; + /** + * AbilityAttachTimeOut, called by ability manager service when an ability is loaded timeout. + * + * @param token indicates the token of the ability which is timeout. + */ virtual void AbilityAttachTimeOut(const sptr &token) override; + /** + * PrepareTerminate, called before terminating one ability by ability manager service to notify application. + * + * @param token indicates the token of the ability to be terminated. + * @param clearMissionFlag indicates whether it is caused by cleaning mission. + */ virtual void PrepareTerminate(const sptr &token, bool clearMissionFlag = false) override; + /** + * GetRunningProcessInfoByToken, get process info for one ability. + * + * @param token indicates the token of the ability requested. + * @param info output of the information. + */ virtual void GetRunningProcessInfoByToken( const sptr &token, AppExecFwk::RunningProcessInfo &info) override; @@ -189,18 +238,50 @@ public: */ void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) override; + /** + * Start specified ability. + * + * @param want Want contains information of the ability to start. + * @param abilityInfo Ability information. + * @param requestId request id to callback + */ virtual void StartSpecifiedAbility( const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override; + /** + * Register response of start specified ability. + * + * @param response Response of start specified ability. + */ virtual void RegisterStartSpecifiedAbilityResponse(const sptr &response) override; + /** + * Start specified process. + * + * @param want Want contains information wish to start. + * @param abilityInfo Ability information. + * @param requestId for callback + */ virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override; + /** + * SetCurrentUserId, set the userid to app mgr by ability mgr when switching to another user. + * + * @param userId the new user. + */ virtual void SetCurrentUserId(const int32_t userId) override; virtual void SetEnableStartProcessFlagByUserId(int32_t userId, bool enableStartProcess) override; + /** + * GetBundleNameByPid, get bundleName and uid of a process. + * + * @param pid input param indicates the pid of the process. + * @param bundleName output for bundleName. + * @param uid output for uid. + * @return ERR_OK for success call, others for failure. + */ virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) override; /** @@ -281,6 +362,7 @@ public: * @brief Set resident process enable status. * @param bundleName The application bundle name. * @param enable The current updated enable status. + * @param uid indicates user, 0 for all users */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) override; @@ -292,8 +374,8 @@ public: virtual void ClearProcessByToken(sptr token) override; /** - * whether memory size is sufficent. - * @return Returns true is sufficent memory size, others return false. + * whether memory size is sufficient. + * @return Returns true is sufficient memory size, others return false. */ virtual bool IsMemorySizeSufficent() override; @@ -328,6 +410,9 @@ public: */ virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override; + /** + * Whether a process is attached, refer to AttachApplication + */ virtual bool IsProcessAttached(sptr token) override; virtual bool IsAppKilling(sptr token) override; diff --git a/services/appmgr/include/app_lifecycle_deal.h b/services/appmgr/include/app_lifecycle_deal.h index ce65133609..568b26b85f 100644 --- a/services/appmgr/include/app_lifecycle_deal.h +++ b/services/appmgr/include/app_lifecycle_deal.h @@ -163,7 +163,7 @@ public: void ScheduleProcessSecurityExit(); /** - * cheduleClearPageStack, call cheduleClearPageStack() through proxy project, + * scheduleClearPageStack, call scheduleClearPageStack() through proxy project, * Notify application clear recovery page stack. * * @return @@ -184,6 +184,12 @@ public: */ sptr GetApplicationClient() const; + /** + * @brief Schedule the given module the onAcceptWant lifecycle call. + * + * @param want the param passed to onAcceptWant lifecycle. + * @param want the moduleName of which being scheduled. + */ void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName); void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName); @@ -196,14 +202,43 @@ public: */ int32_t UpdateConfiguration(const Configuration &config); + /** + * @brief Notify application load patch. + * + * @param bundleName Bundle name + * @param callback called when LoadPatch finished. + * @param recordId callback data + * @return Returns 0 on success, error code on failure. + */ int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback, const int32_t recordId); + /** + * @brief Notify application reload page. + * + * @param callback called when HotReload finished. + * @param recordId callback data + * @return Returns 0 on success, error code on failure. + */ int32_t NotifyHotReloadPage(const sptr &callback, const int32_t recordId); + /** + * @brief Notify application unload patch. + * + * @param bundleName Bundle name + * @param callback called when UnloadPatch finished. + * @param recordId callback data + * @return Returns 0 on success, error code on failure. + */ int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr &callback, const int32_t recordId); + /** + * Notify Fault Data + * + * @param faultData the fault data. + * @return Returns ERR_OK on success, others on failure. + */ int32_t NotifyAppFault(const FaultData &faultData); /** @@ -215,7 +250,18 @@ public: */ int32_t ChangeAppGcState(int32_t state); + /** + * @brief attach to a process to debug. + * + * @return ERR_OK, return back success, others fail. + */ int32_t AttachAppDebug(); + + /** + * @brief detach a debugging process. + * + * @return ERR_OK, return back success, others fail. + */ int32_t DetachAppDebug(); /** @@ -233,9 +279,6 @@ public: /** * Notifies the application of process caching. - * - * - * @return */ void ScheduleCacheProcess(); diff --git a/services/appmgr/include/app_mgr_service.h b/services/appmgr/include/app_mgr_service.h index 7290b87bff..9f8654c168 100644 --- a/services/appmgr/include/app_mgr_service.h +++ b/services/appmgr/include/app_mgr_service.h @@ -60,7 +60,7 @@ public: virtual ~AppMgrService() override; // the function about application - // attach the application to ams, then ams can control it. + // attach the application to ability mgr, then ability mgr can control it. /** * AttachApplication, call AttachApplication() through proxy object, * get all the information needed to start the Application (data related to the Application ). @@ -162,10 +162,10 @@ public: /** * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. - * Obtains running isntance keys of multi-instance app that are running on the device. + * Obtains running instance keys of multi-instance app that are running on the device. * * @param bundlename, bundle name in Application record. - * @param instanceKeys, output instance keys of the multi-insatnce app. + * @param instanceKeys, output instance keys of the multi-instance app. * @return ERR_OK ,return back success,others fail. */ virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, @@ -330,32 +330,105 @@ public: */ int Dump(int fd, const std::vector& args) override; + /** + * @brief called when the abilityStage's onAcceptWant lifecycle completed. + * @param recordId record id of the ability. + * @param want want has been accepted. + * @param flag flag get from OnAcceptWant. + */ virtual void ScheduleAcceptWantDone( const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override; virtual void ScheduleNewProcessRequestDone( const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override; + /** + * Get the token of ability records by process ID. + * + * @param pid The process id. + * @param tokens The token of ability records. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetAbilityRecordsByProcessID(const int pid, std::vector> &tokens) override; + /** + * Prestart nwebspawn process. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int PreStartNWebSpawnProcess() override; + /** + * Start nweb render process, called by nweb host. + * + * @param renderParam, params passed to renderProcess. + * @param ipcFd, ipc file descriptor for web browser and render process. + * @param sharedFd, shared memory file descriptor. + * @param crashFd, crash signal file descriptor. + * @param renderPid, created render pid. + * @param isGPU, is or not gpu process + * @return Returns ERR_OK on success, others on failure. + */ virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU = false) override; + /** + * Render process call this to attach to app manager service. + * + * @param renderScheduler scheduler of render process. + */ virtual void AttachRenderProcess(const sptr &shceduler) override; + /** + * Get render process termination status, called by nweb host. + * + * @param renderPid, target render pid. + * @param status, termination status of the render process. + * @return Returns ERR_OK on success, others on failure. + */ virtual int GetRenderProcessTerminationStatus(pid_t renderPid, int &status) override; + /** + * GetConfiguration + * + * @param info to retrieve configuration data. + * @return ERR_OK ,return back success,others fail. + */ virtual int32_t GetConfiguration(Configuration& config) override; + /** + * UpdateConfiguration, ANotify application update system environment changes. + * + * @param config System environment change parameters. + * @param userId configuration for the user + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t UpdateConfiguration(const Configuration &config, const int32_t userId = -1) override; + /** + * Update config by bundle name. + * + * @param config Application environment change parameters. + * @param name Application bundle name. + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name) override; + /** + * @brief register a configuration observer which will receive notifies when updated. + * @param observer the configuration observer to receive notify. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t RegisterConfigurationObserver(const sptr &observer) override; + /** + * @brief unregister a configuration observer registered before. + * @param observer the configuration observer registered before. + * + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t UnregisterConfigurationObserver(const sptr &observer) override; /** @@ -372,12 +445,39 @@ public: */ virtual int32_t CheckIsKiaProcess(pid_t pid, bool &isKia) override; + /** + * @brief Get the running state of application by bundle name. + * + * @param bundleName Bundle name + * @return Returns true if process is running, false if process isn't running. + */ bool GetAppRunningStateByBundleName(const std::string &bundleName) override; + /** + * @brief Notify application load patch. + * + * @param bundleName Bundle name + * @param callback called when LoadPatch finished. + * @return Returns ERR_OK on success, error code on failure. + */ int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback) override; + /** + * @brief Notify application reload page. + * + * @param bundleName Bundle name + * @param callback called when HotReload finished. + * @return Returns ERR_OK on success, error code on failure. + */ int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr &callback) override; + /** + * @brief Notify application unload patch. + * + * @param bundleName Bundle name + * @param callback called when UnloadPatch finished. + * @return Returns ERR_OK on success, error code on failure. + */ int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr &callback) override; #ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE @@ -393,6 +493,11 @@ public: */ virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode) override; + /** + * start native process for debugger. + * + * @param want param to start a process. + */ virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) override; /** @@ -540,28 +645,89 @@ public: */ void ExitChildProcessSafely() override; + /** + * @brief register a render process state observer to receive change. + * @param observer the render process state observer to receive notify. + * + * @return Returns ERR_OK on success, others on failure. + */ int32_t RegisterRenderStateObserver(const sptr &observer) override; + /** + * @brief unregister a render process state observer registered before. + * @param observer the render process state observer registered before. + * + * @return Returns ERR_OK on success, others on failure. + */ int32_t UnregisterRenderStateObserver(const sptr &observer) override; + /** + * @brief update a render process state. + * @param renderPid the pid of the render process to be updated. + * @param state the new state value of the render process. + * + * @return Returns ERR_OK on success, others on failure. + */ int32_t UpdateRenderState(pid_t renderPid, int32_t state) override; + /** + * @brief mark a process which is going restart. + * @param bundleName the bundleName of the process. + * + * @return Returns ERR_OK on success, others on failure. + */ int32_t SignRestartAppFlag(const std::string &bundleName) override; + /** + * Get appRunningUniqueId by pid. + * @param pid pid. + * @param appRunningUniqueId appRunningUniqueId. + * @return Returns ERR_OK on success, others on failure. + */ int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId) override; + /* + * Get all uiextension root host process id, need apply permission ohos.permission.GET_RUNNING_INFO. + * If specified pid mismatch UIExtensionAbility type, return empty vector. + * @param pid Process id. + * @param hostPids All host process id. + * @return Returns ERR_OK on success, others on failure. + */ int32_t GetAllUIExtensionRootHostPid(pid_t pid, std::vector &hostPids) override; + /** + * Get all uiextension provider process id, need apply permission ohos.permission.GET_RUNNING_INFO. + * If specified hostPid didn't start any UIExtensionAbility, return empty vector. + * @param hostPid Host process id. + * @param providerPids All provider process id started by specified hostPid. + * @return Returns ERR_OK on success, others on failure. + */ int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector &providerPids) override; - int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; + /** + * @brief Notify memory size state changed to sufficient or insufficient. + * @param isMemorySizeSufficient Indicates the memory size state. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) override; + /** + * Set application assertion pause state. + * + * @param flag assertion pause state. + */ void SetAppAssertionPauseState(bool flag) override; + /** + * @brief set support process cache by self + */ int32_t SetSupportedProcessCacheSelf(bool isSupport) override; - + int32_t SetSupportedProcessCache(int32_t pid, bool isSupport) override; + /** + * set browser channel for caller + */ virtual void SaveBrowserChannel(sptr browser) override; /** @@ -581,10 +747,19 @@ public: int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, const sptr &callback) override; + /** + * Notify that the process depends on web by itself. + */ virtual int32_t NotifyProcessDependedOnWeb() override; + /** + * Kill process depended on web by sa. + */ virtual void KillProcessDependedOnWeb() override; + /** + * Restart resident process depended on web. + */ virtual void RestartResidentProcessDependedOnWeb() override; private: /** diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index b24c754bc9..cebe61d69a 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -183,8 +183,20 @@ public: */ virtual void KillProcessesByUserId(int32_t userId); + /** + * KillProcessesByPids, only in process call is allowed, + * kill the processes by pid list given. + * + * @param pids, the pid list of processes are going to be killed. + * @return + */ virtual void KillProcessesByPids(std::vector &pids); + /** + * Set child and parent relationship + * @param token child process + * @param callerToken parent process + */ virtual void AttachPidToParent(const sptr &token, const sptr &callerToken); /** @@ -291,6 +303,12 @@ public: */ virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid); + /** + * KillApplicationSelf, this allows app to terminate itself. + * + * @param clearPageStack, the flag indicates if ClearPageStack lifecycle should be scheduled. + * @return ERR_OK for success call, others for failure. + */ virtual int32_t KillApplicationSelf(const bool clearPageStack = false); /** @@ -351,10 +369,10 @@ public: /** * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. - * Obtains running isntance keys of multi-instance app that are running on the device. + * Obtains running instance keys of multi-instance app that are running on the device. * * @param bundlename, bundle name in Application record. - * @param instanceKeys, output instance keys of the multi-insatnce app. + * @param instanceKeys, output instance keys of the multi-instance app. * @return ERR_OK ,return back success,others fail. */ virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, @@ -473,6 +491,11 @@ public: */ int32_t IsAppRunning(const std::string &bundleName, int32_t appCloneIndex, bool &isRunning); + /** + * start native process for debugger. + * + * @param want param to start a process. + */ int32_t StartNativeProcessForDebugger(const AAFwk::Want &want); std::shared_ptr CreateAppRunningRecord( @@ -608,8 +631,19 @@ public: eventHandler_ = eventHandler; } + /** + * HandleAbilityAttachTimeOut, called by ability manager service when an ability is loaded timeout. + * + * @param token indicates the token of the ability which is timeout. + */ void HandleAbilityAttachTimeOut(const sptr &token); + /** + * PrepareTerminate, called before terminating one ability by ability manager service to notify application. + * + * @param token indicates the token of the ability to be terminated. + * @param clearMissionFlag indicates whether it is caused by cleaning mission. + */ void PrepareTerminate(const sptr &token, bool clearMissionFlag = false); void OnAppStateChanged(const std::shared_ptr &appRecord, const ApplicationState state, @@ -619,6 +653,12 @@ public: void OnAppStopped(const std::shared_ptr &appRecord); + /** + * GetRunningProcessInfoByToken, get process info for one ability. + * + * @param token indicates the token of the ability requested. + * @param info output of the information. + */ void GetRunningProcessInfoByToken(const sptr &token, AppExecFwk::RunningProcessInfo &info); int32_t GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) const; @@ -715,14 +755,34 @@ public: int FinishUserTest( const std::string &msg, const int64_t &resultCode, const std::string &bundleName, const pid_t &pid); + /** + * Start specified ability. + * + * @param want Want contains information of the ability to start. + * @param abilityInfo Ability information. + * @param requestId request id to callback + */ void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0); + /** + * Start specified process. + * + * @param want Want contains information wish to start. + * @param abilityInfo Ability information. + * @param requestId for callback + */ void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0); void RegisterStartSpecifiedAbilityResponse(const sptr &response); + /** + * @brief called when the abilityStage's onAcceptWant lifecycle completed. + * @param recordId record id of the ability. + * @param want want has been accepted. + * @param flag flag get from OnAcceptWant. + */ void ScheduleAcceptWantDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag); void ScheduleNewProcessRequestDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag); @@ -759,6 +819,13 @@ public: int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug); + /** + * Record process exit reason to appRunningRecord + * @param pid pid + * @param reason reason enum + * @param exitMsg exitMsg + * @return Returns ERR_OK on success, others on failure. + */ int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg); /** @@ -773,8 +840,21 @@ public: int32_t KillProcessByPid(const pid_t pid, const std::string& reason = "foundation"); + /** + * @brief Get the running state of application by bundle name. + * + * @param bundleName Bundle name + * @return Returns true if process is running, false if process isn't running. + */ bool GetAppRunningStateByBundleName(const std::string &bundleName); + /** + * @brief Notify application load patch. + * + * @param bundleName Bundle name + * @param callback called when LoadPatch finished. + * @return Returns ERR_OK on success, error code on failure. + */ int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback); int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr &callback); @@ -1101,28 +1181,60 @@ public: bool IsFinalAppProcessByBundleName(const std::string &bundleName); /** - * @brief Notify memory size state changed to sufficient or insufficent. - * @param isMemorySizeSufficent Indicates the memory size state. + * @brief Notify memory size state changed to sufficient or insufficient. + * @param isMemorySizeSufficient Indicates the memory size state. * @return Returns ERR_OK on success, others on failure. */ - int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent); + int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient); /** - * whether memory size is sufficent. - * @return Returns true is sufficent memory size, others return false. + * whether memory size is sufficient. + * @return Returns true is sufficient memory size, others return false. */ - bool IsMemorySizeSufficent(); + bool IsMemorySizeSufficient(); + /** + * Register render state observer. + * @param observer Render process state observer. + * @return Returns ERR_OK on success, others on failure. + */ int32_t RegisterRenderStateObserver(const sptr &observer); + /** + * Unregister render state observer. + * @param observer Render process state observer. + * @return Returns ERR_OK on success, others on failure. + */ int32_t UnregisterRenderStateObserver(const sptr &observer); + /** + * Update render state. + * @param renderPid Render pid. + * @param state foreground or background state. + * @return Returns ERR_OK on success, others on failure. + */ int32_t UpdateRenderState(pid_t renderPid, int32_t state); + /** + * Mark processes of a bundleName as the app is going to be restarted. + */ int32_t SignRestartAppFlag(const std::string &bundleName); + /** + * Set application assertion pause state. + * + * @param flag assertion pause state. + */ void SetAppAssertionPauseState(bool flag); + /** + * @brief A process can config itself to keep alive or not. + * when one process started, this method will be called from ability mgr with data selected from db. + * + * @param bundleName processed of witch to be configed + * @param enable config value + * @param uid indicates user, 0 for all users + */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid); int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId); @@ -1145,12 +1257,19 @@ public: virtual int DumpFfrt(const std::vector& pids, std::string& result); + /** + * @brief set support process cache by self + */ int32_t SetSupportedProcessCacheSelf(bool isSupport); int32_t SetSupportedProcessCache(int32_t pid, bool isSupport); void OnAppCacheStateChanged(const std::shared_ptr &appRecord, ApplicationState state); + /** + * set browser channel for caller + * @param hostPid caller pid + */ virtual void SaveBrowserChannel(const pid_t hostPid, sptr browser); bool IsAppProcessesAllCached(const std::string &bundleName, int32_t uid, @@ -1168,6 +1287,9 @@ public: void SetSceneBoardAttachFlag(bool flag); + /** + * Scene board has the highest priority. If Scene board is loading cache other apps' request. + */ void CacheLoadAbilityTask(const LoadAbilityTaskFunc& func); void SubmitCacheLoadAbilityTask(); @@ -1189,14 +1311,32 @@ public: bool CleanAbilityByUserRequest(const sptr &token); + /** + * whether killed for upgrade web. + * + * @param bundleName the bundle name is killed for upgrade web. + * @return Returns true is killed for upgrade web, others return false. + */ bool IsKilledForUpgradeWeb(const std::string &bundleName) const; bool IsProcessContainsOnlyUIAbility(const pid_t pid); + /** + * Whether a process is attached, refer to AttachApplication + */ bool IsProcessAttached(sptr token) const; + /** + * Is a process of a ability will be killed + * @param indicates the ability + */ bool IsAppKilling(sptr token) const; + /** + * @brief Notify abilityms app process pre cache + * @param pid process pid. + * @param userId userId Designation User ID. + */ void NotifyAppPreCache(int32_t pid, int32_t userId); /** @@ -1208,8 +1348,18 @@ public: */ virtual int32_t GetSupportedProcessCachePids(const std::string &bundleName, std::vector &pidList); + /** + * Register KIA interceptor. + * @param interceptor KIA interceptor. + * @return Returns ERR_OK on success, others on failure. + */ virtual int32_t RegisterKiaInterceptor(const sptr &interceptor); + /** + * Check if the given pid is a KIA process. + * @param pid process id. + * @return Returns true if it is a KIA process, false otherwise. + */ virtual int32_t CheckIsKiaProcess(pid_t pid, bool &isKia); private: @@ -1220,25 +1370,43 @@ private: FaultData ConvertDataTypes(const AppFaultDataBySA &faultData); + /** + * Start a empty resident process + */ void StartEmptyResidentProcess(const BundleInfo &info, const std::string &processName, int restartCount, bool isEmptyKeepAliveApp); + /** + * If one app needs keepalive and dies, restart the app again + */ void RestartResidentProcess(std::shared_ptr appRecord); bool CheckLoadAbilityConditions(const sptr &token, const std::shared_ptr &abilityInfo, const std::shared_ptr &appInfo); + /** + * query bundle info for the given bundleName + */ bool GetBundleInfo(const std::string &bundleName, BundleInfo &bundleInfo); bool GenerateRenderUid(int32_t &renderUid); + /** + * Build a process's name for service extension + */ void MakeServiceExtProcessName(const std::shared_ptr &abilityInfo, const std::shared_ptr &appInfo, std::string &processName) const; + /** + * Build a process's name for the info given + */ void MakeProcessName(const std::shared_ptr &abilityInfo, const std::shared_ptr &appInfo, const HapModuleInfo &hapModuleInfo, int32_t appIndex, const std::string &specifiedProcessFlag, std::string &processName) const; + /** + * Build a process's name based on the info given + */ void MakeProcessName(const std::shared_ptr &appInfo, const HapModuleInfo &hapModuleInfo, std::string &processName) const; @@ -1360,9 +1528,20 @@ private: void InitGlobalConfiguration(); + /** + * @brief Another way of GetRunningProcess, only one item will be filled into the info + */ void GetRunningProcesses(const std::shared_ptr &appRecord, std::vector &info); + /** + * @brief Retrieve a process's running info + */ void GetRunningProcess(const std::shared_ptr &appRecord, RunningProcessInfo &info); + /** + * @brief query a process's render process info + * @param appRecord the main process + * @param info to retrieve render process info + */ void GetRenderProcesses(const std::shared_ptr &appRecord, std::vector &info); void GetChildrenProcesses(const std::shared_ptr &appRecord, std::vector &info); @@ -1379,10 +1558,16 @@ private: bool VerifyAPL() const; + /** + * Register a focus listener to window manager + */ void RegisterFocusListener(); static void PointerDeviceEventCallback(const char *key, const char *value, void *context); + /** + * Verify whether the caller has the permission to kill processes of a bundleName. + */ int VerifyKillProcessPermission(const std::string &bundleName) const; int32_t VerifyKillProcessPermissionCommon() const; @@ -1404,6 +1589,10 @@ private: void OnChildProcessRemoteDied(const wptr &remote); + /** + * kill all child processed of a main process + * @param appRecord indicates the main process + */ void KillChildProcess(const std::shared_ptr &appRecord); void KillAttachedChildProcess(const std::shared_ptr &appRecord); @@ -1431,6 +1620,11 @@ private: bool CheckGetRunningInfoPermission() const; + /** + * kill all processes of a bundleName + * @param bundleName bundleName of which to be killed + * @param clearPageStack should schedule clearPage lifecycle + */ int32_t KillApplicationByBundleName( const std::string &bundleName, const bool clearPageStack = false); @@ -1454,6 +1648,10 @@ private: void RemoveRunningSharedBundleList(const std::string &bundleName); + /** + * kill one process's render process + * @param appRecord the main process + */ void KillRenderProcess(const std::shared_ptr &appRecord); void SetOverlayInfo(const std::string& bundleName, const int32_t userId, AppSpawnStartMsg& startMsg); @@ -1466,8 +1664,8 @@ private: void ProcessAppDebug(const std::shared_ptr &appRecord, const bool &isDebugStart); AppDebugInfo MakeAppDebugInfo(const std::shared_ptr &appRecord, const bool &isDebugStart); - int32_t NotifyAbilitysDebugChange(const std::string &bundleName, const bool &isAppDebug); - int32_t NotifyAbilitysAssertDebugChange(const std::shared_ptr &appRecord, bool isAssertDebug); + int32_t NotifyAbilitiesDebugChange(const std::string &bundleName, const bool &isAppDebug); + int32_t NotifyAbilitiesAssertDebugChange(const std::shared_ptr &appRecord, bool isAssertDebug); void SetProcessJITState(const std::shared_ptr appRecord); @@ -1518,6 +1716,9 @@ private: const std::shared_ptr &appInfo, const std::string &processName, AppSpawnStartMsg &startMsg); + /** + * Build message body for app spawn + */ int32_t CreateStartMsg(const std::string &processName, uint32_t startFlags, const int uid, const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, AppSpawnStartMsg &startMsg, std::shared_ptr want, const std::string &moduleName = "", const std::string &abilityName = "", @@ -1534,10 +1735,20 @@ private: void SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg); + /** + * Query ability for one want param + */ bool CreateAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo); + /** + * Build event info for one app record + */ AAFwk::EventInfo BuildEventInfo(std::shared_ptr appRecord) const; + /** + * @brief Call the callbacks to notify one process should go dying due fatal error. + * @param appRecord indicates the process is going to die. + */ void NotifyAppAttachFailed(std::shared_ptr appRecord); private: /** @@ -1605,7 +1816,7 @@ private: sptr windowVisibilityChangedListener_; sptr windowPidVisibilityChangedListener_; #endif //SUPPORT_SCREEN - std::vector> restartResedentTaskList_; + std::vector> restartResidentTaskList_; std::map> runningSharedBundleList_; std::map waitingDebugBundleList_; ffrt::mutex waitingDebugLock_; @@ -1617,7 +1828,7 @@ private: int32_t lastRenderUid_ = Constants::START_UID_FOR_RENDER_PROCESS; sptr abilityDebugResponse_; std::shared_ptr appDebugManager_; - ffrt::mutex killpedProcessMapLock_; + ffrt::mutex killedProcessMapLock_; mutable std::map killedProcessMap_; ffrt::mutex startChildProcessLock_; std::vector serviceExtensionWhiteList_; diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index a3eb1c4ed6..9016b85ea2 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -79,11 +79,11 @@ public: * CheckAppRunningRecordIsExist, Check whether the process of the app exists by bundle name and process Name. * * @param bundleName, Indicates the bundle name of the bundle.. - * @param ablityName, ablity name. + * @param abilityName, ability name. * * @return true if exist. */ - bool CheckAppRunningRecordIsExist(const std::string &bundleName, const std::string &ablityName); + bool CheckAppRunningRecordIsExist(const std::string &bundleName, const std::string &abilityName); #endif /** diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 3c8b82fef4..00bf6bac0a 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -308,15 +308,39 @@ public: */ sptr GetApplicationClient() const; + /** + * @brief Load a module and schedule the stage's lifecycle + * @param appInfo app info + * @param abilityInfo ability info + * @param token the ability's token + * @param hapModuleInfo module info + * @param want starting ability param + * @param abilityRecordId the record id of the ability + */ void AddModule(std::shared_ptr appInfo, std::shared_ptr abilityInfo, sptr token, const HapModuleInfo &hapModuleInfo, std::shared_ptr want, int32_t abilityRecordId); + /** + * @brief Batch adding modules whose stages will be loaded + * @param appInfo app info + * @param moduleInfos list of modules to be added + */ void AddModules(const std::shared_ptr &appInfo, const std::vector &moduleInfos); + /** + * @brief Search a module record by bundleName and moduleName + * @param bundleName bundleName of the module + * @param moduleName moduleName of the module + * @return the module record matched the params or null + */ std::shared_ptr GetModuleRecordByModuleName( - const std::string bundleName, const std::string &moduleName); + const std::string &bundleName, const std::string &moduleName); + /** + * @brief Get one ability's module record + * @param token represents the ability + */ std::shared_ptr GetModuleRunningRecordByToken(const sptr &token) const; std::shared_ptr GetModuleRunningRecordByTerminateLists(const sptr &token) const; @@ -446,7 +470,7 @@ public: * * @param token, the unique identification to the ability. * - * @return + * @return ability running record */ std::shared_ptr GetAbilityRunningRecordByToken(const sptr &token) const; @@ -528,27 +552,69 @@ public: int64_t GetEventId() const; + /** + * When the one process has no ability, it will go dying. + */ bool IsLastAbilityRecord(const sptr &token); bool IsLastPageAbilityRecord(const sptr &token); bool ExtensionAbilityRecordExists(); + /** + * @brief indicates one process will go dying. + * Then the process won't be reused. + */ void SetTerminating(); + /** + * @brief Whether the process is dying. + */ bool IsTerminating(); + /** + * @brief Whether the process should keep alive. + */ bool IsKeepAliveApp() const; + /** + * @brief Whether the process can keep empty alive. + */ bool IsEmptyKeepAliveApp() const; + /** + * @brief Whether the process is main process. + */ bool IsMainProcess() const; + /** + * @brief indicates one process can stay alive without any abilities. + * One case is that the process's stages being loaded + * + * @param isEmptyKeepAliveApp new value + */ void SetEmptyKeepAliveAppState(bool isEmptyKeepAliveApp); + /** + * @brief A process can config itself to keep alive or not. + * when one process started, this method will be called from ability mgr with data selected from db. + * + * @param isKeepAliveEnable new value + */ void SetKeepAliveEnableState(bool isKeepAliveEnable); + + /** + * @brief roughly considered as a value from the process's bundle info. + * + * @param isKeepAliveBundle new value + */ void SetKeepAliveBundle(bool isKeepAliveBundle); + /** + * @brief only the bundle's main process can stay alive. + * + * @param isMainProcess new value + */ void SetMainProcess(bool isMainProcess); void SetSingleton(bool isSingleton); @@ -594,21 +660,48 @@ public: void SetProcessAndExtensionType(const std::shared_ptr &abilityInfo); void SetSpecifiedAbilityFlagAndWant(int requestId, const AAFwk::Want &want, const std::string &moduleName); void SetScheduleNewProcessRequestState(int32_t requestId, const AAFwk::Want &want, const std::string &moduleName); + /** + * Is processing new process request + */ bool IsNewProcessRequest() const; + /** + * Is processing specified ability request + */ bool IsStartSpecifiedAbility() const; + /** + * Get the specified requestId, -1 for none specified + */ int32_t GetSpecifiedRequestId() const; + /** + * Called when one specified request is finished to set the request id to -1 + */ void ResetSpecifiedRequestId(); + /** + * call the scheduler to go acceptWant procedure + */ void ScheduleAcceptWant(const std::string &moduleName); + /** + * Called when acceptWant complete + */ void ScheduleAcceptWantDone(); void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName); void ScheduleNewProcessRequestDone(); void ApplicationTerminated(); + /** + * Get the want param for specified request + */ AAFwk::Want GetSpecifiedWant() const; AAFwk::Want GetNewProcessRequestWant() const; int32_t GetNewProcessRequestId() const; void ResetNewProcessRequestId(); void SetDebugApp(bool isDebugApp); + /** + * Indicate whether the process is a debugging one + */ bool IsDebugApp(); + /** + * debug flag or assert flag is set + */ bool IsDebugging() const; void SetErrorInfoEnhance(const bool errorInfoEnhance); void SetNativeDebug(bool isNativeDebug); @@ -680,12 +773,18 @@ public: ExtensionAbilityType GetExtensionType() const; ProcessType GetProcessType() const; + /** + * Notify Fault Data + * + * @param faultData the fault data. + * @return Returns ERR_OK on success, others on failure. + */ int32_t NotifyAppFault(const FaultData &faultData); #ifdef SUPPORT_SCREEN void ChangeWindowVisibility(const sptr &info); void OnWindowVisibilityChanged(const std::vector> &windowVisibilityInfos); #endif //SUPPORT_SCREEN - bool IsAbilitytiesBackground(); + bool IsAbilitiesBackground(); inline void SetAbilityForegroundingFlag() { diff --git a/services/appmgr/include/exit_resident_process_manager.h b/services/appmgr/include/exit_resident_process_manager.h index 5bd0d39b17..a6d5381ee0 100644 --- a/services/appmgr/include/exit_resident_process_manager.h +++ b/services/appmgr/include/exit_resident_process_manager.h @@ -44,7 +44,7 @@ class ExitResidentProcessManager { public: static ExitResidentProcessManager &GetInstance(); ~ExitResidentProcessManager(); - bool IsMemorySizeSufficent() const; + bool IsMemorySizeSufficient() const; bool RecordExitResidentBundleName(const std::string &bundleName, int32_t uid); void RecordExitResidentBundleDependedOnWeb(const std::string &bundleName, int32_t uid); int32_t HandleMemorySizeInSufficent(); diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 46df12a8e9..d9f66ebe36 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -629,7 +629,7 @@ bool AmsMgrScheduler::IsMemorySizeSufficent() TAG_LOGE(AAFwkTag::APPMGR, "verification failed"); return true; } - return amsMgrServiceInner_->IsMemorySizeSufficent(); + return amsMgrServiceInner_->IsMemorySizeSufficient(); } void AmsMgrScheduler::AttachedToStatusBar(const sptr &token) diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index c012ae1a43..8468a310b3 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -1510,14 +1510,14 @@ int32_t AppMgrService::GetAllUIExtensionProviderPid(pid_t hostPid, std::vector

GetAllUIExtensionProviderPid(hostPid, providerPids); } -int32_t AppMgrService::NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) +int32_t AppMgrService::NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); return ERR_INVALID_OPERATION; } - return appMgrServiceInner_->NotifyMemorySizeStateChanged(isMemorySizeSufficent); + return appMgrServiceInner_->NotifyMemorySizeStateChanged(isMemorySizeSufficient); } int32_t AppMgrService::SetSupportedProcessCacheSelf(bool isSupport) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 452f97fc30..24131c77e1 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -2249,7 +2249,7 @@ int32_t AppMgrServiceInner::KillProcessByPid(const pid_t pid, const std::string& eventInfo.versionCode = applicationInfo->versionCode; } if (ret >= 0) { - std::lock_guard lock(killpedProcessMapLock_); + std::lock_guard lock(killedProcessMapLock_); int64_t killTime = std::chrono::duration_cast(std::chrono:: system_clock::now().time_since_epoch()).count(); killedProcessMap_.emplace(killTime, appRecord->GetProcessName()); @@ -2600,7 +2600,7 @@ void AppMgrServiceInner::KillProcessByAbilityToken(const sptr &to // before exec ScheduleProcessSecurityExit return // The resident process won't let him die - if (appRecord->IsKeepAliveApp() && IsMemorySizeSufficent()) { + if (appRecord->IsKeepAliveApp() && IsMemorySizeSufficient()) { return; } @@ -3469,7 +3469,7 @@ bool AppMgrServiceInner::SendProcessStartEvent(const std::shared_ptr(std::chrono:: system_clock::now().time_since_epoch()).count(); for (auto iter = killedProcessMap_.begin(); iter != killedProcessMap_.end();) { @@ -3948,9 +3948,9 @@ void AppMgrServiceInner::RestartResidentProcess(std::shared_ptr &appRunningRecord) { return (appRecord != nullptr && appRecord->GetBundleName() == appRunningRecord->GetBundleName()); }; - auto findIter = find_if(restartResedentTaskList_.begin(), restartResedentTaskList_.end(), findRestartResidentTask); - if (findIter != restartResedentTaskList_.end()) { - restartResedentTaskList_.erase(findIter); + auto findIter = find_if(restartResidentTaskList_.begin(), restartResidentTaskList_.end(), findRestartResidentTask); + if (findIter != restartResidentTaskList_.end()) { + restartResidentTaskList_.erase(findIter); } if (!CheckRemoteClient() || !appRecord || !appRunningManager_) { @@ -6344,7 +6344,7 @@ int32_t AppMgrServiceInner::AttachAppDebug(const std::string &bundleName) appDebugManager_->StartDebug(debugInfos); } - NotifyAbilitysDebugChange(bundleName, true); + NotifyAbilitiesDebugChange(bundleName, true); return ERR_OK; } @@ -6370,7 +6370,7 @@ int32_t AppMgrServiceInner::DetachAppDebug(const std::string &bundleName) } } - NotifyAbilitysDebugChange(bundleName, false); + NotifyAbilitiesDebugChange(bundleName, false); return ERR_OK; } @@ -6582,7 +6582,7 @@ int32_t AppMgrServiceInner::RegisterAbilityDebugResponse(const sptr &appRecord, bool isAssertDebug) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); @@ -6682,10 +6682,10 @@ void AppMgrServiceInner::ClearAppRunningDataForKeepAlive(const std::shared_ptrGetBundleName()) && ExitResidentProcessManager::GetInstance().RecordExitResidentBundleName(appRecord->GetBundleName(), appRecord->GetUid())) { - TAG_LOGI(AAFwkTag::APPMGR, "memory size insufficent"); + TAG_LOGI(AAFwkTag::APPMGR, "memory size insufficient"); return; } - TAG_LOGI(AAFwkTag::APPMGR, "memory size sufficent"); + TAG_LOGI(AAFwkTag::APPMGR, "memory size sufficient"); auto restartProcess = [appRecord, innerService = shared_from_this()]() { innerService->RestartResidentProcess(appRecord); }; @@ -6700,13 +6700,13 @@ void AppMgrServiceInner::ClearAppRunningDataForKeepAlive(const std::shared_ptrGetBundleName() == appRunningRecord->GetBundleName()); }; - auto findIter = find_if(restartResedentTaskList_.begin(), restartResedentTaskList_.end(), + auto findIter = find_if(restartResidentTaskList_.begin(), restartResidentTaskList_.end(), findRestartResidentTask); - if (findIter != restartResedentTaskList_.end()) { + if (findIter != restartResidentTaskList_.end()) { TAG_LOGW(AAFwkTag::APPMGR, "reboot task already registered"); return; } - restartResedentTaskList_.emplace_back(appRecord); + restartResidentTaskList_.emplace_back(appRecord); TAG_LOGD(AAFwkTag::APPMGR, "Post restart resident process delay task."); taskHandler_->SubmitTask(restartProcess, "RestartResidentProcessDelayTask", RESTART_INTERVAL_TIME); } @@ -7372,7 +7372,7 @@ void AppMgrServiceInner::SetAppAssertionPauseState(bool flag) flag ? appDebugManager_->StartDebug(debugInfos) : appDebugManager_->StopDebug(debugInfos); } - NotifyAbilitysAssertDebugChange(appRecord, flag); + NotifyAbilitiesAssertDebugChange(appRecord, flag); } int32_t AppMgrServiceInner::UpdateRenderState(pid_t renderPid, int32_t state) @@ -7477,10 +7477,10 @@ int32_t AppMgrServiceInner::GetAllUIExtensionProviderPid(pid_t hostPid, std::vec return appRunningManager_->GetAllUIExtensionProviderPid(hostPid, providerPids); } -int32_t AppMgrServiceInner::NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) +int32_t AppMgrServiceInner::NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) { - TAG_LOGI(AAFwkTag::APPMGR, "isMemorySizeSufficent: %{public}d", - isMemorySizeSufficent); + TAG_LOGI(AAFwkTag::APPMGR, "isMemorySizeSufficient: %{public}d", + isMemorySizeSufficient); bool isMemmgrCall = AAFwk::PermissionVerification::GetInstance()->CheckSpecificSystemAbilityAccessPermission( MEMMGR_PROC_NAME); bool isSupportCall = OHOS::system::GetBoolParameter(SUPPORT_CALL_NOTIFY_MEMORY_CHANGED, false); @@ -7489,7 +7489,7 @@ int32_t AppMgrServiceInner::NotifyMemorySizeStateChanged(bool isMemorySizeSuffic return ERR_PERMISSION_DENIED; } - if (!isMemorySizeSufficent) { + if (!isMemorySizeSufficient) { auto ret = ExitResidentProcessManager::GetInstance().HandleMemorySizeInSufficent(); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "handleMemorySizeInSufficent fail, ret: %{public}d", ret); @@ -7517,9 +7517,9 @@ int32_t AppMgrServiceInner::NotifyMemorySizeStateChanged(bool isMemorySizeSuffic return ERR_OK; } -bool AppMgrServiceInner::IsMemorySizeSufficent() +bool AppMgrServiceInner::IsMemorySizeSufficient() { - return ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent(); + return ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient(); } void AppMgrServiceInner::NotifyAppPreCache(int32_t pid, int32_t userId) diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index fbd793d90c..b171a67a93 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -166,7 +166,7 @@ std::shared_ptr AppRunningManager::CheckAppRunningRecordIsExis } #ifdef APP_NO_RESPONSE_DIALOG -bool AppRunningManager::CheckAppRunningRecordIsExist(const std::string &bundleName, const std::string &ablityName) +bool AppRunningManager::CheckAppRunningRecordIsExist(const std::string &bundleName, const std::string &abilityName) { std::lock_guard guard(runningRecordMapMutex_); if (appRunningRecordMap_.empty()) { @@ -183,7 +183,7 @@ bool AppRunningManager::CheckAppRunningRecordIsExist(const std::string &bundleNa const auto &abilityRunningRecordMap = appRecord->GetAbilities(); for (const auto &abilityItem : abilityRunningRecordMap) { const auto &abilityRunning = abilityItem.second; - if (abilityRunning && abilityRunning->GetName() == ablityName) { + if (abilityRunning && abilityRunning->GetName() == abilityName) { return true; } } @@ -283,7 +283,7 @@ bool AppRunningManager::ProcessExitByBundleName( // condition [!appRecord->IsKeepAliveApp()] Is to not kill the resident process. // Before using this method, consider whether you need. if (appRecord && (!appRecord->IsKeepAliveApp() || - !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent())) { + !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient())) { pid_t pid = appRecord->GetPriorityObject()->GetPid(); auto appInfoList = appRecord->GetAppInfoList(); auto isExist = [&bundleName](const std::shared_ptr &appInfo) { @@ -567,7 +567,7 @@ void AppRunningManager::HandleAbilityAttachTimeOut(const sptr &to } if ((isPage || appRecord->IsLastAbilityRecord(token)) && (!appRecord->IsKeepAliveApp() || - !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent())) { + !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient())) { appRecord->SetTerminating(); } @@ -601,7 +601,7 @@ void AppRunningManager::PrepareTerminate(const sptr &token, bool auto isLastAbility = clearMissionFlag ? appRecord->IsLastPageAbilityRecord(token) : appRecord->IsLastAbilityRecord(token); if (isLastAbility && (!appRecord->IsKeepAliveApp() || - !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent())) { + !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient())) { auto cacheProcMgr = DelayedSingleton::GetInstance(); if (cacheProcMgr != nullptr && cacheProcMgr->IsAppShouldCache(appRecord)) { cacheProcMgr->PenddingCacheProcess(appRecord); @@ -663,7 +663,7 @@ void AppRunningManager::TerminateAbility(const sptr &token, bool #endif //SUPPORT_SCREEN auto isLauncherApp = appRecord->GetApplicationInfo()->isLauncherApp; if (isLastAbility && (!appRecord->IsKeepAliveApp() || - !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent()) && !isLauncherApp) { + !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient()) && !isLauncherApp) { auto cacheProcMgr = DelayedSingleton::GetInstance(); if (cacheProcMgr != nullptr && cacheProcMgr->IsAppShouldCache(appRecord)) { cacheProcMgr->PenddingCacheProcess(appRecord); diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index c86a018e1b..f31a2ed4a2 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -404,13 +404,13 @@ const std::string &AppRunningRecord::GetAppIdentifier() const const std::map, std::shared_ptr> AppRunningRecord::GetAbilities() { - std::map, std::shared_ptr> abilitysMap; + std::map, std::shared_ptr> abilitiesMap; auto moduleRecordList = GetAllModuleRecord(); for (const auto &moduleRecord : moduleRecordList) { auto abilities = moduleRecord->GetAbilities(); - abilitysMap.insert(abilities.begin(), abilities.end()); + abilitiesMap.insert(abilities.begin(), abilities.end()); } - return abilitysMap; + return abilitiesMap; } sptr AppRunningRecord::GetApplicationClient() const @@ -808,7 +808,7 @@ void AppRunningRecord::AddModule(std::shared_ptr appInfo, } std::shared_ptr AppRunningRecord::GetModuleRecordByModuleName( - const std::string bundleName, const std::string &moduleName) + const std::string &bundleName, const std::string &moduleName) { TAG_LOGD(AAFwkTag::APPMGR, "called"); auto moduleRecords = hapModules_.find(bundleName); @@ -1208,14 +1208,14 @@ void AppRunningRecord::AbilityTerminated(const sptr &token) EVENT_KEY_BUNDLE_NAME, appInfo->bundleName, EVENT_KEY_SUPPORT_STATE, state); if (moduleRecord->GetAbilities().empty() && (!IsKeepAliveApp() || AAFwk::UIExtensionUtils::IsUIExtension(GetExtensionType()) - || !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent()) && !needCache) { + || !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient()) && !needCache) { RemoveModuleRecord(moduleRecord, isExtensionDebug); } auto moduleRecordList = GetAllModuleRecord(); if (moduleRecordList.empty() && (!IsKeepAliveApp() || AAFwk::UIExtensionUtils::IsUIExtension(GetExtensionType()) - || !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficent()) && !isExtensionDebug + || !ExitResidentProcessManager::GetInstance().IsMemorySizeSufficient()) && !isExtensionDebug && !needCache) { ScheduleTerminate(); } @@ -1981,7 +1981,7 @@ int32_t AppRunningRecord::NotifyAppFault(const FaultData &faultData) return appLifeCycleDeal_->NotifyAppFault(faultData); } -bool AppRunningRecord::IsAbilitytiesBackground() +bool AppRunningRecord::IsAbilitiesBackground() { std::lock_guard hapModulesLock(hapModulesLock_); for (const auto &iter : hapModules_) { @@ -2014,7 +2014,7 @@ void AppRunningRecord::ChangeWindowVisibility(const sptrwindowId_); if (iter != windowIds_.end() && info->visibilityState_ == OHOS::Rosen::WindowVisibilityState::WINDOW_VISIBILITY_STATE_TOTALLY_OCCUSION) { @@ -2063,7 +2063,7 @@ void AppRunningRecord::OnWindowVisibilityChanged( SetApplicationPendingState(ApplicationPendingState::FOREGROUNDING); ScheduleForegroundRunning(); } - if (windowIds_.empty() && IsAbilitytiesBackground() && curState_ == ApplicationState::APP_STATE_FOREGROUND) { + if (windowIds_.empty() && IsAbilitiesBackground() && curState_ == ApplicationState::APP_STATE_FOREGROUND) { SetApplicationPendingState(ApplicationPendingState::BACKGROUNDING); ScheduleBackgroundRunning(); } @@ -2072,7 +2072,7 @@ void AppRunningRecord::OnWindowVisibilityChanged( if (!windowIds_.empty()) { SetApplicationPendingState(ApplicationPendingState::FOREGROUNDING); } - if (windowIds_.empty() && IsAbilitytiesBackground()) { + if (windowIds_.empty() && IsAbilitiesBackground()) { SetApplicationPendingState(ApplicationPendingState::BACKGROUNDING); } } diff --git a/services/appmgr/src/exit_resident_process_manager.cpp b/services/appmgr/src/exit_resident_process_manager.cpp index cea7fe470d..b340b8d6fe 100644 --- a/services/appmgr/src/exit_resident_process_manager.cpp +++ b/services/appmgr/src/exit_resident_process_manager.cpp @@ -37,7 +37,7 @@ ExitResidentProcessManager &ExitResidentProcessManager::GetInstance() return instance; } -bool ExitResidentProcessManager::IsMemorySizeSufficent() const +bool ExitResidentProcessManager::IsMemorySizeSufficient() const { std::lock_guard lock(mutexLock_); return currentMemorySizeState_ == MemorySizeState::MEMORY_SIZE_SUFFICIENT; diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_client.h b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_client.h index fb684aab95..61a1d28dc4 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_client.h +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_client.h @@ -131,10 +131,10 @@ public: /** * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. - * Obtains running isntance keys of multi-instance app that are running on the device. + * Obtains running instance keys of multi-instance app that are running on the device. * * @param bundlename, bundle name in Application record. - * @param instanceKeys, output instance keys of the multi-insatnce app. + * @param instanceKeys, output instance keys of the multi-instance app. * @return ERR_OK ,return back success,others fail. */ virtual AppMgrResultCode GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_interface.h b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_interface.h index 237b12a33e..cad5c60673 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_interface.h +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/include/appmgr/app_mgr_interface.h @@ -113,10 +113,10 @@ public: /** * GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project. - * Obtains running isntance keys of multi-instance app that are running on the device. + * Obtains running instance keys of multi-instance app that are running on the device. * * @param bundlename, bundle name in Application record. - * @param instanceKeys, output instance keys of the multi-insatnce app. + * @param instanceKeys, output instance keys of the multi-instance app. * @return ERR_OK ,return back success,others fail. */ virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName, diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h index 7b54480d7e..087c80ccf0 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h @@ -70,7 +70,7 @@ public: MOCK_METHOD1(GetWaitingDebugApp, int32_t(std::vector &debugInfoList)); MOCK_METHOD1(IsWaitingDebugApp, bool(const std::string &bundleName)); MOCK_METHOD0(ClearNonPersistWaitingDebugFlag, void()); - MOCK_METHOD0(IsMemorySizeSufficent, bool()); + MOCK_METHOD0(IsMemorySizeSufficient, bool()); MOCK_METHOD4(StartNativeChildProcess, int32_t(const pid_t hostPid, const std::string &libName, int32_t childProcessCount, const sptr &callback)); void StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t) diff --git a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp index f9411bc6cf..dcc8631a4a 100644 --- a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp +++ b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp @@ -2453,7 +2453,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFWK_Start_Service_With_SessionInfo_001, Te abilityRequest_.sessionInfo = nullptr; WaitUntilTaskDone(TaskHandler()); - auto service = ConnectManager()->GetUIExtensioBySessionInfo(sessionInfo); + auto service = ConnectManager()->GetUIExtensionBySessionInfo(sessionInfo); EXPECT_EQ(static_cast(ConnectManager()->GetServiceMap().size()), 1); } diff --git a/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp b/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp index 9c2120615a..3cc305c0fc 100644 --- a/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp +++ b/test/unittest/ams_app_running_record_test/ams_app_running_record_test.cpp @@ -2986,7 +2986,7 @@ HWTEST_F(AmsAppRunningRecordTest, IsAbilitytiesBackground_001, TestSize.Level1) // 1. create AppRunningRecord and verify default status auto record = GetTestAppRunningRecord(); EXPECT_NE(record, nullptr); - EXPECT_TRUE(record->IsAbilitytiesBackground()); + EXPECT_TRUE(record->IsAbilitiesBackground()); // 2. create AbilityInfo and AppInfo, and construct ModuleRunningRecord std::shared_ptr appInfo = std::make_shared(); @@ -3011,7 +3011,7 @@ HWTEST_F(AmsAppRunningRecordTest, IsAbilitytiesBackground_001, TestSize.Level1) record->hapModules_.emplace(bundleName, moduleRecords); // 4. verify function - EXPECT_FALSE(record->IsAbilitytiesBackground()); + EXPECT_FALSE(record->IsAbilitiesBackground()); moduleRecord->abilities_.clear(); abilityRecord->state_ = AbilityState::ABILITY_STATE_BACKGROUND; @@ -3019,7 +3019,7 @@ HWTEST_F(AmsAppRunningRecordTest, IsAbilitytiesBackground_001, TestSize.Level1) moduleRecords.clear(); moduleRecords.push_back(moduleRecord); record->hapModules_.emplace(bundleName, moduleRecords); - EXPECT_TRUE(record->IsAbilitytiesBackground()); + EXPECT_TRUE(record->IsAbilitiesBackground()); GTEST_LOG_(INFO) << "IsAbilitytiesBackground_001 end."; } diff --git a/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp b/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp index 2f5b73f615..d6a0e8424e 100644 --- a/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp +++ b/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp @@ -1692,7 +1692,7 @@ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_ClearProcessByToke /** * @tc.name: AmsMgrSchedulerSecondTest_IsMemorySizeSufficent_001 - * @tc.desc: Test IsMemorySizeSufficent + * @tc.desc: Test IsMemorySizeSufficient * @tc.type: FUNC */ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsMemorySizeSufficent_001, TestSize.Level1) @@ -1713,7 +1713,7 @@ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsMemorySizeSuffic /* * @tc.name: AmsMgrSchedulerSecondTest_IsMemorySizeSufficent_002 - * @tc.desc: Test IsMemorySizeSufficent + * @tc.desc: Test IsMemorySizeSufficient * @tc.type: FUNC */ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsMemorySizeSufficent_002, TestSize.Level1) @@ -1735,7 +1735,7 @@ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsMemorySizeSuffic /* * @tc.name: AmsMgrSchedulerSecondTest_IsMemorySizeSufficent_003 - * @tc.desc: Test IsMemorySizeSufficent + * @tc.desc: Test IsMemorySizeSufficient * @tc.type: FUNC */ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_IsMemorySizeSufficent_003, TestSize.Level1) diff --git a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp index 4db1331bfc..9bf7ee9c4f 100644 --- a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp +++ b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp @@ -727,11 +727,11 @@ HWTEST_F(AmsMgrSchedulerTest, GetRunningProcessInfoByToken_001, TestSize.Level0) /* * Feature: AmsMgrScheduler - * Function: IsMemorySizeSufficent + * Function: IsMemorySizeSufficient * SubFunction: NA - * FunctionPoints: AmsMgrScheduler IsMemorySizeSufficent + * FunctionPoints: AmsMgrScheduler IsMemorySizeSufficient * EnvConditions: NA - * CaseDescription: Verify IsMemorySizeSufficent + * CaseDescription: Verify IsMemorySizeSufficient */ HWTEST_F(AmsMgrSchedulerTest, IsMemorySizeSufficent_001, TestSize.Level0) { diff --git a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp index f9834fd36f..2d1c4f87f3 100644 --- a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp +++ b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp @@ -1324,8 +1324,8 @@ HWTEST_F(AppMgrClientTest, GetAppRunningUniqueIdByPid_001, TestSize.Level0) HWTEST_F(AppMgrClientTest, NotifyMemorySizeStateChanged_001, TestSize.Level0) { auto appMgrClient = std::make_unique(); - bool isMemorySizeSufficent = false; - int32_t ret = appMgrClient->NotifyMemorySizeStateChanged(isMemorySizeSufficent); + bool isMemorySizeSufficient = false; + int32_t ret = appMgrClient->NotifyMemorySizeStateChanged(isMemorySizeSufficient); EXPECT_EQ(ret, 1); } diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 831a8f7d1b..245e158876 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -2045,14 +2045,14 @@ HWTEST_F(AppMgrServiceInnerTest, CheckGetRunningInfoPermission_001, TestSize.Lev */ HWTEST_F(AppMgrServiceInnerTest, IsMemorySizeSufficent_001, TestSize.Level0) { - TAG_LOGI(AAFwkTag::TEST, "IsMemorySizeSufficent start"); + TAG_LOGI(AAFwkTag::TEST, "IsMemorySizeSufficient start"); auto appMgrServiceInner = std::make_shared(); EXPECT_NE(appMgrServiceInner, nullptr); - appMgrServiceInner->IsMemorySizeSufficent(); + appMgrServiceInner->IsMemorySizeSufficient(); appMgrServiceInner->appRunningManager_ = nullptr; - appMgrServiceInner->IsMemorySizeSufficent(); + appMgrServiceInner->IsMemorySizeSufficient(); TAG_LOGI(AAFwkTag::TEST, "IsMemorySizeSufficent_001 end"); } @@ -3644,7 +3644,7 @@ HWTEST_F(AppMgrServiceInnerTest, RegisterAbilityDebugResponse_001, TestSize.Leve /** * @tc.name: NotifyAbilitysDebugChange_001 - * @tc.desc: Test the status of NotifyAbilitysDebugChange. + * @tc.desc: Test the status of NotifyAbilitiesDebugChange. * @tc.type: FUNC */ HWTEST_F(AppMgrServiceInnerTest, NotifyAbilitysDebugChange_001, TestSize.Level0) @@ -3655,7 +3655,7 @@ HWTEST_F(AppMgrServiceInnerTest, NotifyAbilitysDebugChange_001, TestSize.Level0) bool isAppDebug = true; appMgrServiceInner->appRunningManager_ = std::make_shared(); appMgrServiceInner->appDebugManager_ = std::make_shared(); - auto result = appMgrServiceInner->NotifyAbilitysDebugChange(bundleName, isAppDebug); + auto result = appMgrServiceInner->NotifyAbilitiesDebugChange(bundleName, isAppDebug); EXPECT_EQ(result, ERR_NO_INIT); } diff --git a/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp b/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp index deee8b998e..c89d4ca528 100644 --- a/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp +++ b/test/unittest/app_running_manager_second_test/app_running_manager_second_test.cpp @@ -127,7 +127,7 @@ HWTEST_F(AppRunningManagerSecondTest, AppRunningManager_CheckAppRunningRecordIsE record->SetRestartAppFlag(true); ret = appRunningManager->CheckAppRunningRecordIsExistByUid(USR_ID_100); EXPECT_FALSE(ret); - + /** * @tc.steps: step4. call CheckAppRunningRecordIsExistByUid USR_ID_101 * @tc.expected: step4. expect call CheckAppRunningRecordIsExistByUid false @@ -294,17 +294,17 @@ HWTEST_F(AppRunningManagerSecondTest, AppRunningManager_ProcessExitByBundleName_ record1->SetKeepAliveEnableState(true); record1->SetMainProcess(true); record1->GetPriorityObject()->SetPid(10000); // 10000 means valid process id - ExitResidentProcessManager::GetInstance().HandleMemorySizeInSufficent(); // marked mem insufficent + ExitResidentProcessManager::GetInstance().HandleMemorySizeInSufficent(); // marked mem insufficient std::list pids; appRunningManager->ProcessExitByBundleName(BUNDLE_NAME, pids, false); EXPECT_TRUE(pids.empty()); /** * @tc.steps: step2. process resident process and ExitResidentProcessManager Memory Size Insufficent - * @tc.expected: step2. expect pids not empty, memory size sufficent + * @tc.expected: step2. expect pids not empty, memory size sufficient */ pids.clear(); - ExitResidentProcessManager::GetInstance().HandleMemorySizeSufficient(processInfos); // marked mem sufficent + ExitResidentProcessManager::GetInstance().HandleMemorySizeSufficient(processInfos); // marked mem sufficient appRunningManager->ProcessExitByBundleName(BUNDLE_NAME, pids, true); EXPECT_TRUE(pids.empty()); } diff --git a/test/unittest/exit_resident_process_manager_test/exit_resident_process_manager_test.cpp b/test/unittest/exit_resident_process_manager_test/exit_resident_process_manager_test.cpp index 3c5b077414..4bdc1b9b9d 100644 --- a/test/unittest/exit_resident_process_manager_test/exit_resident_process_manager_test.cpp +++ b/test/unittest/exit_resident_process_manager_test/exit_resident_process_manager_test.cpp @@ -52,13 +52,13 @@ void ExitResidentProcessManagerTest::TearDown() /** * @tc.name: IsMemorySizeSufficent_001 - * @tc.desc: Verify that the IsMemorySizeSufficent interface calls normally + * @tc.desc: Verify that the IsMemorySizeSufficient interface calls normally * @tc.type: FUNC */ HWTEST_F(ExitResidentProcessManagerTest, IsMemorySizeSufficent_001, TestSize.Level1) { auto exitResidentProcessManager = std::make_shared(); - EXPECT_EQ(exitResidentProcessManager->IsMemorySizeSufficent(), true); + EXPECT_EQ(exitResidentProcessManager->IsMemorySizeSufficient(), true); } /** From d909e4a355c048fb4cb50afae07497e0cadd1ea5 Mon Sep 17 00:00:00 2001 From: Tintin9529 Date: Wed, 25 Sep 2024 14:41:48 +0800 Subject: [PATCH 20/26] add tdd Signed-off-by: Tintin9529 --- .../BUILD.gn | 2 + .../ability_manager_service_fourth_test.cpp | 128 ++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/test/unittest/ability_manager_service_fourth_test/BUILD.gn b/test/unittest/ability_manager_service_fourth_test/BUILD.gn index d067398fdb..4ffb560d14 100644 --- a/test/unittest/ability_manager_service_fourth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_fourth_test/BUILD.gn @@ -49,6 +49,8 @@ ohos_unittest("ability_manager_service_fourth_test") { "${ability_runtime_services_path}/abilitymgr/src/auto_startup_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/exit_reason.cpp", "${ability_runtime_services_path}/abilitymgr/src/insight_intent_execute_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/modal_system_dialog/modal_system_dialog_ui_extension.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/modal_system_dialog_util.cpp", "${ability_runtime_services_path}/common/src/ffrt_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/queue_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/task_handler_wrap.cpp", diff --git a/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp b/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp index 0d1ffd079f..a957363062 100644 --- a/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp +++ b/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp @@ -24,6 +24,8 @@ #include "mock_parameters.h" #include "ability_manager_service.h" #include "insight_intent_execute_manager.h" +#include "modal_system_dialog/modal_system_dialog_ui_extension.h" +#include "utils/modal_system_dialog_util.h" #undef private #undef protected #include "hilog_tag_wrapper.h" @@ -98,6 +100,63 @@ sptr AbilityManagerServiceFourthTest::MockToken(AbilityType abilityType) return abilityRecord->GetToken(); } +class IRemoteObjectMocker : public IRemoteObject { +public: + IRemoteObjectMocker() : IRemoteObject { u"IRemoteObjectMocker" } {} + + ~IRemoteObjectMocker() {} + + int32_t GetObjectRefCount() + { + return 0; + } + + int SendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) + { + int32_t key = data.ReadInt32(); + std::string parameters = Str16ToStr8(data.ReadString16()); + std::string command = Str16ToStr8(data.ReadString16()); + if (command.compare("test") == 0) { + isSuccess_ = true; + return 0; + } + isSuccess_ = false; + return -1; + } + + bool IsProxyObject() const + { + return true; + } + + bool CheckObjectLegality() const + { + return true; + } + + bool AddDeathRecipient(const sptr& recipient) + { + return true; + } + + bool RemoveDeathRecipient(const sptr& recipient) + { + return true; + } + + sptr AsInterface() + { + return nullptr; + } + + int Dump(int fd, const std::vector& args) + { + return 0; + } + +public: + bool isSuccess_ = false; +}; /* * Feature: AbilityManagerService @@ -1423,5 +1482,74 @@ HWTEST_F(AbilityManagerServiceFourthTest, SetAbilityRequestSessionInfo_003, Test TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest SetAbilityRequestSessionInfo_003 end"); } +/* + * Feature: AbilityManagerService + * Function: CheckDebugAppNotInDeveloperMode + * SubFunction: NA + * FunctionPoints: ModalSystemDialogUtil CheckDebugAppNotInDeveloperMode + */ +HWTEST_F(AbilityManagerServiceFourthTest, CheckDebugAppNotInDeveloperMode_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest CheckDebugAppNotInDeveloperMode start"); + bool srcDeveloperMode = OHOS::system::GetBoolParameter(DEVELOPER_MODE_STATE, false); + + OHOS::system::SetBoolParameter(DEVELOPER_MODE_STATE, false); + ApplicationInfo applicationInfo; + applicationInfo.appProvisionType = "release"; + EXPECT_FALSE(ModalSystemDialogUtil::CheckDebugAppNotInDeveloperMode(applicationInfo)); + + applicationInfo.appProvisionType = "debug"; + EXPECT_TRUE(ModalSystemDialogUtil::CheckDebugAppNotInDeveloperMode(applicationInfo)); + + OHOS::system::SetBoolParameter(DEVELOPER_MODE_STATE, true); + applicationInfo.appProvisionType = "release"; + EXPECT_FALSE(ModalSystemDialogUtil::CheckDebugAppNotInDeveloperMode(applicationInfo)); + + applicationInfo.appProvisionType = "debug"; + EXPECT_FALSE(ModalSystemDialogUtil::CheckDebugAppNotInDeveloperMode(applicationInfo)); + + OHOS::system::SetBoolParameter(DEVELOPER_MODE_STATE, srcDeveloperMode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest CheckDebugAppNotInDeveloperMode end"); +} + +/* + * Feature: AbilityManagerService + * Function: CreateModalUIExtension + * SubFunction: NA + * FunctionPoints: ModalSystemDialogUIExtension CreateModalUIExtension + */ +HWTEST_F(AbilityManagerServiceFourthTest, ModalSystemDialogUIExtension_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ModalSystemDialogUIExtension_001 start"); + auto modalSystemDialog = std::make_shared(); + ASSERT_NE(modalSystemDialog, nullptr); + std::string commandStr = "test"; + auto result = modalSystemDialog->CreateModalUIExtension(commandStr); + EXPECT_FALSE(result); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ModalSystemDialogUIExtension_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OnAbilityConnectDone + * SubFunction: NA + * FunctionPoints: ModalSystemDialogUIExtension OnAbilityConnectDone + */ +HWTEST_F(AbilityManagerServiceFourthTest, OnAbilityConnectDone_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest OnAbilityConnectDone_001 start"); + sptr dialogConnection( + new (std::nothrow) ModalSystemDialogUIExtension::DialogConnection("test")); + ASSERT_NE(dialogConnection, nullptr); + ElementName element("", "", "ability", ""); + dialogConnection->OnAbilityConnectDone(element, nullptr, 0); + sptr iRemoteObject = new IRemoteObjectMocker(); + dialogConnection->OnAbilityConnectDone(element, iRemoteObject, 0); + EXPECT_TRUE(iRemoteObject->isSuccess_); + dialogConnection->commandStr_ = ""; + dialogConnection->OnAbilityConnectDone(element, iRemoteObject, 0); + EXPECT_FALSE(iRemoteObject->isSuccess_); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest OnAbilityConnectDone_001 end"); +} } // namespace AAFwk } // namespace OHOS From 81ba3d609b1eab1f70de1d5d01dcdbcd452ccc74 Mon Sep 17 00:00:00 2001 From: zhangyuhang72 Date: Wed, 25 Sep 2024 15:12:35 +0800 Subject: [PATCH 21/26] =?UTF-8?q?=E5=AD=90=E8=BF=9B=E7=A8=8Bfd=E6=9C=AA?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangyuhang72 Change-Id: I3426ae6b51a47c08aaed2b14d308997799e14d9b --- services/appmgr/include/child_process_record.h | 1 + services/appmgr/src/child_process_record.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/services/appmgr/include/child_process_record.h b/services/appmgr/include/child_process_record.h index cdc00f3f48..50e30d6a61 100644 --- a/services/appmgr/include/child_process_record.h +++ b/services/appmgr/include/child_process_record.h @@ -78,6 +78,7 @@ private: std::string processName_; std::string srcEntry_; std::string entryFunc_; + std::map fds_; std::weak_ptr hostRecord_; sptr scheduler_ = nullptr; sptr deathRecipient_ = nullptr; diff --git a/services/appmgr/src/child_process_record.cpp b/services/appmgr/src/child_process_record.cpp index 2e607d8720..327acb41d6 100644 --- a/services/appmgr/src/child_process_record.cpp +++ b/services/appmgr/src/child_process_record.cpp @@ -27,6 +27,7 @@ ChildProcessRecord::ChildProcessRecord(pid_t hostPid, const ChildProcessRequest hostRecord_(hostRecord), isStartWithDebug_(request.isStartWithDebug) { srcEntry_ = request.srcEntry; + fds_ = request.args.fds; if (childProcessType_ == CHILD_PROCESS_TYPE_NATIVE_ARGS) { auto pos = request.srcEntry.rfind(":"); if (pos != std::string::npos) { @@ -49,6 +50,9 @@ ChildProcessRecord::ChildProcessRecord(pid_t hostPid, const std::string &libName ChildProcessRecord::~ChildProcessRecord() { TAG_LOGD(AAFwkTag::APPMGR, "called"); + for (const auto &item : fds_) { + close(item.second); + } } std::shared_ptr ChildProcessRecord::CreateChildProcessRecord(pid_t hostPid, From dfeee7bad0451365bde6b421cb97567443a9831f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E5=97=A3=E9=92=8A?= Date: Wed, 25 Sep 2024 15:49:24 +0800 Subject: [PATCH 22/26] =?UTF-8?q?CheckUriPermission=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 段嗣钊 Change-Id: I48143bd4f25951be02ac10a009a92125ff05e678 --- bundle.json | 1 + .../bundle_mgr_helper.cpp | 13 ++ .../bundle_mgr_helper.h | 1 + services/abilitymgr/include/ability_record.h | 4 +- services/abilitymgr/include/uri_utils.h | 6 + .../src/ability_connect_manager.cpp | 3 +- .../src/ability_manager_service.cpp | 14 ++ services/abilitymgr/src/ability_record.cpp | 69 +++---- services/abilitymgr/src/uri_utils.cpp | 61 ++++++ services/uripermmgr/BUILD.gn | 8 + .../include/media_permission_manager.h | 50 +++++ .../uri_permission_manager_stub_impl.h | 10 +- .../uripermmgr/include/uri_permission_utils.h | 1 + .../src/media_permission_manager.cpp | 117 ++++++++++++ .../src/uri_permission_manager_stub_impl.cpp | 176 ++++++++---------- .../uripermmgr/src/uri_permission_utils.cpp | 17 ++ .../ability_record_test.cpp | 10 +- .../mock/include/mock_accesstoken_kit.h | 3 + .../mock/include/mock_bundle_mgr_helper.h | 2 + .../include/mock_media_permission_manager.h | 42 +++++ .../mock/src/mock_accesstoken_kit.cpp | 9 + .../mock/src/mock_bundle_mgr_helper.cpp | 6 + .../uri_permission_impl_test.cpp | 149 ++++----------- 23 files changed, 506 insertions(+), 266 deletions(-) create mode 100644 services/uripermmgr/include/media_permission_manager.h create mode 100644 services/uripermmgr/src/media_permission_manager.cpp create mode 100644 test/unittest/uri_permission_impl_test/mock/include/mock_media_permission_manager.h diff --git a/bundle.json b/bundle.json index 83769e4673..3a732cb12f 100644 --- a/bundle.json +++ b/bundle.json @@ -77,6 +77,7 @@ "jsoncpp", "kv_store", "libuv", + "media_library", "memmgr", "memory_utils", "napi", diff --git a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp index 3e64de339a..d95edf3f7e 100644 --- a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp +++ b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp @@ -196,6 +196,19 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, return bundleMgr->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo); } +std::string BundleMgrHelper::GetAppIdByBundleName(const std::string &bundleName, const int32_t userId) +{ + TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "GetAppIdByBundleName called"); + auto bundleMgr = Connect(); + if (bundleMgr == nullptr) { + TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "Failed to connect."); + return ""; + } + + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + return bundleMgr->GetAppIdByBundleName(bundleName, userId); +} + sptr BundleMgrHelper::Connect() { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); diff --git a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h index c0fadbc03c..e0ca6ad6d1 100644 --- a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h +++ b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h @@ -41,6 +41,7 @@ public: ErrCode GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId, HapModuleInfo &hapModuleInfo); bool GetBundleInfo(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo, int32_t userId); + std::string GetAppIdByBundleName(const std::string &bundleName, const int32_t userId); bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo); std::string GetAbilityLabel(const std::string &bundleName, const std::string &abilityName); std::string GetAppType(const std::string &bundleName); diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index cd71034999..09b18f52b1 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -596,6 +596,8 @@ public: bool GrantUriPermissionForServiceExtension(); + bool GrantUriPermissionForUIExtension(); + /** * check whether the ability is launcher. * @@ -1159,8 +1161,6 @@ private: void DumpUIExtensionPid(std::vector &info, bool isUIExtension) const; - bool GetUriListFromWant(Want &want, std::vector &uriVec); - void PublishFileOpenEvent(const Want &want); void SetDebugAppByWaitingDebugFlag(); diff --git a/services/abilitymgr/include/uri_utils.h b/services/abilitymgr/include/uri_utils.h index 0d470589d1..cca3bfdc06 100644 --- a/services/abilitymgr/include/uri_utils.h +++ b/services/abilitymgr/include/uri_utils.h @@ -37,6 +37,12 @@ public: std::vector GetPermissionedUriList(const std::vector &uriVec, const std::vector &checkResults, Want &want); + bool GetUriListFromWant(Want &want, std::vector &uriVec); + + bool IsGrantUriPermissionFlag(const Want &want); + + void CheckUriPermissionForServiceExtension(Want &want, AppExecFwk::ExtensionAbilityType extensionAbilityType); + private: UriUtils(); ~UriUtils(); diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index e96b7907f9..c8a22df34c 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -807,7 +807,6 @@ int AbilityConnectManager::AttachAbilityThreadLocked( void AbilityConnectManager::OnAbilityRequestDone(const sptr &token, const int32_t state) { TAG_LOGD(AAFwkTag::ABILITYMGR, "state: %{public}d", state); - std::lock_guard guard(serialMutex_); AppAbilityState abilityState = DelayedSingleton::GetInstance()->ConvertToAppAbilityState(state); if (abilityState == AppAbilityState::ABILITY_STATE_FOREGROUND) { auto abilityRecord = GetExtensionByTokenFromServiceMap(token); @@ -822,6 +821,8 @@ void AbilityConnectManager::OnAbilityRequestDone(const sptr &toke } std::string element = abilityRecord->GetURI(); TAG_LOGD(AAFwkTag::ABILITYMGR, "Ability is %{public}s, start to foreground.", element.c_str()); + abilityRecord->GrantUriPermissionForUIExtension(); + std::lock_guard guard(serialMutex_); abilityRecord->ForegroundUIExtensionAbility(); } } diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 376d61f1b9..ba96e7e4c2 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -72,6 +72,7 @@ #include "view_data.h" #include "xcollie/watchdog.h" #include "config_policy_utils.h" +#include "uri_utils.h" #include "utils/ability_permission_util.h" #include "utils/dump_utils.h" #include "utils/extension_permissions_util.h" @@ -1284,6 +1285,8 @@ int AbilityManagerService::StartAbilityByConnectManager(const Want& want, const TAG_LOGD(AAFwkTag::ABILITYMGR, "Start service or extension, name is %{public}s.", abilityInfo.name.c_str()); ReportEventToRSS(abilityInfo, callerToken); InsightIntentExecuteParam::RemoveInsightIntent(const_cast(want)); + UriUtils::GetInstance().CheckUriPermissionForServiceExtension(const_cast(abilityRequest.want), + abilityRequest.abilityInfo.extensionAbilityType); return connectManager->StartAbility(abilityRequest); } @@ -2025,6 +2028,8 @@ int32_t AbilityManagerService::RequestDialogServiceInner(const Want &want, const TAG_LOGD(AAFwkTag::ABILITYMGR, "request dialog service, start service extension,name is %{public}s.", abilityInfo.name.c_str()); ReportEventToRSS(abilityInfo, callerToken); + UriUtils::GetInstance().CheckUriPermissionForServiceExtension(abilityRequest.want, + abilityRequest.abilityInfo.extensionAbilityType); return connectManager->StartAbility(abilityRequest); } @@ -2885,8 +2890,11 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp if (!isStartAsCaller) { UpdateCallerInfo(abilityRequest.want, callerToken); } + TAG_LOGD(AAFwkTag::ABILITYMGR, "Start extension begin, name is %{public}s.", abilityInfo.name.c_str()); SetAbilityRequestSessionInfo(abilityRequest, extensionType); + UriUtils::GetInstance().CheckUriPermissionForServiceExtension(abilityRequest.want, + abilityRequest.abilityInfo.extensionAbilityType); eventInfo.errCode = connectManager->StartAbility(abilityRequest); if (eventInfo.errCode != ERR_OK) { EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); @@ -3170,6 +3178,8 @@ int AbilityManagerService::StartUIExtensionAbility(const sptr &exte } ReportEventToRSS(abilityRequest.abilityInfo, abilityRequest.callerToken); TAG_LOGD(AAFwkTag::ABILITYMGR, "name:%{public}s", abilityInfo.name.c_str()); + UriUtils::GetInstance().CheckUriPermissionForServiceExtension(abilityRequest.want, + abilityRequest.abilityInfo.extensionAbilityType); eventInfo.errCode = connectManager->StartAbility(abilityRequest); if (eventInfo.errCode != ERR_OK) { EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); @@ -4241,6 +4251,8 @@ int AbilityManagerService::ConnectLocalAbility(const Want &want, const int32_t u SetAbilityRequestSessionInfo(abilityRequest, targetExtensionType); ReportEventToRSS(abilityInfo, callerToken); + UriUtils::GetInstance().CheckUriPermissionForServiceExtension(const_cast(abilityRequest.want), + abilityRequest.abilityInfo.extensionAbilityType); return connectManager->ConnectAbilityLocked(abilityRequest, connect, callerToken, sessionInfo, connectInfo); } @@ -7951,6 +7963,8 @@ void AbilityManagerService::StartSwitchUserDialogInner(const Want &want, int32_t } } + UriUtils::GetInstance().CheckUriPermissionForServiceExtension(abilityRequest.want, + abilityRequest.abilityInfo.extensionAbilityType); eventInfo.errCode = connectManager->StartAbility(abilityRequest); if (eventInfo.errCode != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "eventInfo errCode:%{public}d", eventInfo.errCode); diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 2226bcfc00..321c5d700e 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -400,16 +400,22 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag) } } +bool AbilityRecord::GrantUriPermissionForUIExtension() +{ + TAG_LOGD(AAFwkTag::ABILITYMGR, "GrantUriPermissionForUIExtension:: called."); + if (UIExtensionUtils::IsUIExtension(abilityInfo_.extensionAbilityType)) { + std::lock_guard guard(wantLock_); + GrantUriPermission(want_, abilityInfo_.applicationInfo.bundleName, false, 0); + return true; + } + return false; +} + void AbilityRecord::ForegroundUIExtensionAbility(uint32_t sceneFlag) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGI(AAFwkTag::ABILITYMGR, "ability:%{public}s", GetURI().c_str()); CHECK_POINTER(lifecycleDeal_); - // grant uri permission - { - std::lock_guard guard(wantLock_); - GrantUriPermission(want_, abilityInfo_.applicationInfo.bundleName, false, 0); - } // schedule active after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. @@ -3178,36 +3184,6 @@ void AbilityRecord::DumpAbilityInfoDone(std::vector &infos) dumpCondition_.notify_all(); } -bool AbilityRecord::GetUriListFromWant(Want &want, std::vector &uriVec) -{ - auto uriStr = want.GetUri().ToString(); - uriVec = want.GetStringArrayParam(AbilityConfig::PARAMS_STREAM); - if (uriVec.empty() && uriStr.empty()) { - TAG_LOGW(AAFwkTag::ABILITYMGR, "uriVec empty."); - return false; - } - // process param stream - auto paramStreamUriCount = uriVec.size(); - if (uriStr.empty() && paramStreamUriCount > MAX_URI_COUNT) { - TAG_LOGW(AAFwkTag::ABILITYMGR, "uri empty, paream stream counts: %{public}zu", paramStreamUriCount); - uriVec.resize(MAX_URI_COUNT); - want.RemoveParam(AbilityConfig::PARAMS_STREAM); - want.SetParam(AbilityConfig::PARAMS_STREAM, uriVec); - return true; - } - if (!uriStr.empty() && paramStreamUriCount > MAX_URI_COUNT - 1) { - TAG_LOGW(AAFwkTag::ABILITYMGR, "paream stream counts: %{public}zu", paramStreamUriCount); - uriVec.resize(MAX_URI_COUNT - 1); - want.RemoveParam(AbilityConfig::PARAMS_STREAM); - want.SetParam(AbilityConfig::PARAMS_STREAM, uriVec); - } - // process uri - if (!uriStr.empty()) { - uriVec.insert(uriVec.begin(), uriStr); - } - return true; -} - void AbilityRecord::PublishFileOpenEvent(const Want &want) { auto wangUri = want.GetUri(); @@ -3256,7 +3232,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, return; } - if ((want.GetFlags() & (Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION)) == 0) { + if (!UriUtils::GetInstance().IsGrantUriPermissionFlag(want)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Do not call uriPermissionMgr."); return; } @@ -3265,7 +3241,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, return; } std::vector uriVec; - if (!GetUriListFromWant(want, uriVec)) { + if (!UriUtils::GetInstance().GetUriListFromWant(want, uriVec)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "get uri list failed"); return; } @@ -3292,9 +3268,22 @@ void AbilityRecord::GrantUriPermissionInner(Want &want, std::vector return; } uint32_t flag = want.GetFlags(); - auto checkResults = IN_PROCESS_CALL(UriPermissionManagerClient::GetInstance().CheckUriAuthorization( - uriVec, flag, callerTokenId)); - auto permissionUris = UriUtils::GetInstance().GetPermissionedUriList(uriVec, checkResults, want); + std::vector permissionUris; + if (abilityInfo_.extensionAbilityType != AppExecFwk::ExtensionAbilityType::SERVICE && + abilityInfo_.extensionAbilityType != AppExecFwk::ExtensionAbilityType::UI_SERVICE) { + auto checkResults = IN_PROCESS_CALL(UriPermissionManagerClient::GetInstance().CheckUriAuthorization( + uriVec, flag, callerTokenId)); + permissionUris = UriUtils::GetInstance().GetPermissionedUriList(uriVec, checkResults, want); + } else { + TAG_LOGI(AAFwkTag::ABILITYMGR, "target is Service Extension."); + // for service extension, uri permission checked ahead + for (auto &uriStr: uriVec) { + Uri uri(uriStr); + if (uri.GetScheme() == "file") { + permissionUris.emplace_back(uri); + } + } + } if (permissionUris.empty()) { TAG_LOGE(AAFwkTag::ABILITYMGR, "uris not permissioned."); return; diff --git a/services/abilitymgr/src/uri_utils.cpp b/services/abilitymgr/src/uri_utils.cpp index a096008836..00f08b3be2 100644 --- a/services/abilitymgr/src/uri_utils.cpp +++ b/services/abilitymgr/src/uri_utils.cpp @@ -16,6 +16,7 @@ #include "uri_utils.h" #include "ability_config.h" +#include "extension_ability_info.h" #include "hilog_tag_wrapper.h" #include "in_process_call_wrapper.h" #include "uri_permission_manager_client.h" @@ -172,5 +173,65 @@ std::vector UriUtils::GetPermissionedUriList(const std::vector return permissionedUris; } +bool UriUtils::GetUriListFromWant(Want &want, std::vector &uriVec) +{ + auto uriStr = want.GetUri().ToString(); + uriVec = want.GetStringArrayParam(AbilityConfig::PARAMS_STREAM); + if (uriVec.empty() && uriStr.empty()) { + TAG_LOGW(AAFwkTag::ABILITYMGR, "uriVec empty."); + return false; + } + // process param stream + auto paramStreamUriCount = uriVec.size(); + if (uriStr.empty() && paramStreamUriCount > MAX_URI_COUNT) { + TAG_LOGW(AAFwkTag::ABILITYMGR, "uri empty, paream stream counts: %{public}zu", paramStreamUriCount); + uriVec.resize(MAX_URI_COUNT); + want.RemoveParam(AbilityConfig::PARAMS_STREAM); + want.SetParam(AbilityConfig::PARAMS_STREAM, uriVec); + } + if (!uriStr.empty() && paramStreamUriCount > MAX_URI_COUNT - 1) { + TAG_LOGW(AAFwkTag::ABILITYMGR, "paream stream counts: %{public}zu", paramStreamUriCount); + uriVec.resize(MAX_URI_COUNT - 1); + want.RemoveParam(AbilityConfig::PARAMS_STREAM); + want.SetParam(AbilityConfig::PARAMS_STREAM, uriVec); + } + // process uri + if (!uriStr.empty()) { + uriVec.insert(uriVec.begin(), uriStr); + } + return true; +} + +bool UriUtils::IsGrantUriPermissionFlag(const Want &want) +{ + return ((want.GetFlags() & (Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION)) != 0); +} + +void UriUtils::CheckUriPermissionForServiceExtension(Want &want, AppExecFwk::ExtensionAbilityType extensionAbilityType) +{ + TAG_LOGD(AAFwkTag::ABILITYMGR, "CheckUriPermissionForServiceExtension called."); + if (extensionAbilityType != AppExecFwk::ExtensionAbilityType::SERVICE && + extensionAbilityType != AppExecFwk::ExtensionAbilityType::UI_SERVICE) { + return; + } + uint32_t flag = want.GetFlags(); + if (!IsGrantUriPermissionFlag(want)) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "No grant uri flag: %{public}u.", flag); + return; + } + std::vector uriVec; + if (!UriUtils::GetUriListFromWant(want, uriVec)) { + TAG_LOGW(AAFwkTag::ABILITYMGR, "No file uri neet grant."); + return; + } + auto callerTokenId = want.GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, 0); + // check uri permission + auto checkResults = IN_PROCESS_CALL(UriPermissionManagerClient::GetInstance().CheckUriAuthorization( + uriVec, flag, callerTokenId)); + // remove unpermissioned uri from want + UriUtils::GetInstance().GetPermissionedUriList(uriVec, checkResults, want); + return; +} + } // AAFwk } // OHOS \ No newline at end of file diff --git a/services/uripermmgr/BUILD.gn b/services/uripermmgr/BUILD.gn index b270156d40..185aa05d21 100644 --- a/services/uripermmgr/BUILD.gn +++ b/services/uripermmgr/BUILD.gn @@ -29,6 +29,7 @@ config("upms_config") { libupms_sources = [ "src/file_permission_manager.cpp", + "src/media_permission_manager.cpp", "src/tokenid_permission.cpp", "src/uri_permission_manager_service.cpp", "src/uri_permission_manager_stub_impl.cpp", @@ -77,14 +78,17 @@ ohos_shared_library("libupms") { "c_utils:utils", "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", + "data_share:datashare_consumer", "eventhandler:libeventhandler", "graphic_2d:color_manager", "hilog:libhilog", "hisysevent:libhisysevent", + "hitrace:hitrace_meter", "image_framework:image_native", "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", + "media_library:media_library_manager", "relational_store:native_dataability", "relational_store:native_rdb", "safwk:system_ability_fwk", @@ -140,10 +144,14 @@ ohos_static_library("libupms_static") { "c_utils:utils", "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", + "data_share:datashare_consumer", "hilog:libhilog", + "hitrace:hitrace_meter", + "image_framework:image_native", "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", + "media_library:media_library_manager", "safwk:system_ability_fwk", "samgr:samgr_proxy", "storage_service:storage_manager_sa_proxy", diff --git a/services/uripermmgr/include/media_permission_manager.h b/services/uripermmgr/include/media_permission_manager.h new file mode 100644 index 0000000000..3e25b62cf5 --- /dev/null +++ b/services/uripermmgr/include/media_permission_manager.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 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_MEDIA_PERMISSION_MANAGER_H +#define OHOS_ABILITY_RUNTIME_MEDIA_PERMISSION_MANAGER_H + +#include +#include + +#include "media_library_manager.h" + +namespace OHOS { +namespace AAFwk { +class MediaPermissionManager { +public: + static MediaPermissionManager &GetInstance(); + + std::vector CheckUriPermission(const std::vector &uriVec, uint32_t callerTokenId, uint32_t flag); + + ~MediaPermissionManager() {}; + + MediaPermissionManager(const MediaPermissionManager &mediaPermissionManager) = delete; + + const MediaPermissionManager &operator=(const MediaPermissionManager &mediaPermissionManager) = delete; + +private: + std::mutex mutex_; + + MediaPermissionManager(); + + Media::MediaLibraryManager *GetMediaLibraryManager(); + + Media::MediaLibraryManager *mediaLibraryManager_ = nullptr; +}; + +} // OHOS +} // AAFwk +#endif // OHOS_ABILITY_RUNTIME_MEDIA_PERMISSION_MANAGER_H \ No newline at end of file diff --git a/services/uripermmgr/include/uri_permission_manager_stub_impl.h b/services/uripermmgr/include/uri_permission_manager_stub_impl.h index 58b8240796..e4c84d58e2 100644 --- a/services/uripermmgr/include/uri_permission_manager_stub_impl.h +++ b/services/uripermmgr/include/uri_permission_manager_stub_impl.h @@ -120,7 +120,8 @@ private: int32_t CheckCalledBySandBox(); - bool CheckUriPermission(Uri uri, uint32_t flag, TokenIdPermission &tokenIdPermission); + std::vector CheckUriPermission(TokenIdPermission &tokenIdPermission, const std::vector &uriVec, + uint32_t flag); bool CheckUriTypeIsValid(Uri uri); @@ -134,11 +135,8 @@ private: void HandleUriPermission( uint64_t tokenId, unsigned int flag, std::vector &docsVec, bool isSystemAppCall); - int32_t CheckProxyUriPermission(TokenIdPermission &tokenIdPermission, const Uri &uri, uint32_t flag); - - bool AccessMediaUriPermission(TokenIdPermission &tokenIdPermission, const Uri &uri, uint32_t flag); - - bool AccessDocsUriPermission(TokenIdPermission &tokenIdPermission, const Uri &uri, uint32_t flag); + void CheckProxyUriPermission(TokenIdPermission &tokenIdPermission, const std::vector &uriVec, uint32_t flag, + std::vector &result); int32_t DeleteShareFile(uint32_t targetTokenId, const std::vector &uriVec); diff --git a/services/uripermmgr/include/uri_permission_utils.h b/services/uripermmgr/include/uri_permission_utils.h index 3251839c55..a0b9021ef9 100644 --- a/services/uripermmgr/include/uri_permission_utils.h +++ b/services/uripermmgr/include/uri_permission_utils.h @@ -33,6 +33,7 @@ public: static bool IsSystemAppCall(uint32_t tokenId); static bool CheckIsSystemAppByTokenId(uint32_t tokenId); static bool GetBundleNameByTokenId(uint32_t tokenId, std::string &bundleName); + static int32_t GetAppIdByBundleName(const std::string &bundleName, std::string &appId); static std::string GetCallerNameByTokenId(uint32_t callerTokenId); static int32_t GetTokenIdByBundleName(const std::string &bundleName, int32_t appIndex, uint32_t &tokenId); static bool IsDocsCloudUri(Uri &uri); diff --git a/services/uripermmgr/src/media_permission_manager.cpp b/services/uripermmgr/src/media_permission_manager.cpp new file mode 100644 index 0000000000..7e67dd936d --- /dev/null +++ b/services/uripermmgr/src/media_permission_manager.cpp @@ -0,0 +1,117 @@ + +/* +* Copyright (c) 2024 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 "media_permission_manager.h" + +#include +#include + +#include "ability_manager_errors.h" +#include "hilog_tag_wrapper.h" +#include "hitrace_meter.h" +#include "in_process_call_wrapper.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" +#include "uri_permission_utils.h" +#include "want.h" + +namespace OHOS { +namespace AAFwk { + +MediaPermissionManager& MediaPermissionManager::GetInstance() +{ + static MediaPermissionManager mediaPermissionManager; + return mediaPermissionManager; +} + +MediaPermissionManager::MediaPermissionManager() +{ + TAG_LOGI(AAFwkTag::URIPERMMGR, "MediaPermissionManager init."); + mediaLibraryManager_ = GetMediaLibraryManager(); +} + +Media::MediaLibraryManager *MediaPermissionManager::GetMediaLibraryManager() +{ + TAG_LOGI(AAFwkTag::URIPERMMGR, "GetMediaLibraryManager."); + std::lock_guard lock(mutex_); + if (mediaLibraryManager_) { + return mediaLibraryManager_; + } + TAG_LOGI(AAFwkTag::URIPERMMGR, "mediaLibraryManager is nullptr."); + mediaLibraryManager_ = Media::MediaLibraryManager::GetMediaLibraryManager(); + if (mediaLibraryManager_ == nullptr) { + TAG_LOGE(AAFwkTag::URIPERMMGR, "GetMediaLibraryManager failed."); + return mediaLibraryManager_; + } + mediaLibraryManager_->InitMediaLibraryManager(); + TAG_LOGI(AAFwkTag::URIPERMMGR, "InitMediaLibraryManager success!"); + return mediaLibraryManager_; +} + +std::vector MediaPermissionManager::CheckUriPermission(const std::vector &uriVec, + uint32_t callerTokenId, uint32_t flag) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + std::vector uriStrVec; + std::vector results; + for (auto &uri: uriVec) { + uriStrVec.emplace_back(uri.ToString()); + } + TAG_LOGI(AAFwkTag::URIPERMMGR, "Check photo uri permission start."); + flag &= (Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION); + std::string appId = ""; + std::string bundleName; + if (!UPMSUtils::GetBundleNameByTokenId(callerTokenId, bundleName)) { + TAG_LOGW(AAFwkTag::URIPERMMGR, "Get bundle name failed."); + results = std::vector(uriStrVec.size(), false); + return results; + } + if (UPMSUtils::GetAppIdByBundleName(bundleName, appId) != ERR_OK) { + TAG_LOGW(AAFwkTag::URIPERMMGR, "Get appId by bundle failed."); + results = std::vector(uriStrVec.size(), false); + return results; + } + auto mediaLibraryManager = GetMediaLibraryManager(); + if (mediaLibraryManager == nullptr) { + TAG_LOGE(AAFwkTag::URIPERMMGR, "GetMediaLibraryManager failed."); + results = std::vector(uriStrVec.size(), false); + return results; + } + TAG_LOGI(AAFwkTag::URIPERMMGR, "CheckPhotoUriPermission start."); + auto ret = IN_PROCESS_CALL(mediaLibraryManager->CheckPhotoUriPermission(callerTokenId, appId, uriStrVec, + results, flag)); + TAG_LOGI(AAFwkTag::URIPERMMGR, "CheckPhotoUriPermission finished."); + if (ret != ERR_OK) { + TAG_LOGE(AAFwkTag::URIPERMMGR, "Check photo uri permission failed, ret is %{pubic}d", ret); + results = std::vector(uriStrVec.size(), false); + return results; + } + if (results.size() != uriStrVec.size()) { + TAG_LOGE(AAFwkTag::URIPERMMGR, "size of results is unexpected: %{public}zu", results.size()); + results = std::vector(uriStrVec.size(), false); + return results; + } + for (size_t i = 0; i < results.size(); i++) { + if (!results[i]) { + TAG_LOGE(AAFwkTag::URIPERMMGR, "No media permission, uri is %{private}s", uriStrVec[i].c_str()); + break; + } + } + return results; +} + +} // OHOS +} // AAFwk \ No newline at end of file diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index ebf13df32d..d5c135ea68 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -25,6 +25,7 @@ #include "in_process_call_wrapper.h" #include "ipc_skeleton.h" #include "iservice_registry.h" +#include "media_permission_manager.h" #include "parameter.h" #include "permission_constants.h" #include "permission_verification.h" @@ -351,7 +352,9 @@ int UriPermissionManagerStubImpl::GrantSingleUriPermission(const Uri &uri, unsig return ERR_CODE_INVALID_URI_TYPE; } TokenIdPermission tokenIdPermission(callerTokenId); - if (!CheckUriPermission(uri, flag, tokenIdPermission)) { + std::vector uriVec = { uri }; + auto checkResult = CheckUriPermission(tokenIdPermission, uriVec, flag); + if (!checkResult[0]) { TAG_LOGW(AAFwkTag::URIPERMMGR, "No permission, uri:%{private}s, callerTokenId:%{public}u", uri.ToString().c_str(), callerTokenId); UPMSUtils::SendShareUnPrivilegeUriEvent(callerTokenId, targetTokenId); @@ -405,24 +408,22 @@ int UriPermissionManagerStubImpl::GrantBatchUriPermission(const std::vector callerTokenId, targetTokenId, flag, abilityId); TokenIdPermission tokenIdPermission(callerTokenId); std::vector uriStrVec = {}; - bool checkUriPermissionFailedFlag = false; - for (const auto &uri : uriVec) { - if (!CheckUriTypeIsValid(uri)) { - TAG_LOGW(AAFwkTag::URIPERMMGR, "failed, uri:%{private}s", uri.ToString().c_str()); + auto checkResult = CheckUriPermission(tokenIdPermission, uriVec, flag); + int32_t noPermissionUriCount = 0; + for (size_t i = 0; i < checkResult.size(); i++) { + auto uriStr = uriVec[i].ToString(); + if (!checkResult[i]) { + TAG_LOGW(AAFwkTag::URIPERMMGR, "No permission, uri:%{private}s", uriStr.c_str()); + noPermissionUriCount++; continue; } - if (!CheckUriPermission(uri, flag, tokenIdPermission)) { - TAG_LOGW(AAFwkTag::URIPERMMGR, "No permission, uri:%{private}s", uri.ToString().c_str()); - checkUriPermissionFailedFlag = true; - continue; - } - uriStrVec.emplace_back(uri.ToString()); + uriStrVec.emplace_back(uriStr); } - if (checkUriPermissionFailedFlag) { + if (noPermissionUriCount > 0) { UPMSUtils::SendShareUnPrivilegeUriEvent(callerTokenId, targetTokenId); } if (uriStrVec.empty()) { - TAG_LOGE(AAFwkTag::URIPERMMGR, "empty uri"); + TAG_LOGE(AAFwkTag::URIPERMMGR, "all uri invalid or no permission"); return INNER_ERR; } return GrantBatchUriPermissionImpl(uriStrVec, flag, callerTokenId, targetTokenId, abilityId); @@ -648,35 +649,28 @@ int32_t UriPermissionManagerStubImpl::DeleteShareFile(uint32_t targetTokenId, co return ret; } -std::vector UriPermissionManagerStubImpl::CheckUriAuthorization(const std::vector &uriVec, +std::vector UriPermissionManagerStubImpl::CheckUriAuthorization(const std::vector &uriStrVec, uint32_t flag, uint32_t tokenId) { TAG_LOGI(AAFwkTag::URIPERMMGR, "tokenId:%{public}u, tokenName:%{public}s, flag:%{public}u, size of uris:%{public}zu", - tokenId, UPMSUtils::GetCallerNameByTokenId(tokenId).c_str(), flag, uriVec.size()); - std::vector result(uriVec.size(), false); + tokenId, UPMSUtils::GetCallerNameByTokenId(tokenId).c_str(), flag, uriStrVec.size()); if (!UPMSUtils::IsSAOrSystemAppCall()) { TAG_LOGE(AAFwkTag::URIPERMMGR, "not SA/SystemApp"); + std::vector result(uriStrVec.size(), false); return result; } if ((flag & FLAG_READ_WRITE_URI) == 0) { TAG_LOGE(AAFwkTag::URIPERMMGR, "Flag invalid"); + std::vector result(uriStrVec.size(), false); return result; } - - TokenIdPermission tokenIdPermission(tokenId); - for (size_t i = 0; i < uriVec.size(); i++) { - Uri uri(uriVec[i]); - if (!CheckUriTypeIsValid(uri)) { - TAG_LOGW(AAFwkTag::URIPERMMGR, "uri:invalid, uri:%{private}s", uriVec[i].c_str()); - continue; - } - result[i] = CheckUriPermission(uri, flag, tokenIdPermission); - if (!result[i]) { - TAG_LOGW(AAFwkTag::URIPERMMGR, "CheckUriPermission failed, uri:%{private}s", uriVec[i].c_str()); - } + std::vector uriVec; + for (auto &uriStr: uriStrVec) { + uriVec.emplace_back(uriStr); } - return result; + TokenIdPermission tokenIdPermission(tokenId); + return CheckUriPermission(tokenIdPermission, uriVec, flag); } template @@ -811,83 +805,69 @@ void UriPermissionManagerStubImpl::HandleUriPermission( } } -bool UriPermissionManagerStubImpl::CheckUriPermission(Uri uri, uint32_t flag, TokenIdPermission &tokenIdPermission) +std::vector UriPermissionManagerStubImpl::CheckUriPermission(TokenIdPermission &tokenIdPermission, + const std::vector &uriVec, uint32_t flag) { - auto &&authority = uri.GetAuthority(); - TAG_LOGD(AAFwkTag::URIPERMMGR, "UriAuth:%{public}s", authority.c_str()); - if (uri.GetScheme() == "content") { - TAG_LOGI(AAFwkTag::URIPERMMGR, "content uri"); - return UPMSUtils::IsFoundationCall(); + auto tokenId = tokenIdPermission.GetTokenId(); + std::vector result(uriVec.size(), false); + std::vector mediaUris; + std::vector mediaUriIndexs; + bool isFoundationCall = UPMSUtils::IsFoundationCall(); + std::string callerBundleName; + UPMSUtils::GetBundleNameByTokenId(tokenId, callerBundleName); + for (size_t i = 0; i < uriVec.size(); i++) { + auto uri = uriVec[i]; + auto &&scheme = uri.GetScheme(); + if (scheme != "content" && scheme != "file") { + TAG_LOGW(AAFwkTag::URIPERMMGR, "invalid uri:%{private}s", uri.ToString().c_str()); + result[i] = false; + continue; + } + if (scheme == "content") { + result[i] = isFoundationCall; + continue; + } + auto &&authority = uri.GetAuthority(); + TAG_LOGD(AAFwkTag::URIPERMMGR, "UriAuth:%{public}s", authority.c_str()); + if (authority == "docs" && tokenIdPermission.VerifyFileAccessManagerPermission()) { + result[i] = true; + continue; + } + if (authority == "media") { + mediaUris.emplace_back(uri); + mediaUriIndexs.emplace_back(i); + continue; + } + result[i] = (authority == callerBundleName); } - if (authority == "docs") { - return AccessDocsUriPermission(tokenIdPermission, uri, flag); + if (!mediaUris.empty()) { + auto mediaUriResult = MediaPermissionManager::GetInstance().CheckUriPermission(mediaUris, tokenId, flag); + for (size_t i = 0; i < mediaUris.size(); i++) { + result[mediaUriIndexs[i]] = mediaUriResult[i]; + } } - if (authority == "media") { - return AccessMediaUriPermission(tokenIdPermission, uri, flag); - } - uint32_t authorityTokenId = 0; - if (UPMSUtils::GetTokenIdByBundleName(authority, 0, authorityTokenId) != ERR_OK) { - TAG_LOGE(AAFwkTag::URIPERMMGR, "Get tokenId of %{public}s failed", authority.c_str()); - return false; - } - if (tokenIdPermission.GetTokenId() == authorityTokenId) { - return true; - } - return CheckProxyUriPermission(tokenIdPermission, uri, flag); + CheckProxyUriPermission(tokenIdPermission, uriVec, flag, result); + return result; } -bool UriPermissionManagerStubImpl::AccessMediaUriPermission(TokenIdPermission &tokenIdPermission, - const Uri &uri, uint32_t flag) -{ - TAG_LOGD(AAFwkTag::URIPERMMGR, "Call"); - bool isWriteFlag = (flag & Want::FLAG_AUTH_WRITE_URI_PERMISSION) != 0; - auto innerUri = uri; - auto path = innerUri.GetPath(); - if (path.rfind("/Photo/", 0) == 0) { - if (tokenIdPermission.VerifyWriteImageVideoPermission()) { - return true; - } - if (!isWriteFlag && tokenIdPermission.VerifyReadImageVideoPermission()) { - return true; - } - TAG_LOGI(AAFwkTag::URIPERMMGR, "No IMAGEVIDEO Permission"); - return CheckProxyUriPermission(tokenIdPermission, uri, flag); - } - if (path.rfind("/Audio/", 0) == 0) { - if (tokenIdPermission.VerifyWriteAudioPermission()) { - return true; - } - if (!isWriteFlag && tokenIdPermission.VerifyReadAudioPermission()) { - return true; - } - TAG_LOGI(AAFwkTag::URIPERMMGR, "No AUDIO Permission"); - return CheckProxyUriPermission(tokenIdPermission, uri, flag); - } - TAG_LOGE(AAFwkTag::URIPERMMGR, "Media uri invalid, path:%{public}s", path.c_str()); - return false; -} - -bool UriPermissionManagerStubImpl::AccessDocsUriPermission(TokenIdPermission &tokenIdPermission, - const Uri &uri, uint32_t flag) -{ - TAG_LOGD(AAFwkTag::URIPERMMGR, "Call"); - if (tokenIdPermission.VerifyFileAccessManagerPermission()) { - return true; - } - TAG_LOGW(AAFwkTag::URIPERMMGR, "No FILE_ACCESS_MANAGER Permission"); - return CheckProxyUriPermission(tokenIdPermission, uri, flag); -} - -int32_t UriPermissionManagerStubImpl::CheckProxyUriPermission(TokenIdPermission &tokenIdPermission, - const Uri &uri, uint32_t flag) +void UriPermissionManagerStubImpl::CheckProxyUriPermission(TokenIdPermission &tokenIdPermission, + const std::vector &uriVec, uint32_t flag, std::vector &result) { TAG_LOGI(AAFwkTag::URIPERMMGR, "Call"); - auto tokenId = tokenIdPermission.GetTokenId(); - if (tokenIdPermission.VerifyProxyAuthorizationUriPermission() && VerifyUriPermission(uri, flag, tokenId)) { - return true; + if (uriVec.size() != result.size()) { + TAG_LOGW(AAFwkTag::URIPERMMGR, "param size not equal"); + return; + } + auto tokenId = tokenIdPermission.GetTokenId(); + if (!tokenIdPermission.VerifyProxyAuthorizationUriPermission()) { + TAG_LOGW(AAFwkTag::URIPERMMGR, "no proxy permission"); + return; + } + for (size_t i = 0; i < uriVec.size(); i++) { + if (!result[i]) { + result[i] = VerifyUriPermission(uriVec[i], flag, tokenId); + } } - TAG_LOGW(AAFwkTag::URIPERMMGR, "failed"); - return false; } bool UriPermissionManagerStubImpl::CheckUriTypeIsValid(Uri uri) diff --git a/services/uripermmgr/src/uri_permission_utils.cpp b/services/uripermmgr/src/uri_permission_utils.cpp index dcbee1ad11..70f74b8e57 100644 --- a/services/uripermmgr/src/uri_permission_utils.cpp +++ b/services/uripermmgr/src/uri_permission_utils.cpp @@ -195,6 +195,23 @@ bool UPMSUtils::GetBundleNameByTokenId(uint32_t tokenId, std::string &bundleName return false; } +int32_t UPMSUtils::GetAppIdByBundleName(const std::string &bundleName, std::string &appId) +{ + TAG_LOGD(AAFwkTag::URIPERMMGR, "BundleName is %{public}s.", bundleName.c_str()); + auto bms = ConnectManagerHelper(); + if (bms == nullptr) { + TAG_LOGW(AAFwkTag::URIPERMMGR, "The bundleMgrHelper is nullptr."); + return GET_BUNDLE_MANAGER_SERVICE_FAILED; + } + auto userId = GetCurrentAccountId(); + appId = IN_PROCESS_CALL(bms->GetAppIdByBundleName(bundleName, userId)); + if (appId.empty()) { + TAG_LOGW(AAFwkTag::URIPERMMGR, "Get appId by bundle name failed, userId is %{private}d", userId); + return INNER_ERR; + } + return ERR_OK; +} + std::string UPMSUtils::GetCallerNameByTokenId(uint32_t tokenId) { auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenId); diff --git a/test/unittest/ability_record_test/ability_record_test.cpp b/test/unittest/ability_record_test/ability_record_test.cpp index 9eb6f5b9d2..005a08206b 100644 --- a/test/unittest/ability_record_test/ability_record_test.cpp +++ b/test/unittest/ability_record_test/ability_record_test.cpp @@ -3338,7 +3338,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_GetUriListFromWant_001, TestSize.Level Want want; want.SetUri("file://com.example.test/test.txt"); std::vector uriVec; - abilityRecord->GetUriListFromWant(want, uriVec); + UriUtils::GetInstance().GetUriListFromWant(want, uriVec); EXPECT_EQ(uriVec.size(), 1); } @@ -3357,7 +3357,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_GetUriListFromWant_002, TestSize.Level std::vector oriUriVec = { "file://com.example.test/test.txt" }; want.SetParam(AbilityConfig::PARAMS_STREAM, oriUriVec); std::vector uriVec; - abilityRecord->GetUriListFromWant(want, uriVec); + UriUtils::GetInstance().GetUriListFromWant(want, uriVec); EXPECT_EQ(uriVec.size(), 1); } @@ -3377,7 +3377,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_GetUriListFromWant_003, TestSize.Level std::vector oriUriVec = { "file://com.example.test/test.txt" }; want.SetParam(AbilityConfig::PARAMS_STREAM, oriUriVec); std::vector uriVec; - abilityRecord->GetUriListFromWant(want, uriVec); + UriUtils::GetInstance().GetUriListFromWant(want, uriVec); EXPECT_EQ(uriVec.size(), 2); } @@ -3397,7 +3397,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_GetUriListFromWant_004, TestSize.Level std::vector oriUriVec(500, "file://com.example.test/test.txt"); want.SetParam(AbilityConfig::PARAMS_STREAM, oriUriVec); std::vector uriVec; - abilityRecord->GetUriListFromWant(want, uriVec); + UriUtils::GetInstance().GetUriListFromWant(want, uriVec); EXPECT_EQ(uriVec.size(), 500); } @@ -3416,7 +3416,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_GetUriListFromWant_005, TestSize.Level std::vector oriUriVec(501, "file://com.example.test/test.txt"); want.SetParam(AbilityConfig::PARAMS_STREAM, oriUriVec); std::vector uriVec; - abilityRecord->GetUriListFromWant(want, uriVec); + UriUtils::GetInstance().GetUriListFromWant(want, uriVec); EXPECT_EQ(uriVec.size(), 500); } diff --git a/test/unittest/uri_permission_impl_test/mock/include/mock_accesstoken_kit.h b/test/unittest/uri_permission_impl_test/mock/include/mock_accesstoken_kit.h index 6474da1451..3b87f2f4a7 100644 --- a/test/unittest/uri_permission_impl_test/mock/include/mock_accesstoken_kit.h +++ b/test/unittest/uri_permission_impl_test/mock/include/mock_accesstoken_kit.h @@ -18,6 +18,7 @@ #include "access_token.h" #include "native_token_info.h" +#include "hap_token_info.h" namespace OHOS { namespace Security { @@ -28,6 +29,8 @@ public: static ATokenTypeEnum GetTokenTypeFlag(AccessTokenID tokenID); static int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo& nativeTokenInfoRes); + + static int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo& hapInfo); }; } // namespace AccessToken } // namespace Security diff --git a/test/unittest/uri_permission_impl_test/mock/include/mock_bundle_mgr_helper.h b/test/unittest/uri_permission_impl_test/mock/include/mock_bundle_mgr_helper.h index 19d7dfae90..7b7550a9bc 100644 --- a/test/unittest/uri_permission_impl_test/mock/include/mock_bundle_mgr_helper.h +++ b/test/unittest/uri_permission_impl_test/mock/include/mock_bundle_mgr_helper.h @@ -37,6 +37,8 @@ public: ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex, BundleInfo &bundleInfo, int32_t userId); + std::string GetAppIdByBundleName(const std::string &bundleName, const int32_t userId); + private: void OnDeath(); diff --git a/test/unittest/uri_permission_impl_test/mock/include/mock_media_permission_manager.h b/test/unittest/uri_permission_impl_test/mock/include/mock_media_permission_manager.h new file mode 100644 index 0000000000..cc79664049 --- /dev/null +++ b/test/unittest/uri_permission_impl_test/mock/include/mock_media_permission_manager.h @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 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_MEDIA_PERMISSION_MANAGER_H +#define OHOS_ABILITY_RUNTIME_MEDIA_PERMISSION_MANAGER_H + +#include +#include +#include + +namespace OHOS { +namespace AAFwk { +class MediaPermissionManager { +public: + static int32_t GrantPhotoUriPermission(const std::string &bundleName, const std::vector &uris, + uint32_t flag) + { + return 0; + } + + static std::vector CheckPhotoUriPermission(const std::vector &uriVec, + uint32_t tokenId, uint32_t flag) + { + return std::vector(uriVec.size(), 0); + } +}; + +} // OHOS +} // AAFwk +#endif // OHOS_ABILITY_RUNTIME_MEDIA_PERMISSION_MANAGER_H \ No newline at end of file diff --git a/test/unittest/uri_permission_impl_test/mock/src/mock_accesstoken_kit.cpp b/test/unittest/uri_permission_impl_test/mock/src/mock_accesstoken_kit.cpp index bfa66bcab8..c24e601ead 100644 --- a/test/unittest/uri_permission_impl_test/mock/src/mock_accesstoken_kit.cpp +++ b/test/unittest/uri_permission_impl_test/mock/src/mock_accesstoken_kit.cpp @@ -37,6 +37,15 @@ int AccessTokenKit::GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo& n } return -1; } + +int AccessTokenKit::GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo& hapInfo) +{ + if (MyFlag::tokenInfos.find(tokenID) != MyFlag::tokenInfos.end()) { + hapInfo.bundleName = MyFlag::tokenInfos[tokenID].bundleName; + return 0; + } + return -1; +} } // namespace AccessToken } // namespace Security } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/uri_permission_impl_test/mock/src/mock_bundle_mgr_helper.cpp b/test/unittest/uri_permission_impl_test/mock/src/mock_bundle_mgr_helper.cpp index 5859e7b056..cc31030736 100644 --- a/test/unittest/uri_permission_impl_test/mock/src/mock_bundle_mgr_helper.cpp +++ b/test/unittest/uri_permission_impl_test/mock/src/mock_bundle_mgr_helper.cpp @@ -76,6 +76,12 @@ bool BundleMgrHelper::GetApplicationInfo(const std::string &appName, uint32_t fl return true; } +std::string BundleMgrHelper::GetAppIdByBundleName(const std::string &bundleName, const int32_t userId) +{ + auto appId = bundleName + "_appId"; + return appId; +} + ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex, BundleInfo &bundleInfo, int32_t userId) { diff --git a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp index 9d0acf36c0..3fc634c6f9 100755 --- a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp +++ b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp @@ -15,6 +15,7 @@ #include +#include "mock_media_permission_manager.h" #include "mock_accesstoken_kit.h" #include "mock_bundle_mgr_helper.h" #include "mock_ipc_skeleton.h" @@ -485,53 +486,12 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_001, TestSize.Level1) ASSERT_NE(upms, nullptr); auto mediaPhotoUri = Uri("file://media/Photo/1/IMG_001/test_001.jpg"); uint32_t callerTokenId = 1001; - uint32_t targetTokenId = 1002; uint32_t flagRead = 1; - uint32_t flagWrite = 2; TokenIdPermission tokenIdPermission(callerTokenId); - auto ret = upms->CheckUriPermission(mediaPhotoUri, flagRead, tokenIdPermission); + std::vector mediaPhotoUris = { mediaPhotoUri }; + auto ret = upms->CheckUriPermission(tokenIdPermission, mediaPhotoUris, flagRead)[0]; ASSERT_EQ(ret, false); - - // read - MyFlag::permissionReadImageVideo_ = true; - tokenIdPermission = TokenIdPermission(callerTokenId); - ret = upms->CheckUriPermission(mediaPhotoUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(mediaPhotoUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, false); - MyFlag::permissionReadImageVideo_ = false; - - // write - MyFlag::permissionWriteImageVideo_ = true; - tokenIdPermission = TokenIdPermission(callerTokenId); - ret = upms->CheckUriPermission(mediaPhotoUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(mediaPhotoUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, true); - MyFlag::permissionWriteImageVideo_ = false; - - // proxy uri permision - MyFlag::permissionProxyAuthorization_ = true; - tokenIdPermission = TokenIdPermission(targetTokenId); - // no record - ret = upms->CheckUriPermission(mediaPhotoUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, false); - ret = upms->CheckUriPermission(mediaPhotoUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, false); - - // read - upms->AddTempUriPermission(mediaPhotoUri.ToString(), flagRead, callerTokenId, targetTokenId, false); - ret = upms->CheckUriPermission(mediaPhotoUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(mediaPhotoUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, false); - - // write - upms->AddTempUriPermission(mediaPhotoUri.ToString(), flagWrite, callerTokenId, targetTokenId, false); - ret = upms->CheckUriPermission(mediaPhotoUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, true); - MyFlag::permissionProxyAuthorization_ = false; } /* @@ -546,53 +506,12 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_002, TestSize.Level1) ASSERT_NE(upms, nullptr); auto mediaAudioUri = Uri("file://media/Audio/1/Record_001/test_001.mp3"); uint32_t callerTokenId = 1001; - uint32_t targetTokenId = 1002; uint32_t flagRead = 1; - uint32_t flagWrite = 2; TokenIdPermission tokenIdPermission(callerTokenId); - auto ret = upms->CheckUriPermission(mediaAudioUri, flagRead, tokenIdPermission); + std::vector mediaAudioUris = { mediaAudioUri }; + auto ret = upms->CheckUriPermission(tokenIdPermission, mediaAudioUris, flagRead)[0]; ASSERT_EQ(ret, false); - - // read - MyFlag::permissionReadAudio_ = true; - tokenIdPermission = TokenIdPermission(targetTokenId); - ret = upms->CheckUriPermission(mediaAudioUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(mediaAudioUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, false); - MyFlag::permissionReadAudio_ = false; - - // write - MyFlag::permissionWriteAudio_ = true; - tokenIdPermission = TokenIdPermission(targetTokenId); - ret = upms->CheckUriPermission(mediaAudioUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(mediaAudioUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, true); - MyFlag::permissionWriteAudio_ = false; - - // proxy uri permission - MyFlag::permissionProxyAuthorization_ = true; - tokenIdPermission = TokenIdPermission(targetTokenId); - // no record - ret = upms->CheckUriPermission(mediaAudioUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, false); - ret = upms->CheckUriPermission(mediaAudioUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, false); - - // read - upms->AddTempUriPermission(mediaAudioUri.ToString(), flagRead, callerTokenId, targetTokenId, 0); - ret = upms->CheckUriPermission(mediaAudioUri, flagRead, tokenIdPermission); - ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(mediaAudioUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, false); - - // write - upms->AddTempUriPermission(mediaAudioUri.ToString(), flagWrite, callerTokenId, targetTokenId, 0); - ret = upms->CheckUriPermission(mediaAudioUri, flagWrite, tokenIdPermission); - ASSERT_EQ(ret, true); - MyFlag::permissionProxyAuthorization_ = false; } /* @@ -605,22 +524,22 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_003, TestSize.Level1) { auto upms = std::make_unique(); ASSERT_NE(upms, nullptr); - auto docsUri = Uri("file://docs/DestTop/Text/test_001.txt"); + std::vector docsUri = { Uri("file://docs/DestTop/Text/test_001.txt") }; uint32_t callerTokenId = 1001; uint32_t targetTokenId = 1002; uint32_t flagRead = 1; uint32_t flagWrite = 2; TokenIdPermission tokenIdPermission(callerTokenId); - auto ret = upms->CheckUriPermission(docsUri, flagRead, tokenIdPermission); + auto ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagRead)[0]; ASSERT_EQ(ret, false); // have FILE_ACCESS_MANAGER permission MyFlag::permissionFileAccessManager_ = true; tokenIdPermission = TokenIdPermission(targetTokenId); - ret = upms->CheckUriPermission(docsUri, flagRead, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagRead)[0]; ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(docsUri, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagWrite)[0]; ASSERT_EQ(ret, true); MyFlag::permissionFileAccessManager_ = false; @@ -628,21 +547,21 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_003, TestSize.Level1) MyFlag::permissionProxyAuthorization_ = true; tokenIdPermission = TokenIdPermission(targetTokenId); // no record - ret = upms->CheckUriPermission(docsUri, flagRead, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagRead)[0]; ASSERT_EQ(ret, false); - ret = upms->CheckUriPermission(docsUri, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagWrite)[0]; ASSERT_EQ(ret, false); // read - upms->AddTempUriPermission(docsUri.ToString(), flagRead, callerTokenId, targetTokenId, 0); - ret = upms->CheckUriPermission(docsUri, flagRead, tokenIdPermission); + upms->AddTempUriPermission(docsUri[0].ToString(), flagRead, callerTokenId, targetTokenId, 0); + ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagRead)[0]; ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(docsUri, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagWrite)[0]; ASSERT_EQ(ret, false); // write - upms->AddTempUriPermission(docsUri.ToString(), flagWrite, callerTokenId, targetTokenId, 0); - ret = upms->CheckUriPermission(docsUri, flagWrite, tokenIdPermission); + upms->AddTempUriPermission(docsUri[0].ToString(), flagWrite, callerTokenId, targetTokenId, 0); + ret = upms->CheckUriPermission(tokenIdPermission, docsUri, flagWrite)[0]; ASSERT_EQ(ret, true); MyFlag::permissionProxyAuthorization_ = false; } @@ -657,45 +576,46 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_004, TestSize.Level1) { auto upms = std::make_unique(); ASSERT_NE(upms, nullptr); - auto uri1 = Uri("file://com.example.app1001/data/storage/el2/base/haps/entry/files/test_001.txt"); - auto uri2 = Uri("file://com.example.app1002/data/storage/el2/base/haps/entry/files/test_002.txt"); + std::vector uri1 = { Uri("file://com.example.app1001/data/storage/el2/base/haps/entry/files/test_001.txt") }; + std::vector uri2 = { Uri("file://com.example.app1002/data/storage/el2/base/haps/entry/files/test_002.txt") }; uint32_t callerTokenId = 1001; uint32_t targetTokenId = 1002; uint32_t flagRead = 1; uint32_t flagWrite = 2; TokenIdPermission tokenIdPermission(callerTokenId); - auto ret = upms->CheckUriPermission(uri1, flagRead, tokenIdPermission); + MyFlag::tokenInfos[1001] = TokenInfo(1001, MyATokenTypeEnum::TOKEN_HAP, "", "com.example.app1001"); + auto ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagRead)[0]; ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(uri1, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagWrite)[0]; ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(uri2, flagRead, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, uri2, flagRead)[0]; ASSERT_EQ(ret, false); - ret = upms->CheckUriPermission(uri2, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, uri2, flagWrite)[0]; ASSERT_EQ(ret, false); // proxy uri permision MyFlag::permissionProxyAuthorization_ = true; tokenIdPermission = TokenIdPermission(targetTokenId); // no record - ret = upms->CheckUriPermission(uri1, flagRead, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagRead)[0]; ASSERT_EQ(ret, false); - ret = upms->CheckUriPermission(uri1, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagWrite)[0]; ASSERT_EQ(ret, false); // read - upms->AddTempUriPermission(uri1.ToString(), flagRead, callerTokenId, targetTokenId, 0); - ret = upms->CheckUriPermission(uri1, flagRead, tokenIdPermission); + upms->AddTempUriPermission(uri1[0].ToString(), flagRead, callerTokenId, targetTokenId, 0); + ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagRead)[0]; ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(uri1, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagWrite)[0]; ASSERT_EQ(ret, false); // write - upms->AddTempUriPermission(uri1.ToString(), flagWrite, callerTokenId, targetTokenId, 0); - ret = upms->CheckUriPermission(uri1, flagRead, tokenIdPermission); + upms->AddTempUriPermission(uri1[0].ToString(), flagWrite, callerTokenId, targetTokenId, 0); + ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagRead)[0]; ASSERT_EQ(ret, true); - ret = upms->CheckUriPermission(uri1, flagWrite, tokenIdPermission); + ret = upms->CheckUriPermission(tokenIdPermission, uri1, flagWrite)[0]; ASSERT_EQ(ret, true); MyFlag::permissionProxyAuthorization_ = false; } @@ -711,21 +631,21 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_005, TestSize.Level1) auto upms = std::make_unique(); ASSERT_NE(upms, nullptr); MyFlag::flag_ |= MyFlag::IS_SA_CALL; - auto uri = Uri("content://com.example.app1001/data/storage/el2/base/haps/entry/files/test_001.txt"); + std::vector uri = { Uri("content://com.example.app1001/data/storage/el2/base/haps/entry/files/test_1.txt") }; uint32_t flagRead = 1; uint32_t callerTokenId1 = 1001; IPCSkeleton::callerTokenId = callerTokenId1; MyFlag::tokenInfos[callerTokenId1] = TokenInfo(callerTokenId1, MyATokenTypeEnum::TOKEN_NATIVE, "foundation"); TokenIdPermission tokenIdPermission1(callerTokenId1); - auto ret = upms->CheckUriPermission(uri, flagRead, tokenIdPermission1); + auto ret = upms->CheckUriPermission(tokenIdPermission1, uri, flagRead)[0]; ASSERT_EQ(ret, true); uint32_t callerTokenId2 = 1002; IPCSkeleton::callerTokenId = callerTokenId2; MyFlag::tokenInfos[callerTokenId2] = TokenInfo(callerTokenId2, MyATokenTypeEnum::TOKEN_NATIVE, "testProcess"); TokenIdPermission tokenIdPermission2(callerTokenId2); - ret = upms->CheckUriPermission(uri, flagRead, tokenIdPermission2); + ret = upms->CheckUriPermission(tokenIdPermission2, uri, flagRead)[0]; ASSERT_EQ(ret, false); } @@ -1004,6 +924,7 @@ HWTEST_F(UriPermissionImplTest, CheckUriAuthorization_005, TestSize.Level1) const std::vector uris = { uri }; uint32_t flag = 1; uint32_t tokenId = 1001; + MyFlag::tokenInfos[1001] = TokenInfo(1001, MyATokenTypeEnum::TOKEN_HAP, "", "com.example.app1001"); auto res = upms->CheckUriAuthorization(uris, flag, tokenId); std::vector expectRes(1, true); EXPECT_EQ(res, expectRes); From 1ac648cf859c1a64e9b0afdc80905e93b3fc8148 Mon Sep 17 00:00:00 2001 From: luopengtao Date: Wed, 25 Sep 2024 08:56:47 +0000 Subject: [PATCH 23/26] =?UTF-8?q?CloseUIAbilityBySCB=E6=97=B6=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: luopengtao --- services/abilitymgr/src/ability_manager_service.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 8c6c168c9f..376db58049 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -3592,7 +3592,11 @@ int AbilityManagerService::CloseUIAbilityBySCB(const sptr &sessionI (void)DelayedSingleton::GetInstance()-> DeleteAbilityRecoverInfo(abilityInfo.applicationInfo.accessTokenId, abilityInfo.moduleName, abilityName); } - + bool forceKillProcess = ResSchedUtil::GetInstance().CheckShouldForceKillProcess(abilityRecord->GetPid()); + if (!forceKillProcess) { + IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->SetProcessCacheStatus( + abilityRecord->GetPid(), true)); + } EventInfo eventInfo; eventInfo.bundleName = abilityRecord->GetAbilityInfo().bundleName; eventInfo.abilityName = abilityRecord->GetAbilityInfo().name; From 44d8d3c330ef9dc8250a028fc871817a1cbbfaf7 Mon Sep 17 00:00:00 2001 From: gaojiaqi Date: Tue, 24 Sep 2024 09:27:41 +0800 Subject: [PATCH 24/26] add interfaces Signed-off-by: gaojiaqi --- .../include/ability_manager_client.h | 10 +++ .../include/ability_manager_interface.h | 13 ++++ .../ability_manager_ipc_interface_code.h | 3 + .../include/ability_manager_proxy.h | 12 +++ .../include/ability_manager_service.h | 4 + .../abilitymgr/include/ability_manager_stub.h | 1 + .../abilitymgr/src/ability_manager_client.cpp | 9 +++ .../abilitymgr/src/ability_manager_proxy.cpp | 78 +++++++++++++++++++ .../src/ability_manager_service.cpp | 30 +++++++ .../abilitymgr/src/ability_manager_stub.cpp | 43 ++++++++++ 10 files changed, 203 insertions(+) diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index b9966d0c2a..c1603eb2e2 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1596,6 +1596,16 @@ public: */ ErrCode BlockAllAppStart(bool flag); + /** + * update associate config list by rss. + * + * @param configs The rss config info. + * @param exportConfigs The rss export config info. + * @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config. + */ + ErrCode UpdateAssociateConfigList(const std::map>& configs, + const std::list& exportConfigs, int32_t flag); + private: AbilityManagerClient(); DISALLOW_COPY_AND_MOVE(AbilityManagerClient); diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 386f4834e2..c8a9a2bc9b 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -1746,6 +1746,19 @@ public: { return 0; } + + /** + * update associate config list by rss. + * + * @param configs The rss config info. + * @param exportConfigs The rss export config info. + * @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config. + */ + virtual int32_t UpdateAssociateConfigList(const std::map>& configs, + const std::list& exportConfigs, int32_t flag) + { + return 0; + } }; } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h index 417ab427e1..9a13e7599c 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h @@ -558,6 +558,9 @@ enum class AbilityManagerInterfaceCode { // ipc for block all apps from starting BLOCK_ALL_APP_START = 6119, + + // update associate config list + UPDATE_ASSOCIATE_CONFIG_LIST = 6120, }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index f7f546420d..8b32ec8b0b 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -1347,6 +1347,16 @@ public: */ virtual int32_t BlockAllAppStart(bool flag) override; + /** + * update associate config list by rss. + * + * @param configs The rss config info. + * @param exportConfigs The rss export config info. + * @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config. + */ + virtual int32_t UpdateAssociateConfigList(const std::map>& configs, + const std::list& exportConfigs, int32_t flag) override; + private: template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); @@ -1357,6 +1367,8 @@ private: MessageOption& option); int CheckUISessionParams(MessageParcel &data, const sptr &callerToken, const sptr &sessionInfo, int32_t userId, int requestCode); + bool UpdateAssociateConfigInner(const std::map>& configs, + MessageParcel& data); private: static inline BrokerDelegator delegator_; diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 9ced8c4761..1ccb97659f 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -1787,6 +1787,9 @@ public: int32_t TerminateMission(int32_t missionId) override; + int32_t UpdateAssociateConfigList(const std::map>& configs, + const std::list& exportConfigs, int32_t flag) override; + int32_t BlockAllAppStart(bool flag) override; int32_t StartUIAbilityBySCBDefaultCommon(AbilityRequest &abilityRequest, sptr sessionInfo, @@ -2359,6 +2362,7 @@ private: std::shared_ptr abilityAutoStartupService_; + std::mutex whiteListMutex_; std::map> whiteListMap_; std::list exportWhiteList_; diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 334976eb52..d29110c3d8 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -350,6 +350,7 @@ private: int32_t OpenLinkInner(MessageParcel &data, MessageParcel &reply); int32_t TerminateMissionInner(MessageParcel &data, MessageParcel &reply); int32_t BlockAllAppStartInner(MessageParcel &data, MessageParcel &reply); + int32_t UpdateAssociateConfigListInner(MessageParcel &data, MessageParcel &reply); }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index 01d6fcba3b..b715ff6415 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -2036,5 +2036,14 @@ ErrCode AbilityManagerClient::BlockAllAppStart(bool flag) CHECK_POINTER_RETURN_INVALID_VALUE(abms); return abms->BlockAllAppStart(flag); } + +ErrCode AbilityManagerClient::UpdateAssociateConfigList(const std::map>& configs, + const std::list& exportConfigs, int32_t flag) +{ + TAG_LOGD(AAFwkTag::ABILITYMGR, "call."); + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_NOT_CONNECTED(abms); + return abms->UpdateAssociateConfigList(configs, exportConfigs, flag); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index df93f425df..7b90485c37 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -35,6 +35,7 @@ namespace { using AutoStartupInfo = AbilityRuntime::AutoStartupInfo; constexpr int32_t CYCLE_LIMIT = 1000; constexpr int32_t MAX_AUTO_STARTUP_COUNT = 100; +constexpr int32_t MAX_UPDATE_CONFIG_SIZE = 100; bool AbilityManagerProxy::WriteInterfaceToken(MessageParcel &data) { if (!data.WriteInterfaceToken(AbilityManagerProxy::GetDescriptor())) { @@ -5611,5 +5612,82 @@ int32_t AbilityManagerProxy::BlockAllAppStart(bool flag) return reply.ReadInt32(); } + +int32_t AbilityManagerProxy::UpdateAssociateConfigList(const std::map>& configs, + const std::list& exportConfigs, int32_t flag) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + return IPC_PROXY_ERR; + } + + if (!UpdateAssociateConfigInner(configs, data)) { + return INNER_ERR; + } + + int32_t size = static_cast(exportConfigs.size()); + if (size > MAX_UPDATE_CONFIG_SIZE) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "export configs size too large"); + return INNER_ERR; + } + if (!data.WriteInt32(size)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write export configs size fail"); + return INNER_ERR; + } + for (const auto& config : exportConfigs) { + if (!data.WriteString(config)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write export config item fail"); + return INNER_ERR; + } + } + if (!data.WriteInt32(flag)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail"); + return INNER_ERR; + } + auto error = SendRequest(AbilityManagerInterfaceCode::UPDATE_ASSOCIATE_CONFIG_LIST, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + +bool AbilityManagerProxy::UpdateAssociateConfigInner(const std::map>& configs, + MessageParcel& data) +{ + int32_t size = static_cast(configs.size()); + if (size > MAX_UPDATE_CONFIG_SIZE) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "configs size too large"); + return false; + } + if (!data.WriteInt32(size)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write configs size fail"); + return false; + } + for (const auto& config : configs) { + if (!data.WriteString(config.first)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write config key fail"); + return false; + } + size = static_cast(config.second.size()); + if (size > MAX_UPDATE_CONFIG_SIZE) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "config size too large"); + return false; + } + if (!data.WriteInt32(size)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write config item size fail"); + return false; + } + for (const auto& item : config.second) { + if (!data.WriteString(item)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "write config item fail"); + return false; + } + } + } + return true; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index c7a72731f6..a86fa3826f 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -177,6 +177,10 @@ constexpr char ASSERT_FAULT_DETAIL[] = "assertFaultDialogDetail"; constexpr char PRODUCT_ASSERT_FAULT_DIALOG_ENABLED[] = "persisit.sys.abilityms.support_assert_fault_dialog"; constexpr const char* ABILITYMS_ENABLE_UISERVICE = "const.abilityms.enable_uiservice"; +constexpr int32_t RESOURCE_SCHEDULE_UID = 1096; +constexpr int32_t UPDATE_CONFIG_FLAG_COVER = 1; +constexpr int32_t UPDATE_CONFIG_FLAG_APPEND = 2; + const std::unordered_set COMMON_PICKER_TYPE = { "share", "action" }; @@ -11604,6 +11608,7 @@ void AbilityManagerService::ReportPreventStartAbilityResult(const AppExecFwk::Ab bool AbilityManagerService::IsInWhiteList(const std::string &callerBundleName, const std::string &calleeBundleName, const std::string &calleeAbilityName) { + std::lock_guard locker(whiteListMutex_); std::map>::iterator iter = whiteListMap_.find(callerBundleName); std::string uri = calleeBundleName + "/" + calleeAbilityName; if (iter != whiteListMap_.end()) { @@ -11625,6 +11630,7 @@ bool AbilityManagerService::ParseJsonFromBoot(const std::string &relativePath) if (ParseJsonValueFromFile(jsonObj, absolutePath) != ERR_OK) { return false; } + std::lock_guard locker(whiteListMutex_); nlohmann::json whiteListJsonList = jsonObj[WHITE_LIST]; for (const auto& [key, value] : whiteListJsonList.items()) { if (!value.is_array()) { @@ -12315,5 +12321,29 @@ bool AbilityManagerService::ShouldBlockAllAppStart() std::unique_lock lock(shouldBlockAllAppStartMutex_); return shouldBlockAllAppStart_; } + +int32_t AbilityManagerService::UpdateAssociateConfigList(const std::map>& configs, + const std::list& exportConfigs, int32_t flag) +{ + if (IPCSkeleton::GetCallingUid() != RESOURCE_SCHEDULE_UID) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Update associate config, current process not rss process"); + return CHECK_PERMISSION_FAILED; + } + std::lock_guard locker(whiteListMutex_); + if (flag == UPDATE_CONFIG_FLAG_COVER) { + whiteListMap_ = configs; + exportWhiteList_ = exportConfigs; + } else if (flag == UPDATE_CONFIG_FLAG_APPEND) { + for (const auto& config : configs) { + for (const auto& item : config.second) { + whiteListMap_[config.first].push_back(item); + } + } + for (const auto& config : exportConfigs) { + exportWhiteList_.push_back(config); + } + } + return ERR_OK; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index b5a3dc8a02..cbeaff74b8 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -29,6 +29,7 @@ namespace { const std::u16string extensionDescriptor = u"ohos.aafwk.ExtensionManager"; constexpr int32_t CYCLE_LIMIT = 1000; constexpr int32_t MAX_KILL_PROCESS_PID_COUNT = 100; +constexpr int32_t MAX_UPDATE_CONFIG_SIZE = 100; } // namespace AbilityManagerStub::AbilityManagerStub() {} @@ -757,6 +758,9 @@ int AbilityManagerStub::OnRemoteRequestInnerNineteenth(uint32_t code, MessagePar if (interfaceCode == AbilityManagerInterfaceCode::BLOCK_ALL_APP_START) { return BlockAllAppStartInner(data, reply); } + if (interfaceCode == AbilityManagerInterfaceCode::UPDATE_ASSOCIATE_CONFIG_LIST) { + return UpdateAssociateConfigListInner(data, reply); + } return ERR_CODE_NOT_EXIST; } @@ -4046,5 +4050,44 @@ int32_t AbilityManagerStub::BlockAllAppStartInner(MessageParcel &data, MessagePa } return ERR_OK; } + +int32_t AbilityManagerStub::UpdateAssociateConfigListInner(MessageParcel &data, MessageParcel &reply) +{ + int32_t size = data.ReadInt32(); + if (size > MAX_UPDATE_CONFIG_SIZE) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "config size error"); + return ERR_INVALID_VALUE; + } + std::map> configs; + for (int32_t i = 0; i < size; ++i) { + std::string key = data.ReadString(); + int32_t itemSize = data.ReadInt32(); + if (itemSize > MAX_UPDATE_CONFIG_SIZE) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "config size error"); + return ERR_INVALID_VALUE; + } + configs.emplace(key, std::list()); + for (int32_t j = 0; j < itemSize; ++j) { + configs[key].push_back(data.ReadString()); + } + } + + std::list exportConfigs; + size = data.ReadInt32(); + if (size > MAX_UPDATE_CONFIG_SIZE) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "config size error"); + return ERR_INVALID_VALUE; + } + for (int32_t i = 0; i < size; ++i) { + exportConfigs.push_back(data.ReadString()); + } + int32_t flag = data.ReadInt32(); + int32_t result = UpdateAssociateConfigList(configs, exportConfigs, flag); + if (result != NO_ERROR) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "update associate config fail"); + } + reply.WriteInt32(result); + return NO_ERROR; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file From 086cdc9483d4f2fa3a97042dc3b224c0eb834e2f Mon Sep 17 00:00:00 2001 From: hanchenZz Date: Wed, 25 Sep 2024 17:25:37 +0800 Subject: [PATCH 25/26] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=80=9A=E8=B7=AF=E4=BC=A0=E9=80=92JIT?= =?UTF-8?q?=E7=9A=84flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hanchenZz --- services/appmgr/src/app_mgr_service_inner.cpp | 5 ++++- services/appmgr/src/app_preloader.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 452f97fc30..4e5c824c32 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -3961,8 +3961,11 @@ void AppMgrServiceInner::RestartResidentProcess(std::shared_ptrGetBundleManagerHelper(); BundleInfo bundleInfo; auto userId = GetUserIdByUid(appRecord->GetUid()); + auto flags = BundleFlag::GET_BUNDLE_DEFAULT | BundleFlag::GET_BUNDLE_WITH_REQUESTED_PERMISSION; if (!IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfo( - appRecord->GetBundleName(), BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId))) { + appRecord->GetBundleName(), + static_cast(flags), + bundleInfo, userId))) { TAG_LOGE(AAFwkTag::APPMGR, "getBundleInfo fail"); return; } diff --git a/services/appmgr/src/app_preloader.cpp b/services/appmgr/src/app_preloader.cpp index e45b221e52..e610fbb3f5 100644 --- a/services/appmgr/src/app_preloader.cpp +++ b/services/appmgr/src/app_preloader.cpp @@ -134,8 +134,10 @@ bool AppPreloader::GetBundleAndHapInfo(const std::string &bundleName, int32_t us return false; } - if (!IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfo(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, - userId))) { + auto flags = BundleFlag::GET_BUNDLE_DEFAULT | BundleFlag::GET_BUNDLE_WITH_REQUESTED_PERMISSION; + if (!IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfo(bundleName, + static_cast(flags), + bundleInfo, userId))) { TAG_LOGE(AAFwkTag::APPMGR, "GetBundleInfo failed"); return false; } From db493a073da7cbc3379dcc3e712a106c473579c7 Mon Sep 17 00:00:00 2001 From: zhang_hao_zheng Date: Wed, 25 Sep 2024 11:18:55 +0800 Subject: [PATCH 26/26] =?UTF-8?q?want=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E6=A0=87=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhang_hao_zheng Change-Id: Ifdc636b38b9a4781357255cf00674620480b997c --- services/abilitymgr/src/ability_connect_manager.cpp | 3 +++ services/abilitymgr/src/ability_manager_service.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 99c29dac18..0fa15fcae7 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -64,6 +64,7 @@ const int32_t AUTO_DISCONNECT_INFINITY = -1; 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"; const std::string XIAOYI_BUNDLE_NAME = "com.huawei.hmos.vassistant"; @@ -2335,6 +2336,8 @@ void AbilityConnectManager::RestartAbility(const std::shared_ptr return; } + requestInfo.want.SetParam(WANT_PARAMS_APP_RESTART_FLAG, true); + // restart other resident ability if (abilityRecord->CanRestartResident()) { requestInfo.restartCount = abilityRecord->GetRestartCount(); diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 7e5d418cb0..32d50af839 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -158,6 +158,7 @@ constexpr size_t INDEX_TWO = 2; constexpr size_t ARGC_THREE = 3; 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"; +constexpr const char* WANT_PARAMS_APP_RESTART_FLAG = "ohos.aafwk.app.restart"; constexpr int32_t FOUNDATION_UID = 5523; constexpr const char* FRS_BUNDLE_NAME = "com.ohos.formrenderservice"; @@ -8227,6 +8228,7 @@ void AbilityManagerService::UpdateCallerInfo(Want& want, const sptrGetCallerInfo(); @@ -8373,6 +8377,7 @@ bool AbilityManagerService::UpdateAsCallerInfoFromDialog(Want& want) want.SetParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME, callerBundleName); want.SetParam(Want::PARAM_RESV_CALLER_ABILITY_NAME, callerAbilityName); want.RemoveParam(Want::PARAM_RESV_CALLER_NATIVE_NAME); + want.RemoveParam(WANT_PARAMS_APP_RESTART_FLAG); if (callerBundleName == "") { want.SetParam(Want::PARAM_RESV_CALLER_NATIVE_NAME, dialogCallerWant.GetStringParam(Want::PARAM_RESV_CALLER_NATIVE_NAME)); @@ -8399,6 +8404,7 @@ void AbilityManagerService::UpdateCallerInfoFromToken(Want& want, const sptrGetAbilityInfo().bundleName; want.RemoveParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);