From 737abe35a914fb0af7d53d8b6b9a7dd92892c4ee Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Wed, 11 Jun 2025 18:44:32 +0800 Subject: [PATCH] add AppMgrServiceInner unittest cases for ability_runtime Signed-off-by: zhangzezhong --- .../app_mgr_service_inner_ninth_test/BUILD.gn | 6 +- .../app_mgr_service_inner_ninth_test.cpp | 122 +- .../mock/include/mock_app_scheduler.h | 1 + .../mock/include/mock_my_status.h | 101 +- .../mock_app_mgr_service_event_handler.cpp | 86 ++ .../mock/src/mock_app_running_manager.cpp | 519 +++++++ .../mock/src/mock_app_running_record.cpp | 1332 +++++++++++++++++ .../mock_exit_resident_process_manager.cpp | 1 + .../mock/src/mock_ipc_skeleton.cpp | 2 + .../mock/src/mock_parameters.cpp | 4 + 10 files changed, 2100 insertions(+), 74 deletions(-) create mode 100644 test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_mgr_service_event_handler.cpp create mode 100644 test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp create mode 100644 test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_record.cpp diff --git a/test/unittest/app_mgr_service_inner_ninth_test/BUILD.gn b/test/unittest/app_mgr_service_inner_ninth_test/BUILD.gn index fe7dd5841d0..4e22e11ce0c 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/BUILD.gn +++ b/test/unittest/app_mgr_service_inner_ninth_test/BUILD.gn @@ -54,11 +54,8 @@ ohos_unittest("app_mgr_service_inner_ninth_test") { "${ability_runtime_services_path}/appmgr/src/app_lifecycle_deal.cpp", "${ability_runtime_services_path}/appmgr/src/app_mgr_event.cpp", "${ability_runtime_services_path}/appmgr/src/app_mgr_service.cpp", - "${ability_runtime_services_path}/appmgr/src/app_mgr_service_event_handler.cpp", "${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp", "${ability_runtime_services_path}/appmgr/src/app_native_spawn_manager.cpp", - "${ability_runtime_services_path}/appmgr/src/app_running_manager.cpp", - "${ability_runtime_services_path}/appmgr/src/app_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp", "${ability_runtime_services_path}/appmgr/src/app_state_observer_manager.cpp", "${ability_runtime_services_path}/appmgr/src/cache_process_manager.cpp", @@ -76,7 +73,10 @@ ohos_unittest("app_mgr_service_inner_ninth_test") { "app_mgr_service_inner_ninth_test.cpp", "mock/src/mock_accesstoken_kit.cpp", "mock/src/mock_app_death_recipient.cpp", + "mock/src/mock_app_mgr_service_event_handler.cpp", "mock/src/mock_app_preloader.cpp", + "mock/src/mock_app_running_manager.cpp", + "mock/src/mock_app_running_record.cpp", "mock/src/mock_app_spawn_client.cpp", "mock/src/mock_bundle_mgr_helper.cpp", "mock/src/mock_exit_resident_process_manager.cpp", diff --git a/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp b/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp index 2e08a13a854..cce0d341a71 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp +++ b/test/unittest/app_mgr_service_inner_ninth_test/app_mgr_service_inner_ninth_test.cpp @@ -48,7 +48,13 @@ constexpr const char* DEVELOPER_MODE_STATE = "const.security.developermode.state constexpr const char* DEBUG_APP = "debugApp"; constexpr const char* DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag"; static int g_scheduleLoadChildCall = 0; - +constexpr const char* UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId"; +constexpr const char* UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid"; +constexpr const char* UIEXTENSION_HOST_PID = "ability.want.params.uiExtensionHostPid"; +constexpr const char* UIEXTENSION_HOST_UID = "ability.want.params.uiExtensionHostUid"; +constexpr const char* UIEXTENSION_HOST_BUNDLENAME = "ability.want.params.uiExtensionHostBundleName"; +constexpr const char* UIEXTENSION_BIND_ABILITY_ID = "ability.want.params.uiExtensionBindAbilityId"; +constexpr const char* UIEXTENSION_NOTIFY_BIND = "ohos.uiextension.params.notifyProcessBind"; namespace OHOS { namespace AppExecFwk { class AppMgrServiceInnerNinthTest : public testing::Test { @@ -58,55 +64,6 @@ public: void SetUp() override; void TearDown() override; }; -class MyKiaInterceptor : public IKiaInterceptor { -public: - int OnIntercept(AAFwk::Want &want) override - { - return 0; - } - - sptr AsObject() override - { - return nullptr; - } -}; -class MyRenderStateObserver : public IRenderStateObserver { -public: - void OnRenderStateChanged(const RenderStateData &renderStateData) override {} - sptr AsObject() override - { - return nullptr; - } -}; -class MyChildScheduler : public IChildScheduler { -public: - bool ScheduleLoadChild() override - { - g_scheduleLoadChildCall++; - return false; - } - bool ScheduleExitProcessSafely() override - { - return false; - } - bool ScheduleRunNativeProc(const sptr &mainProcessCb) override - { - return false; - } - sptr AsObject() override - { - return nullptr; - } -}; -class MyRenderScheduler : public IRenderScheduler { -public: - void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, sptr browser) override {} - sptr AsObject() override - { - return nullptr; - } -}; class MyAbilityDebugResponse : public IAbilityDebugResponse { public: @@ -143,28 +100,29 @@ public: } }; -class MyRemoteObject : public IRemoteStub { +class MockIAppStateCallback : public IAppStateCallback { public: - static sptr GetInstance() + MockIAppStateCallback() = default; + virtual ~MockIAppStateCallback() = default; + MOCK_METHOD1(OnAppStateChanged, void(const AppProcessData &appProcessData)); + MOCK_METHOD2(OnAbilityRequestDone, void(const sptr &token, const AbilityState state)); + void NotifyAppPreCache(int32_t pid, int32_t userId) override { - static sptr instance = new MyRemoteObject(); - return instance; + AAFwk::MyStatus::GetInstance().notifyAppPreCacheCalled_ = true; + } + void NotifyStartResidentProcess(std::vector &bundleInfos) override + { + AAFwk::MyStatus::GetInstance().notifyStartResidentProcessCalled_ = true; + } + void NotifyStartKeepAliveProcess(std::vector &bundleInfos) override + { + AAFwk::MyStatus::GetInstance().notifyStartKeepAliveProcessCalled_ = true; + } + sptr AsObject() override + { + return nullptr; } - - void OnAbilityConnectDone(const AppExecFwk::ElementName& element, - const sptr& remoteObject, int resultCode) override - {} - - void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override - {} - -private: - MyRemoteObject() = default; - ~MyRemoteObject() override = default; - MyRemoteObject(const MyRemoteObject&) = delete; - MyRemoteObject& operator=(const MyRemoteObject&) = delete; }; - void AppMgrServiceInnerNinthTest::SetUpTestCase() {} void AppMgrServiceInnerNinthTest::TearDownTestCase() {} @@ -300,6 +258,34 @@ HWTEST_F(AppMgrServiceInnerNinthTest, PreloadApplication_005, TestSize.Level1) EXPECT_EQ(ret, AAFwk::ERR_NOT_ALLOW_PRELOAD_BY_RSS); TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_005 end"); } + +/** + * @tc.name: PreloadApplication_006 + * @tc.desc: test PreloadApplication + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerNinthTest, PreloadApplication_006, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_006 start"); + auto appMgrServiceInner = std::make_shared(); + + AAFwk::MyStatus::GetInstance().judgeCallerIsAllowed_ = false; + AAFwk::MyStatus::GetInstance().verifyCallingPermission_ = true; + AAFwk::MyStatus::GetInstance().isSACall_ = false; + AAFwk::MyStatus::GetInstance().isLogoutUser_ = false; + AAFwk::MyStatus::GetInstance().allowPreload_ = true; + AAFwk::MyStatus::GetInstance().generatePreloadRequestRet_ = ERR_INVALID_VALUE; + appMgrServiceInner->appPreloader_ = std::make_shared(nullptr); + + std::string bundleName = "com.test.preload"; + int32_t userId = 100; + PreloadMode preloadMode = PreloadMode::PRE_MAKE; + int32_t appIndex = 0; + + int32_t ret = appMgrServiceInner->PreloadApplication(bundleName, userId, preloadMode, appIndex); + EXPECT_EQ(ret, AAFwk::ERR_NOT_SYSTEM_APP); + TAG_LOGI(AAFwkTag::TEST, "PreloadApplication_006 end"); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_app_scheduler.h b/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_app_scheduler.h index 53877f10599..70c93a2e7aa 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_app_scheduler.h +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_app_scheduler.h @@ -71,6 +71,7 @@ public: MOCK_METHOD0(ScheduleClearPageStack, void()); MOCK_METHOD0(IsMemorySizeSufficent, bool()); MOCK_METHOD0(ScheduleCacheProcess, void()); + MOCK_METHOD1(ScheduleCjHeapMemory, void(OHOS::AppExecFwk::CjHeapDumpInfo &info)); bool AddDeathRecipient(const sptr &recipient) override { return AAFwk::MyStatus::GetInstance().addDeathRecipientReturn_; diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_my_status.h b/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_my_status.h index 71415c1348c..0ba73811ccc 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_my_status.h +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/include/mock_my_status.h @@ -203,7 +203,51 @@ public: int debugAppCalledTimes_ = 0; int addModuleCalledTimes_ = 0; bool getStateCalled_ = false; - void resetRunningRecordFunctionFlag() + bool getBundleNamesCalled_ = false; + bool isStartSpecifiedAbility_ = false; + bool isNewProcessRequest_ = false; + int getSpecifiedRequestIdCall_ = 0; + bool setStateCalled_ = false; + int resetSpecifiedRequestCall_ = 0; + bool getBundleNameCalled_ = false; + int removeChildProcessRecordCall_ = 0; + int getParentAppRecordCall_ = 0; + bool getAbilityRunningRecordByTokenCalled_ = false; + bool setApplicationClientCalled_ = false; + bool getRecordIdCalled_ = false; + bool isGetAppRunningByBundleName_ = false; + bool getDialogEnabled_ = false; + int getCallingPid_ = 0; + bool setAssertionPauseFlagCalled_ = false; + bool getAbilitiesCalled_ = false; + bool notifyAppPreCacheCalled_ = false; + bool notifyStartResidentProcessCalled_ = false; + bool notifyStartKeepAliveProcessCalled_ = false; + int getCallingUidCalledTimes_ = 0; + int getAppRunningRecordMapCall_ = 0; + bool setKeepAliveEnableStateCalled_ = false; + bool setKeepAliveDkvCalled_ = false; + bool isKeepAliveApp_ = false; + bool getUidCalled_ = false; + bool queryExitBundleInfos_called_ = false; + bool updateInstanceKeyBySpecifiedIdCalled_ = false; + bool addUIExtensionBindItemCalled_ = false; + bool killProcessByPidCalled_ = false; + pid_t killProcessByPid_pid_ = 0; + bool setUserRequestCleaningCalled_ = false; + bool isAllAbilityReadyToCleanedByUserRequestCalled_ = false; + bool isAllAbilityReadyToCleanedByUserRequest_ = false; + bool queryUIExtensionBindItemByIdCalled_ = false; + bool removeUIExtensionBindItemByIdCalled_ = false; + int32_t queryUIExtensionBindItemByIdResult_ = ERR_OK; + int32_t notifyProcessBind_ = 0; + + bool getAbilityInfoCalled_ = false; + bool isKeepAliveAppCalled_ = false; + bool getUIExtensionBindAbilityIdCalled_ = false; + int32_t queryUIExtensionBindItemById_ = static_cast(ERR_INVALID_VALUE); + bool getAbilityRunningRecordByTokenCalledAppRecord_ = false; + void resetRunningRecordFunctionFlagExtend() { appRunningRecordSetAppDeathRecipientCalled_ = false; getPidCall_ = false; @@ -217,6 +261,57 @@ public: debugAppCalledTimes_ = 0; addModuleCalledTimes_ = 0; getStateCalled_ = false; + getBundleNamesCalled_ = false; + isStartSpecifiedAbility_ = false; + isNewProcessRequest_ = false; + getSpecifiedRequestIdCall_ = 0; + getNewProcessRequestIdCall_ = 0; + setStateCalled_ = false; + resetNewProcessRequestCall_ = 0; + resetSpecifiedRequestCall_ = 0; + getBundleNameCalled_ = false; + getChildProcessRecordByPidCall_ = 0; + getAppRunningProcessPidCall_ = 0; + removeChildProcessRecordCall_ = 0; + getParentAppRecordCall_ = 0; + getAbilityRunningRecordByTokenCalled_ = false; + getAbilityRunningRecordByTokenCalledAppRecord_ = false; + setApplicationClientCalled_ = false; + getRecordIdCalled_ = false; + isGetAppRunningByBundleName_ = false; + getDialogEnabled_ = false; + getCallingPid_ = 0; + } + void resetRunningRecordFunctionFlag() + { + resetRunningRecordFunctionFlagExtend(); + setAssertionPauseFlagCalled_ = false; + getAbilitiesCalled_ = false; + notifyAppPreCacheCalled_ = false; + notifyStartResidentProcessCalled_ = false; + notifyStartKeepAliveProcessCalled_ = false; + getCallingUidCalledTimes_ = 0; + getAppRunningRecordMapCall_ = 0; + setKeepAliveEnableStateCalled_ = false; + setKeepAliveDkvCalled_ = false; + isKeepAliveApp_ = false; + getUidCalled_ = false; + queryExitBundleInfos_called_ = false; + updateInstanceKeyBySpecifiedIdCalled_ = false; + addUIExtensionBindItemCalled_ = false; + killProcessByPidCalled_ = false; + killProcessByPid_pid_ = 0; + setUserRequestCleaningCalled_ = false; + isAllAbilityReadyToCleanedByUserRequestCalled_ = false; + isAllAbilityReadyToCleanedByUserRequest_ = false; + queryUIExtensionBindItemByIdCalled_ = false; + removeUIExtensionBindItemByIdCalled_ = false; + queryUIExtensionBindItemByIdResult_ = ERR_OK; + notifyProcessBind_ = 0; + getAbilityInfoCalled_ = false; + isKeepAliveAppCalled_ = false; + getUIExtensionBindAbilityIdCalled_ = false; + queryUIExtensionBindItemById_ = static_cast(ERR_INVALID_VALUE); } // StartAbility tracking variables @@ -258,11 +353,11 @@ public: addModuleCalled_ = false; getModuleRecordByModuleNameCalled_ = false; } - - bool getAbilityRunningRecordByTokenCalled_ = false; + std::shared_ptr runningRecord_ = nullptr; void resetModuleRunningFlags() { getAbilityRunningRecordByTokenCalled_ = false; + runningRecord_ = nullptr; } private: MyStatus() = default; diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_mgr_service_event_handler.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_mgr_service_event_handler.cpp new file mode 100644 index 00000000000..c2f8f1529a3 --- /dev/null +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_mgr_service_event_handler.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "app_mgr_service_event_handler.h" + +#include "app_mgr_service_inner.h" +#include "hilog_tag_wrapper.h" +#include "mock_my_status.h" + +namespace OHOS { +namespace AppExecFwk { +AMSEventHandler::AMSEventHandler(const std::shared_ptr &taskHandler, + const std::weak_ptr &appMgr) + : AAFwk::EventHandlerWrap(taskHandler), appMgr_(appMgr) +{ + TAG_LOGI(AAFwkTag::APPMGR, "instance created"); +} + +AMSEventHandler::~AMSEventHandler() +{ + TAG_LOGI(AAFwkTag::APPMGR, "instance destroyed"); +} + +void AMSEventHandler::ProcessEvent(const AAFwk::EventWrap &event) +{ + auto appManager = appMgr_.lock(); + if (!appManager) { + TAG_LOGE(AAFwkTag::APPMGR, "null appManager"); + return; + } + appManager->HandleTimeOut(event); +} + +AppEventUtil &AppEventUtil::GetInstance() +{ + static AppEventUtil instance; + return instance; +} + +void AppEventUtil::AddEvent(std::shared_ptr appRecord, uint32_t eventId, int64_t param) +{ + if (appRecord == nullptr) { + return; + } + std::lock_guard lock(appEventListMutex_); + appEventList_.emplace_back(eventId, param, appRecord); +} + +bool AppEventUtil::HasEvent(std::shared_ptr appRecord, uint32_t eventId) +{ + if (appRecord == nullptr) { + return false; + } + std::lock_guard lock(appEventListMutex_); + for (const auto &item : appEventList_) { + if (item.appRecord.lock() == appRecord && item.eventId == eventId) { + return true; + } + } + return false; +} + +std::shared_ptr AppEventUtil::RemoveEvent(uint32_t eventId, int64_t param) +{ + return AAFwk::MyStatus::GetInstance().runningRecord_; +} + +std::list AppEventUtil::RemoveEvent(std::shared_ptr appRecord, uint32_t eventId) +{ + std::list result; + return result; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp new file mode 100644 index 00000000000..f594b91f791 --- /dev/null +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_manager.cpp @@ -0,0 +1,519 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "app_running_manager.h" + +#include "app_mgr_service_inner.h" +#include "datetime_ex.h" +#include "iremote_object.h" + +#include "appexecfwk_errors.h" +#include "app_utils.h" +#include "hilog_tag_wrapper.h" +#include "hitrace_meter.h" +#include "killing_process_manager.h" +#include "perf_profile.h" +#include "parameters.h" +#include "quick_fix_callback_with_record.h" +#include +#ifdef SUPPORT_SCREEN + +#endif //SUPPORT_SCREEN +#include "app_mgr_service_const.h" +#include "app_mgr_service_dump_error_code.h" +#include "mock_my_status.h" + +namespace OHOS { +namespace AppExecFwk { +namespace { +constexpr int32_t QUICKFIX_UID = 5524; +constexpr int32_t DEAD_APP_RECORD_CLEAR_TIME = 3000; // ms +constexpr const char* DEVELOPER_MODE_STATE = "const.security.developermode.state"; +} + +AppRunningManager::AppRunningManager() +{} +AppRunningManager::~AppRunningManager() +{} + +std::shared_ptr AppRunningManager::CreateAppRunningRecord( + const std::shared_ptr &appInfo, const std::string &processName, const BundleInfo &bundleInfo, + const std::string &instanceKey, const std::string &customProcessFlag) +{ + return AAFwk::MyStatus::GetInstance().createAppRunning_; +} + +std::shared_ptr AppRunningManager::CheckAppRunningRecordIsExist(const std::string &appName, + const std::string &processName, const int uid, const BundleInfo &bundleInfo, + const std::string &specifiedProcessFlag, bool *isProCache, const std::string &instanceKey, + const std::string &customProcessFlag) +{ + AAFwk::MyStatus::GetInstance().checkAppRunningCall_++; + if (AAFwk::MyStatus::GetInstance().checkAppRunning_) { + AAFwk::MyStatus::GetInstance().handlePreloadApplication_existingAppRecord_called_ = true; + } + return AAFwk::MyStatus::GetInstance().checkAppRunning_; +} + +#ifdef APP_NO_RESPONSE_DIALOG +bool AppRunningManager::CheckAppRunningRecordIsExist(const std::string &bundleName, const std::string &abilityName) +{ + return false; +} +#endif + +bool AppRunningManager::IsAppExist(uint32_t accessTokenId) +{ + AAFwk::MyStatus::GetInstance().isAppExistCall_++; + return false; +} + +bool AppRunningManager::CheckAppRunningRecordIsExistByUid(int32_t uid) +{ + if (!AAFwk::MyStatus::GetInstance().checkAppRunningByUid_) { + AAFwk::MyStatus::GetInstance().handlePreloadApplication_appMultiUserNotExist_called_ = true; + } + return AAFwk::MyStatus::GetInstance().checkAppRunningByUid_; +} + +int32_t AppRunningManager::CheckAppCloneRunningRecordIsExistByBundleName(const std::string &bundleName, + int32_t appCloneIndex, bool &isRunning) +{ + return AAFwk::MyStatus::GetInstance().checkAppClone_; +} + +int32_t AppRunningManager::IsAppRunningByBundleNameAndUserId(const std::string &bundleName, + int32_t userId, bool &isRunning) +{ + return AAFwk::MyStatus::GetInstance().isAppRunningByBundleName_; +} + +int32_t AppRunningManager::GetAllAppRunningRecordCountByBundleName(const std::string &bundleName) +{ + return AAFwk::MyStatus::GetInstance().getAllAppRunningRecordCount_; +} + +std::shared_ptr AppRunningManager::GetAppRunningRecordByPid(const pid_t pid) +{ + AAFwk::MyStatus::GetInstance().getApplicationInfoCalled_ = true; + return AAFwk::MyStatus::GetInstance().getAppRunningRecordByPid_; +} + +std::shared_ptr AppRunningManager::GetAppRunningRecordByAbilityToken( + const sptr &abilityToken) +{ + AAFwk::MyStatus::GetInstance().getAbilityRunningRecordByTokenCalled_ = true; + return AAFwk::MyStatus::GetInstance().getAppRunningByToken_; +} + +bool AppRunningManager::ProcessExitByBundleName( + const std::string &bundleName, std::list &pids, const bool clearPageStack) +{ + return false; +} + +bool AppRunningManager::GetPidsByUserId(int32_t userId, std::list &pids) +{ + return false; +} + +bool AppRunningManager::GetProcessInfosByUserId(int32_t userId, std::list &processInfos) +{ + return false; +} + +int32_t AppRunningManager::ProcessUpdateApplicationInfoInstalled( + const ApplicationInfo& appInfo, const std::string& moduleName) +{ + return AAFwk::MyStatus::GetInstance().processUpdate_; +} + +bool AppRunningManager::ProcessExitByBundleNameAndUid( + const std::string &bundleName, const int uid, std::list &pids, const KillProcessConfig &config) +{ + return AAFwk::MyStatus::GetInstance().processExit_; +} + +bool AppRunningManager::ProcessExitByBundleNameAndAppIndex(const std::string &bundleName, int32_t appIndex, + std::list &pids, bool clearPageStack) +{ + return false; +} + +bool AppRunningManager::ProcessExitByTokenIdAndInstance(uint32_t accessTokenId, const std::string &instanceKey, + std::list &pids, bool clearPageStack) +{ + return false; +} + +bool AppRunningManager::GetPidsByBundleNameUserIdAndAppIndex(const std::string &bundleName, + const int userId, const int appIndex, std::list &pids) +{ + pids = AAFwk::MyStatus::GetInstance().getPidsByBundleName_; + return AAFwk::MyStatus::GetInstance().getPidsByBundleNameRet_; +} + +std::shared_ptr AppRunningManager::OnRemoteDied(const wptr &remote, + std::shared_ptr appMgrServiceInner) +{ + return AAFwk::MyStatus::GetInstance().runningRecord_; +} + +std::map> AppRunningManager::GetAppRunningRecordMap() +{ + AAFwk::MyStatus::GetInstance().getAppRunningRecordMapCall_++; + return AAFwk::MyStatus::GetInstance().getAppRunningRecordMap_; +} + +void AppRunningManager::RemoveAppRunningRecordById(const int32_t recordId) +{ +} + +void AppRunningManager::ClearAppRunningRecordMap() +{ +} + +void AppRunningManager::HandleTerminateTimeOut(int64_t eventId) +{ +} + +std::shared_ptr AppRunningManager::GetTerminatingAppRunningRecord( + const sptr &abilityToken) +{ + return nullptr; +} + +std::shared_ptr AppRunningManager::GetAbilityRunningRecord(const int64_t eventId) +{ + return nullptr; +} + +void AppRunningManager::HandleAbilityAttachTimeOut(const sptr &token, + std::shared_ptr serviceInner) +{ +} + +void AppRunningManager::PrepareTerminate(const sptr &token, bool clearMissionFlag) +{ +} + +void AppRunningManager::TerminateAbility(const sptr &token, bool clearMissionFlag, + std::shared_ptr appMgrServiceInner) +{ +} + +void AppRunningManager::NotifyAppPreCache(const std::shared_ptr& appRecord, + const std::shared_ptr& appMgrServiceInner) +{ +} + +void AppRunningManager::GetRunningProcessInfoByToken( + const sptr &token, AppExecFwk::RunningProcessInfo &info) +{ +} + +int32_t AppRunningManager::GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) +{ + return 0; +} + +int32_t AppRunningManager::GetRunningProcessInfoByChildProcessPid(const pid_t childPid, + OHOS::AppExecFwk::RunningProcessInfo &info) +{ + return 0; +} + +int32_t AppRunningManager::AssignRunningProcessInfoByAppRecord( + std::shared_ptr appRecord, AppExecFwk::RunningProcessInfo &info) const +{ + return ERR_OK; +} + +void AppRunningManager::SetAbilityForegroundingFlagToAppRecord(const pid_t pid) +{ +} + +void AppRunningManager::ClipStringContent(const std::regex &re, const std::string &source, std::string &afterCutStr) +{ +} + +void AppRunningManager::GetForegroundApplications(std::vector &list) +{ +} + +int32_t AppRunningManager::UpdateConfiguration(const Configuration& config, const int32_t userId) +{ + return 0; +} + +int32_t AppRunningManager::UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, + int32_t appIndex) +{ + return AAFwk::MyStatus::GetInstance().updateConfigurationByBundleName_; +} + +bool AppRunningManager::isCollaboratorReserveType(const std::shared_ptr &appRecord) +{ + return false; +} + +int32_t AppRunningManager::NotifyMemoryLevel(int32_t level) +{ + return ERR_OK; +} + +int32_t AppRunningManager::NotifyProcMemoryLevel(const std::map &procLevelMap) +{ + AAFwk::MyStatus::GetInstance().notifyProcMemoryCall_++; + return AAFwk::MyStatus::GetInstance().notifyProcMemory_; +} + +int32_t AppRunningManager::DumpHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo) +{ + return AAFwk::MyStatus::GetInstance().dumpHeapMemory_; +} + +int32_t AppRunningManager::DumpJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) +{ + return AAFwk::MyStatus::GetInstance().dumpJsHeapMemory_; +} + +std::shared_ptr AppRunningManager::GetAppRunningRecordByRenderPid(const pid_t pid) +{ + return AAFwk::MyStatus::GetInstance().getAppRunningRecordByRenderPid_; +} + +std::shared_ptr AppRunningManager::OnRemoteRenderDied(const wptr &remote) +{ + return nullptr; +} + +bool AppRunningManager::GetAppRunningStateByBundleName(const std::string &bundleName) +{ + return AAFwk::MyStatus::GetInstance().isGetAppRunningByBundleName_; +} + +int32_t AppRunningManager::NotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback) +{ + return false; +} + +int32_t AppRunningManager::NotifyHotReloadPage(const std::string &bundleName, const sptr &callback) +{ + return 0; +} + +int32_t AppRunningManager::NotifyUnLoadRepairPatch(const std::string &bundleName, + const sptr &callback) +{ + return 0; +} + +bool AppRunningManager::IsApplicationFirstForeground(const AppRunningRecord &foregroundingRecord) +{ + return true; +} + +bool AppRunningManager::IsApplicationBackground(const AppRunningRecord &backgroundingRecord) +{ + return true; +} +#ifdef SUPPORT_SCREEN +void AppRunningManager::OnWindowVisibilityChanged( + const std::vector> &windowVisibilityInfos) +{ +} +#endif //SUPPORT_SCREEN +bool AppRunningManager::IsApplicationFirstFocused(const AppRunningRecord &focusedRecord) +{ + return true; +} + +bool AppRunningManager::IsApplicationUnfocused(const std::string &bundleName) +{ + return true; +} + +void AppRunningManager::SetAttachAppDebug(const std::string &bundleName, const bool &isAttachDebug, + bool isDebugFromLocal) +{ +} + +std::vector AppRunningManager::GetAppDebugInfosByBundleName( + const std::string &bundleName, const bool &isDetachDebug) +{ + std::vector ret; + return ret; +} + +void AppRunningManager::GetAbilityTokensByBundleName( + const std::string &bundleName, std::vector> &abilityTokens) +{ +} + +#ifdef SUPPORT_CHILD_PROCESS +std::shared_ptr AppRunningManager::GetAppRunningRecordByChildProcessPid(const pid_t pid) +{ + AAFwk::MyStatus::GetInstance().getAppRunningProcessPidCall_++; + return AAFwk::MyStatus::GetInstance().getAppRunningProcessPid_; +} + +bool AppRunningManager::IsChildProcessReachLimit(uint32_t accessTokenId, bool multiProcessFeature) +{ + return AAFwk::MyStatus::GetInstance().isChildProcessReachLimit_; +} + +std::shared_ptr AppRunningManager::OnChildProcessRemoteDied(const wptr &remote) +{ + AAFwk::MyStatus::GetInstance().getChildProcessRecordByPidCall_++; + return nullptr; +} +#endif //SUPPORT_CHILD_PROCESS + +int32_t AppRunningManager::SignRestartAppFlag(int32_t uid, const std::string &instanceKey) +{ + return 0; +} + +int32_t AppRunningManager::AddUIExtensionBindItem( + int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo) +{ + AAFwk::MyStatus::GetInstance().addUIExtensionBindItemCalled_ = true; + return ERR_OK; +} + +int32_t AppRunningManager::GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId) +{ + return ERR_OK; +} + +int32_t AppRunningManager::GetAllUIExtensionRootHostPid(pid_t pid, std::vector &hostPids) +{ + return ERR_OK; +} + +int32_t AppRunningManager::GetAllUIExtensionProviderPid(pid_t hostPid, std::vector &providerPids) +{ + return ERR_OK; +} + +int32_t AppRunningManager::AddUIExtensionLauncherItem(int32_t uiExtensionAbilityId, pid_t hostPid, pid_t providerPid) +{ + return ERR_OK; +} + +int32_t AppRunningManager::RemoveUIExtensionLauncherItem(pid_t pid) +{ + return ERR_OK; +} + +int32_t AppRunningManager::RemoveUIExtensionLauncherItemById(int32_t uiExtensionAbilityId) +{ + return ERR_OK; +} + +int AppRunningManager::DumpIpcAllStart(std::string& result) +{ + return AAFwk::MyStatus::GetInstance().dumpIpcAllStart_; +} + +int AppRunningManager::DumpIpcAllStop(std::string& result) +{ + return AAFwk::MyStatus::GetInstance().dumpIpcAllStop_; +} + +int AppRunningManager::DumpIpcAllStat(std::string& result) +{ + return AAFwk::MyStatus::GetInstance().dumpIpcAllStat_; +} + +int AppRunningManager::DumpIpcStart(const int32_t pid, std::string& result) +{ + return AAFwk::MyStatus::GetInstance().dumpIpcStart_; +} + +int AppRunningManager::DumpIpcStop(const int32_t pid, std::string& result) +{ + return AAFwk::MyStatus::GetInstance().dumpIpcStop_; +} + +int AppRunningManager::DumpIpcStat(const int32_t pid, std::string& result) +{ + return AAFwk::MyStatus::GetInstance().dumpIpcStat_; +} + +int AppRunningManager::DumpFfrt(const std::vector& pids, std::string& result) +{ + return AAFwk::MyStatus::GetInstance().dumpFfrt_; +} + +bool AppRunningManager::HandleUserRequestClean(const sptr &abilityToken, pid_t &pid, int32_t &uid) +{ + pid = AAFwk::MyStatus::GetInstance().handleUserRequestCleanPid_; + uid = AAFwk::MyStatus::GetInstance().handleUserRequestCleanUid_; + return AAFwk::MyStatus::GetInstance().handleUserRequestClean_; +} + +bool AppRunningManager::IsAppProcessesAllCached(const std::string &bundleName, int32_t uid, + const std::set> &cachedSet) +{ + return true; +} + +int32_t AppRunningManager::UpdateConfigurationDelayed(const std::shared_ptr& appRecord) +{ + return 0; +} + +int32_t AppRunningManager::CheckIsKiaProcess(pid_t pid, bool &isKia) +{ + return AAFwk::MyStatus::GetInstance().checkIsKiaProcess_; +} + +bool AppRunningManager::CheckAppRunningRecordIsLast(const std::shared_ptr &appRecord) +{ + return true; +} + +void AppRunningManager::UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std::string &instanceKey) +{ + AAFwk::MyStatus::GetInstance().updateInstanceKeyBySpecifiedIdCalled_ = true; +} + +std::shared_ptr AppRunningManager::QueryAppRecordPlus(int32_t pid, int32_t uid) +{ + return AAFwk::MyStatus::GetInstance().queryAppRecordPlus_; +} + +void AppRunningManager::AddRecordToDeadList(std::shared_ptr appRecord) +{ +} + +void AppRunningManager::RemoveTimeoutDeadAppRecord() +{ +} +int32_t AppRunningManager::RemoveUIExtensionBindItemById(int32_t uiExtensionBindAbilityId) +{ + AAFwk::MyStatus::GetInstance().removeUIExtensionBindItemByIdCalled_ = true; + return ERR_OK; +} +int32_t AppRunningManager::QueryUIExtensionBindItemById( + int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo) +{ + bindInfo.notifyProcessBind = AAFwk::MyStatus::GetInstance().notifyProcessBind_; + return AAFwk::MyStatus::GetInstance().queryUIExtensionBindItemById_; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_record.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_record.cpp new file mode 100644 index 00000000000..f1f464657c8 --- /dev/null +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_app_running_record.cpp @@ -0,0 +1,1332 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "app_running_record.h" +#include "mock_my_status.h" +namespace OHOS { +namespace AppExecFwk { +AppRunningRecord::AppRunningRecord( + const std::shared_ptr &info, const int32_t recordId, const std::string &processName) + : appRecordId_(recordId), processName_(processName) +{ + if (info) { + appInfo_ = info; + mainBundleName_ = info->bundleName; + isLauncherApp_ = info->isLauncherApp; + mainAppName_ = info->name; + } +} + +void AppRunningRecord::SetApplicationClient(const sptr &thread) +{ + AAFwk::MyStatus::GetInstance().setApplicationClientCalled_ = true; +} + +const std::string &AppRunningRecord::GetBundleName() const +{ + AAFwk::MyStatus::GetInstance().getBundleNameCalled_ = true; + return mainBundleName_; +} + +int32_t AppRunningRecord::GetCallerPid() const +{ + return 0; +} + +void AppRunningRecord::SetCallerPid(int32_t pid) +{ +} + +int32_t AppRunningRecord::GetCallerUid() const +{ + return 0; +} + +void AppRunningRecord::SetCallerUid(int32_t uid) +{ +} + +int32_t AppRunningRecord::GetCallerTokenId() const +{ + return 0; +} + +void AppRunningRecord::SetCallerTokenId(int32_t tokenId) +{ +} + +bool AppRunningRecord::IsLauncherApp() const +{ + return false; +} + +int32_t AppRunningRecord::GetRecordId() const +{ + AAFwk::MyStatus::GetInstance().getRecordIdCalled_ = true; + return 0; +} + +const std::string &AppRunningRecord::GetName() const +{ + AAFwk::MyStatus::GetInstance().getNameCalled_=true; + return mainAppName_; +} + +const std::string &AppRunningRecord::GetSignCode() const +{ + return signCode_; +} + +void AppRunningRecord::SetSignCode(const std::string &signCode) +{ +} + +const std::string &AppRunningRecord::GetJointUserId() const +{ + return jointUserId_; +} + +void AppRunningRecord::SetJointUserId(const std::string &jointUserId) +{ +} + +const std::string &AppRunningRecord::GetProcessName() const +{ + return processName_; +} + +void AppRunningRecord::SetSpecifiedProcessFlag(const std::string &flag) +{ +} + +const std::string &AppRunningRecord::GetSpecifiedProcessFlag() const +{ + return specifiedProcessFlag_; +} +void AppRunningRecord::SetCustomProcessFlag(const std::string &flag) +{ +} + +const std::string &AppRunningRecord::GetCustomProcessFlag() const +{ + return customProcessFlag_; +} + +int32_t AppRunningRecord::GetUid() const +{ + AAFwk::MyStatus::GetInstance().getUidCalled_ = true; + return 0; +} + +void AppRunningRecord::SetUid(const int32_t uid) +{ + mainUid_ = uid; +} + +int32_t AppRunningRecord::GetUserId() const +{ + return mainUid_ / Constants::BASE_USER_RANGE; +} + +ApplicationState AppRunningRecord::GetState() const +{ + AAFwk::MyStatus::GetInstance().getStateCalled_ = true; + return curState_; +} + +void AppRunningRecord::SetState(const ApplicationState state) +{ + AAFwk::MyStatus::GetInstance().setStateCalled_ = true; + curState_ = state; +} + +void AppRunningRecord::SetRestartTimeMillis(const int64_t restartTimeMillis) +{ + restartTimeMillis_ = restartTimeMillis; +} + +const std::list> AppRunningRecord::GetAppInfoList() +{ + return AAFwk::MyStatus::GetInstance().getAppInfoList_; +} + +void AppRunningRecord::SetAppIdentifier(const std::string &appIdentifier) +{ + appIdentifier_ = appIdentifier; +} + +const std::string &AppRunningRecord::GetAppIdentifier() const +{ + return appIdentifier_; +} + +const std::map, std::shared_ptr> AppRunningRecord::GetAbilities() +{ + AAFwk::MyStatus::GetInstance().getAbilitiesCalled_ = true; + std::map, std::shared_ptr> abilitiesMap; + return abilitiesMap; +} + +sptr AppRunningRecord::GetApplicationClient() const +{ + return nullptr; +} + +std::shared_ptr AppRunningRecord::GetAbilityRunningRecord(const int64_t eventId) const +{ + return nullptr; +} + +void AppRunningRecord::RemoveModuleRecord( + const std::shared_ptr &moduleRecord, bool isExtensionDebug) +{ +} + +void AppRunningRecord::LaunchApplication(const Configuration &config) +{ +} + +void AppRunningRecord::UpdateApplicationInfoInstalled(const ApplicationInfo &appInfo, const std::string &moduleName) +{ +} + +void AppRunningRecord::AddAbilityStage() +{ +} + +bool AppRunningRecord::AddAbilityStageBySpecifiedAbility(const std::string &bundleName) +{ + return false; +} + +void AppRunningRecord::AddAbilityStageBySpecifiedProcess(const std::string &bundleName) +{ +} + +void AppRunningRecord::AddAbilityStageDone() +{ +} + +void AppRunningRecord::SetModuleLoaded(const std::string &moduleName) const +{ +} + +void AppRunningRecord::LaunchAbility(const std::shared_ptr &ability) +{ + // Track successful ability launch + AAFwk::MyStatus::GetInstance().startAbility_launchAbility_called_ = true; +} + +void AppRunningRecord::ScheduleTerminate() +{ +} + +void AppRunningRecord::LaunchPendingAbilities() +{ +} + +bool AppRunningRecord::ScheduleForegroundRunning() +{ + AAFwk::MyStatus::GetInstance().scheduleForegroundRunningCalled_ = true; + return false; +} + +void AppRunningRecord::ScheduleBackgroundRunning() +{ +} + +void AppRunningRecord::ScheduleProcessSecurityExit() +{ +} + +void AppRunningRecord::ScheduleClearPageStack() +{ +} + +void AppRunningRecord::ScheduleTrimMemory() +{ +} + +void AppRunningRecord::ScheduleMemoryLevel(int32_t level) +{ +} + +void AppRunningRecord::ScheduleHeapMemory(const int32_t pid, OHOS::AppExecFwk::MallocInfo &mallocInfo) +{ +} + +void AppRunningRecord::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) +{ +} + +void AppRunningRecord::LowMemoryWarning() +{ +} + +void AppRunningRecord::AddModules( + const std::shared_ptr &appInfo, const std::vector &moduleInfos) +{ + AAFwk::MyStatus::GetInstance().addModulesCall_++; +} + +void AppRunningRecord::AddModule(std::shared_ptr appInfo, + std::shared_ptr abilityInfo, sptr token, + const HapModuleInfo &hapModuleInfo, std::shared_ptr want, int32_t abilityRecordId) +{ + // Track if AddModule is called, used for checking module creation success/failure + AAFwk::MyStatus::GetInstance().addModuleCalled_ = true; + AAFwk::MyStatus::GetInstance().addModuleCalledTimes_++; + // Simulate module creation failure scenario + if (AAFwk::MyStatus::GetInstance().simulateAddModuleFails_) { + AAFwk::MyStatus::GetInstance().startAbility_addModuleFailed_called_ = true; + return; + } + if (AAFwk::MyStatus::GetInstance().simulateAddAbilityFails_) { + AAFwk::MyStatus::GetInstance().startAbility_addAbilityFailed_called_ = true; + return; + } +} + +std::shared_ptr AppRunningRecord::GetModuleRecordByModuleName( + const std::string &bundleName, const std::string &moduleName) +{ + // Track if GetModuleRecordByModuleName is called + AAFwk::MyStatus::GetInstance().getModuleRecordByModuleNameCalled_ = true; + + // Return nullptr to simulate module creation failure + if (AAFwk::MyStatus::GetInstance().simulateAddModuleFails_) { + return nullptr; + } + + return AAFwk::MyStatus::GetInstance().getModuleRecord_; +} + +void AppRunningRecord::StateChangedNotifyObserver(const std::shared_ptr &ability, + int32_t state, bool isAbility, bool isFromWindowFocusChanged) +{ +} + +std::shared_ptr AppRunningRecord::GetModuleRunningRecordByToken( + const sptr &token) const +{ + return nullptr; +} + +std::shared_ptr AppRunningRecord::GetModuleRunningRecordByTerminateLists( + const sptr &token) const +{ + return nullptr; +} + +std::shared_ptr AppRunningRecord::GetAbilityRunningRecordByToken( + const sptr &token) const +{ + AAFwk::MyStatus::GetInstance().getAbilityRunningRecordByTokenCalledAppRecord_ = true; + // Track singleton mode scenarios + if (AAFwk::MyStatus::GetInstance().simulateSingletonAbilityExists_) { + AAFwk::MyStatus::GetInstance().startAbility_singletonAbilityExists_called_ = true; + return AAFwk::MyStatus::GetInstance().getAbilityRunningRecordByToken_; + } + + // Track existing ability with preToken scenario + if (AAFwk::MyStatus::GetInstance().simulateAbilityExistsWithPreToken_) { + AAFwk::MyStatus::GetInstance().startAbility_abilityExistsWithPreToken_called_ = true; + return AAFwk::MyStatus::GetInstance().getAbilityRunningRecordByToken_; + } + + // Return nullptr to simulate ability creation failure + if (AAFwk::MyStatus::GetInstance().simulateAddAbilityFails_) { + return nullptr; + } + AAFwk::MyStatus::GetInstance().startAbility_nullAbilityInfo_called_ = false; + AAFwk::MyStatus::GetInstance().startAbility_nullAppRecord_called_ = false; + return AAFwk::MyStatus::GetInstance().getAbilityRunningRecordByToken_; +} + +std::shared_ptr AppRunningRecord::GetAbilityByTerminateLists( + const sptr &token) const +{ + return nullptr; +} + +bool AppRunningRecord::UpdateAbilityFocusState(const sptr &token, bool isFocus) +{ + return false; +} + +void AppRunningRecord::UpdateAbilityState(const sptr &token, const AbilityState state) +{ +} + +void AppRunningRecord::AbilityForeground(const std::shared_ptr &ability) +{ +} + +void AppRunningRecord::AbilityBackground(const std::shared_ptr &ability) +{ +} + +bool AppRunningRecord::AbilityFocused(const std::shared_ptr &ability) +{ + return false; +} + +bool AppRunningRecord::AbilityUnfocused(const std::shared_ptr &ability) +{ + return false; +} + +void AppRunningRecord::PopForegroundingAbilityTokens() +{ +} + +void AppRunningRecord::TerminateAbility(const sptr &token, const bool isForce, bool isTimeout) +{ +} + +void AppRunningRecord::AbilityTerminated(const sptr &token) +{ +} + +std::list> AppRunningRecord::GetAllModuleRecord() const +{ + std::list> moduleRecordList; + return moduleRecordList; +} + +void AppRunningRecord::RemoveAppDeathRecipient() const +{ +} + +void AppRunningRecord::SetAppMgrServiceInner(const std::weak_ptr &inner) +{ +} + +void AppRunningRecord::SetAppDeathRecipient(const sptr &appDeathRecipient) +{ + AAFwk::MyStatus::GetInstance().appRunningRecordSetAppDeathRecipientCalled_ = true; + appDeathRecipient_ = appDeathRecipient; +} + +std::shared_ptr AppRunningRecord::GetPriorityObject() +{ + AAFwk::MyStatus::GetInstance().getPriorityObjectCalled_ = true; + return priorityObject_; +} + +void AppRunningRecord::SendEventForSpecifiedAbility() +{ +} + +void AppRunningRecord::SendAppStartupTypeEvent(const std::shared_ptr &ability, + const AppStartType startType) +{ +} + +void AppRunningRecord::SendEvent(uint32_t msg, int64_t timeOut) +{ +} + +void AppRunningRecord::RemoveEvent(uint32_t msg) +{ +} + +void AppRunningRecord::PostTask(std::string msg, int64_t timeOut, const Closure &task) +{ +} + +void AppRunningRecord::SetTaskHandler(std::shared_ptr taskHandler) +{ + taskHandler_ = taskHandler; +} + +void AppRunningRecord::SetEventHandler(const std::shared_ptr &handler) +{ + eventHandler_ = handler; +} + +bool AppRunningRecord::IsLastAbilityRecord(const sptr &token) +{ + return false; +} + +bool AppRunningRecord::ExtensionAbilityRecordExists() +{ + return false; +} + +bool AppRunningRecord::IsLastPageAbilityRecord(const sptr &token) +{ + return false; +} + +void AppRunningRecord::SetTerminating() +{ +} + +bool AppRunningRecord::IsTerminating() +{ + return false; +} + +bool AppRunningRecord::IsKeepAliveApp() const +{ + AAFwk::MyStatus::GetInstance().isKeepAliveAppCalled_ = true; + return AAFwk::MyStatus::GetInstance().isKeepAliveApp_; +} + +bool AppRunningRecord::IsKeepAliveDkv() const +{ + return isKeepAliveDkv_; +} + +void AppRunningRecord::SetKeepAliveEnableState(bool isKeepAliveEnable) +{ + AAFwk::MyStatus::GetInstance().setKeepAliveEnableStateCalled_ = true; + isKeepAliveRdb_ = isKeepAliveEnable; +} + +void AppRunningRecord::SetKeepAliveDkv(bool isKeepAliveDkv) +{ + AAFwk::MyStatus::GetInstance().setKeepAliveDkvCalled_ = true; + isKeepAliveDkv_ = isKeepAliveDkv; +} + +void AppRunningRecord::SetKeepAliveBundle(bool isKeepAliveBundle) +{ + isKeepAliveBundle_ = isKeepAliveBundle; +} + +bool AppRunningRecord::IsEmptyKeepAliveApp() const +{ + return isEmptyKeepAliveApp_; +} + +void AppRunningRecord::SetEmptyKeepAliveAppState(bool isEmptyKeepAliveApp) +{ + isEmptyKeepAliveApp_ = isEmptyKeepAliveApp; +} + +bool AppRunningRecord::IsMainProcess() const +{ + return isMainProcess_; +} + +void AppRunningRecord::SetMainProcess(bool isMainProcess) +{ + isMainProcess_ = isMainProcess; +} + +void AppRunningRecord::SetSingleton(bool isSingleton) +{ + isSingleton_ = isSingleton; +} + +void AppRunningRecord::SetStageModelState(bool isStageBasedModel) +{ + isStageBasedModel_ = isStageBasedModel; +} + +bool AppRunningRecord::GetTheModuleInfoNeedToUpdated(const std::string bundleName, HapModuleInfo &info) +{ + return false; +} + +void AppRunningRecord::SetRestartResidentProcCount(int count) +{ + restartResidentProcCount_ = count; +} + +void AppRunningRecord::DecRestartResidentProcCount() +{ + restartResidentProcCount_--; +} + +int AppRunningRecord::GetRestartResidentProcCount() const +{ + return restartResidentProcCount_; +} + +bool AppRunningRecord::CanRestartResidentProc() +{ + return false; +} + +void AppRunningRecord::GetBundleNames(std::vector &bundleNames) +{ + AAFwk::MyStatus::GetInstance().getBundleNamesCalled_ = true; +} + +void AppRunningRecord::SetUserTestInfo(const std::shared_ptr &record) +{ + userTestRecord_ = record; +} + +std::shared_ptr AppRunningRecord::GetUserTestInfo() +{ + return userTestRecord_; +} + +void AppRunningRecord::SetProcessAndExtensionType( + const std::shared_ptr &abilityInfo, uint32_t extensionProcessMode) +{ +} + +void AppRunningRecord::SetStartupTaskData(const AAFwk::Want &want) +{} + +void AppRunningRecord::SetSpecifiedAbilityFlagAndWant( + int requestId, const AAFwk::Want &want, const std::string &moduleName) +{ +} + +int32_t AppRunningRecord::GetSpecifiedRequestId() const +{ + AAFwk::MyStatus::GetInstance().getSpecifiedRequestIdCall_++; + return -1; +} + +void AppRunningRecord::ResetSpecifiedRequest() +{ + AAFwk::MyStatus::GetInstance().resetSpecifiedRequestCall_++; +} + +void AppRunningRecord::SetScheduleNewProcessRequestState(int32_t requestId, + const AAFwk::Want &want, const std::string &moduleName) +{ +} + +bool AppRunningRecord::IsNewProcessRequest() const +{ + return AAFwk::MyStatus::GetInstance().isNewProcessRequest_; +} + +bool AppRunningRecord::IsStartSpecifiedAbility() const +{ + return AAFwk::MyStatus::GetInstance().isStartSpecifiedAbility_; +} + +void AppRunningRecord::SchedulePrepareTerminate(const std::string &moduleName) +{ + AAFwk::MyStatus::GetInstance().schedulePrepareCall_++; +} + +void AppRunningRecord::ScheduleAcceptWant(const std::string &moduleName) +{ + AAFwk::MyStatus::GetInstance().scheduleAcceptCall_++; +} + +void AppRunningRecord::ScheduleAcceptWantDone() +{ +} + +void AppRunningRecord::ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) +{ +} + +void AppRunningRecord::ScheduleNewProcessRequestDone() +{ +} + +void AppRunningRecord::ApplicationTerminated() +{ +} + +AAFwk::Want AppRunningRecord::GetSpecifiedWant() const +{ + return AAFwk::Want(); +} + +AAFwk::Want AppRunningRecord::GetNewProcessRequestWant() const +{ + return AAFwk::Want(); +} + +int32_t AppRunningRecord::GetNewProcessRequestId() const +{ + AAFwk::MyStatus::GetInstance().getNewProcessRequestIdCall_++; + return AAFwk::MyStatus::GetInstance().getNewProcessRequestId_; +} + +void AppRunningRecord::ResetNewProcessRequest() +{ + AAFwk::MyStatus::GetInstance().resetNewProcessRequestCall_++; +} + +int32_t AppRunningRecord::UpdateConfiguration(const Configuration &config) +{ + return 0; +} + +void AppRunningRecord::AddRenderRecord(const std::shared_ptr &record) +{ +} + +void AppRunningRecord::RemoveRenderRecord(const std::shared_ptr &record) +{ +} + +void AppRunningRecord::RemoveRenderPid(pid_t renderPid) +{ +} + +void AppRunningRecord::GetRenderProcessInfos(std::list &processInfos) +{ +} + +bool AppRunningRecord::ConstainsRenderPid(pid_t renderPid) +{ + return false; +} + +std::shared_ptr AppRunningRecord::GetRenderRecordByPid(const pid_t pid) +{ + return AAFwk::MyStatus::GetInstance().getRenderRecordByPid_; +} + +std::map> AppRunningRecord::GetRenderRecordMap() +{ + return renderRecordMap_; +} + +void AppRunningRecord::SetStartMsg(const AppSpawnStartMsg &msg) +{ + startMsg_ = msg; +} + +AppSpawnStartMsg AppRunningRecord::GetStartMsg() +{ + return startMsg_; +} + +bool AppRunningRecord::IsDebug() +{ + return false; +} + +void AppRunningRecord::SetDebugApp(bool isDebugApp) +{ + isDebugApp_ = isDebugApp; +} + +bool AppRunningRecord::IsDebugApp() +{ + AAFwk::MyStatus::GetInstance().debugAppCalledTimes_++; + return isDebugApp_; +} + +void AppRunningRecord::SetNativeDebug(bool isNativeDebug) +{ +} + +void AppRunningRecord::SetPerfCmd(const std::string &perfCmd) +{ + perfCmd_ = perfCmd; +} + +void AppRunningRecord::SetErrorInfoEnhance(bool errorInfoEnhance) +{ + isErrorInfoEnhance_ = errorInfoEnhance; +} + +void AppRunningRecord::SetMultiThread(bool multiThread) +{ + isMultiThread_ = multiThread; +} + +void AppRunningRecord::SetAppIndex(const int32_t appIndex) +{ + appIndex_ = appIndex; +} + +void AppRunningRecord::SetInstanceKey(const std::string& instanceKey) +{ + instanceKey_ = instanceKey; +} + +void AppRunningRecord::GetSplitModeAndFloatingMode(bool &isSplitScreenMode, bool &isFloatingWindowMode) +{ +} + +int32_t AppRunningRecord::GetAppIndex() const +{ + AAFwk::MyStatus::GetInstance().getAppIndex_++; + return appIndex_; +} + +std::string AppRunningRecord::GetInstanceKey() const +{ + return instanceKey_; +} + +void AppRunningRecord::SetSecurityFlag(bool securityFlag) +{ + securityFlag_ = securityFlag; +} + +bool AppRunningRecord::GetSecurityFlag() const +{ + return securityFlag_; +} + +void AppRunningRecord::SetKilling() +{ + isKilling_.store(true); +} + +bool AppRunningRecord::IsKilling() const +{ + return isKilling_.load(); +} + +bool AppRunningRecord::NeedUpdateConfigurationBackground() +{ + return false; +} + +void AppRunningRecord::RemoveTerminateAbilityTimeoutTask(const sptr& token) const +{ +} + +int32_t AppRunningRecord::NotifyLoadRepairPatch(const std::string &bundleName, const sptr &callback, + const int32_t recordId) +{ + return 0; +} + +int32_t AppRunningRecord::NotifyHotReloadPage(const sptr &callback, const int32_t recordId) +{ + return 0; +} + +int32_t AppRunningRecord::NotifyUnLoadRepairPatch(const std::string &bundleName, + const sptr &callback, const int32_t recordId) +{ + return 0; +} + +int32_t AppRunningRecord::NotifyAppFault(const FaultData &faultData) +{ + return 0; +} + +bool AppRunningRecord::IsAbilitiesBackground() +{ + return false; +} +#ifdef SUPPORT_SCREEN + +void AppRunningRecord::ChangeWindowVisibility(const sptr &info) +{ +} + +void AppRunningRecord::OnWindowVisibilityChanged( + const std::vector> &windowVisibilityInfos) +{ +} + +void AppRunningRecord::OnWindowVisibilityChangedWithPendingState() +{ +} +#endif //SUPPORT_SCREEN + +bool AppRunningRecord::IsWindowIdsEmpty() +{ + return false; +} + +bool AppRunningRecord::IsContinuousTask() +{ + return isContinuousTask_; +} + +void AppRunningRecord::SetContinuousTaskAppState(bool isContinuousTask) +{ + isContinuousTask_ = isContinuousTask; +} + +bool AppRunningRecord::GetFocusFlag() const +{ + return isFocused_; +} + +int64_t AppRunningRecord::GetAppStartTime() const +{ + return startTimeMillis_; +} + +void AppRunningRecord::SetRequestProcCode(int32_t requestProcCode) +{ + requestProcCode_ = requestProcCode; +} + +int32_t AppRunningRecord::GetRequestProcCode() const +{ + return requestProcCode_; +} + +void AppRunningRecord::SetProcessChangeReason(ProcessChangeReason reason) +{ + processChangeReason_ = reason; +} + +ProcessChangeReason AppRunningRecord::GetProcessChangeReason() const +{ + return processChangeReason_; +} + +ExtensionAbilityType AppRunningRecord::GetExtensionType() const +{ + return extensionType_; +} + +ProcessType AppRunningRecord::GetProcessType() const +{ + return processType_; +} + +std::map> AppRunningRecord::GetChildAppRecordMap() const +{ + return childAppRecordMap_; +} + +void AppRunningRecord::AddChildAppRecord(pid_t pid, std::shared_ptr appRecord) +{ + childAppRecordMap_[pid] = appRecord; +} + +void AppRunningRecord::RemoveChildAppRecord(pid_t pid) +{ + childAppRecordMap_.erase(pid); +} + +void AppRunningRecord::ClearChildAppRecordMap() +{ + childAppRecordMap_.clear(); +} + +void AppRunningRecord::SetParentAppRecord(std::shared_ptr appRecord) +{ + parentAppRecord_ = appRecord; +} + +std::shared_ptr AppRunningRecord::GetParentAppRecord() +{ + AAFwk::MyStatus::GetInstance().getParentAppRecordCall_++; + return parentAppRecord_.lock(); +} + +int32_t AppRunningRecord::ChangeAppGcState(int32_t state, uint64_t tid) +{ + return AAFwk::MyStatus::GetInstance().changeAppGcState_; +} + +void AppRunningRecord::SetAttachDebug(bool isAttachDebug, bool isDebugFromLocal) +{ +} + +bool AppRunningRecord::IsAttachDebug() const +{ + return isAttachDebug_; +} + +void AppRunningRecord::SetApplicationPendingState(ApplicationPendingState pendingState) +{ + pendingState_ = pendingState; +} + +ApplicationPendingState AppRunningRecord::GetApplicationPendingState() const +{ + return pendingState_; +} + +void AppRunningRecord::SetApplicationScheduleState(ApplicationScheduleState scheduleState) +{ + AAFwk::MyStatus::GetInstance().setApplicationScheduleStateCalled_ = true; + scheduleState_ = scheduleState; +} + +ApplicationScheduleState AppRunningRecord::GetApplicationScheduleState() const +{ + return scheduleState_; +} + +#ifdef SUPPORT_CHILD_PROCESS +void AppRunningRecord::AddChildProcessRecord(pid_t pid, std::shared_ptr record) +{ +} + +void AppRunningRecord::RemoveChildProcessRecord(std::shared_ptr record) +{ + AAFwk::MyStatus::GetInstance().removeChildProcessRecordCall_++; +} + +std::shared_ptr AppRunningRecord::GetChildProcessRecordByPid(pid_t pid) +{ + AAFwk::MyStatus::GetInstance().getChildProcessRecordByPidCall_++; + return AAFwk::MyStatus::GetInstance().getChildProcessRecordByPid_; +} + +std::map> AppRunningRecord::GetChildProcessRecordMap() +{ + std::lock_guard lock(childProcessRecordMapLock_); + return childProcessRecordMap_; +} + +int32_t AppRunningRecord::GetChildProcessCount() +{ + std::lock_guard lock(childProcessRecordMapLock_); + return 0; +} + +void AppRunningRecord::GetChildProcessInfos(std::list &processInfos) +{ +} +#endif //SUPPORT_CHILD_PROCESS + +void AppRunningRecord::SetJITEnabled(const bool jitEnabled) +{ + jitEnabled_ = jitEnabled; +} + +bool AppRunningRecord::IsJITEnabled() const +{ + return jitEnabled_; +} + +void AppRunningRecord::SetPreloadMode(PreloadMode mode) +{ + preloadMode_ = mode; +} + +PreloadMode AppRunningRecord::GetPreloadMode() +{ + return preloadMode_; +} + +void AppRunningRecord::SetPreloadModuleName(const std::string& preloadModuleName) +{ + preloadModuleName_ = preloadModuleName; +} + +std::string AppRunningRecord::GetPreloadModuleName() const +{ + return preloadModuleName_; +} + +void AppRunningRecord::SetPreloadState(PreloadState state) +{ + preloadState_ = state; +} + +bool AppRunningRecord::IsPreloading() const +{ + return preloadState_ == PreloadState::PRELOADING; +} + +bool AppRunningRecord::IsPreloaded() const +{ + return preloadState_ == PreloadState::PRELOADED; +} + +int32_t AppRunningRecord::GetAssignTokenId() const +{ + return assignTokenId_; +} + +void AppRunningRecord::SetAssignTokenId(int32_t assignTokenId) +{ + assignTokenId_ = assignTokenId; +} + +void AppRunningRecord::SetRestartAppFlag(bool isRestartApp) +{ + isRestartApp_ = isRestartApp; +} + +bool AppRunningRecord::GetRestartAppFlag() const +{ + return isRestartApp_; +} + +void AppRunningRecord::SetAssertionPauseFlag(bool flag) +{ + AAFwk::MyStatus::GetInstance().setAssertionPauseFlagCalled_ = true; + isAssertPause_ = flag; +} + +bool AppRunningRecord::IsAssertionPause() const +{ + return isAssertPause_; +} + +bool AppRunningRecord::IsDebugging() const +{ + return isDebugApp_ || isAssertPause_; +} + +void AppRunningRecord::SetNativeStart(bool isNativeStart) +{ + isNativeStart_ = isNativeStart; +} + +bool AppRunningRecord::isNativeStart() const +{ + return isNativeStart_; +} + +void AppRunningRecord::SetExitReason(int32_t reason) +{ + exitReason_ = reason; +} + +int32_t AppRunningRecord::GetExitReason() const +{ + return exitReason_; +} + +void AppRunningRecord::SetExitMsg(const std::string &exitMsg) +{ + exitMsg_ = exitMsg; +} + +std::string AppRunningRecord::GetExitMsg() const +{ + return exitMsg_; +} + +int AppRunningRecord::DumpIpcStart(std::string& result) +{ + return 0; +} + +int AppRunningRecord::DumpIpcStop(std::string& result) +{ + return 0; +} + +int AppRunningRecord::DumpIpcStat(std::string& result) +{ + return 0; +} + +int AppRunningRecord::DumpFfrt(std::string& result) +{ + return 0; +} + +void AppRunningRecord::SetWatchdogBackgroundStatusRunning(bool status) +{ +} + +bool AppRunningRecord::SetSupportedProcessCache(bool isSupport) +{ + return false; +} + +bool AppRunningRecord::SetEnableProcessCache(bool enable) +{ + return false; +} + +bool AppRunningRecord::GetEnableProcessCache() +{ + return enableProcessCache_; +} + +SupportProcessCacheState AppRunningRecord::GetSupportProcessCacheState() +{ + return procCacheSupportState_; +} + +void AppRunningRecord::ScheduleCacheProcess() +{ +} + +bool AppRunningRecord::CancelTask(std::string msg) +{ + return false; +} + +void AppRunningRecord::SetBrowserHost(sptr browser) +{ + AAFwk::MyStatus::GetInstance().setBrowserHostCall_++; + browserHost_ = browser; +} + +sptr AppRunningRecord::GetBrowserHost() +{ + AAFwk::MyStatus::GetInstance().getBrowserHostCall_++; + return browserHost_; +} + +void AppRunningRecord::SetHasGPU(bool gpu) +{ +} + +bool AppRunningRecord::HasGPU() +{ + return hasGPU_; +} + +void AppRunningRecord::SetGPUPid(pid_t gpuPid) +{ + gpuPid_ = gpuPid; +} + +pid_t AppRunningRecord::GetGPUPid() +{ + return gpuPid_; +} + +pid_t AppRunningRecord::GetPid() +{ + AAFwk::MyStatus::GetInstance().getPidCall_ = true; + return 0; +} + +void AppRunningRecord::SetAttachedToStatusBar(bool isAttached) +{ + isAttachedToStatusBar = isAttached; +} + +bool AppRunningRecord::IsAttachedToStatusBar() +{ + return isAttachedToStatusBar; +} + +void AppRunningRecord::SetProcessCacheBlocked(bool isBlocked) +{ + processCacheBlocked = isBlocked; +} + +bool AppRunningRecord::GetProcessCacheBlocked() +{ + return processCacheBlocked; +} + +bool AppRunningRecord::IsAllAbilityReadyToCleanedByUserRequest() +{ + AAFwk::MyStatus::GetInstance().isAllAbilityReadyToCleanedByUserRequestCalled_ = true; + return AAFwk::MyStatus::GetInstance().isAllAbilityReadyToCleanedByUserRequest_; +} + +void AppRunningRecord::SetUserRequestCleaning() +{ + AAFwk::MyStatus::GetInstance().setUserRequestCleaningCalled_ = true; + isUserRequestCleaning_ = true; +} + +bool AppRunningRecord::IsUserRequestCleaning() const +{ + return isUserRequestCleaning_; +} + +bool AppRunningRecord::IsProcessAttached() const +{ + return false; +} + +void AppRunningRecord::SetUIAbilityLaunched(bool hasLaunched) +{ + hasUIAbilityLaunched_ = hasLaunched; +} + +bool AppRunningRecord::HasUIAbilityLaunched() +{ + return hasUIAbilityLaunched_; +} + +void AppRunningRecord::SetProcessCaching(bool isCaching) +{ + isCaching_ = isCaching; +} + +bool AppRunningRecord::IsCaching() +{ + return isCaching_; +} + +void AppRunningRecord::AddAppLifecycleEvent(const std::string &msg) +{ + AAFwk::MyStatus::GetInstance().addAppLifecycleEventCalled_= true; +} + +void AppRunningRecord::SetNeedPreloadModule(bool isNeedPreloadModule) +{ + isNeedPreloadModule_ = isNeedPreloadModule; +} + +bool AppRunningRecord::GetNeedPreloadModule() +{ + return isNeedPreloadModule_; +} + +void AppRunningRecord::SetNWebPreload(const bool isAllowedNWebPreload) +{ + AAFwk::MyStatus::GetInstance().setNWebPreloadCalled_ = true; + isAllowedNWebPreload_ = isAllowedNWebPreload; +} + +bool AppRunningRecord::IsNWebPreload() const +{ + return isAllowedNWebPreload_; +} + +void AppRunningRecord::SetIsUnSetPermission(bool isUnSetPermission) +{ + isUnSetPermission_ = isUnSetPermission; +} + +bool AppRunningRecord::IsUnSetPermission() +{ + return isUnSetPermission_; +} + +bool AppRunningRecord::GetNeedLimitPrio() +{ + return isNeedLimitPrio_; +} + +void AppRunningRecord::SetNeedLimitPrio(bool isNeedLimitPrio) +{ + isNeedLimitPrio_ = isNeedLimitPrio; +} + +void AppRunningRecord::UnSetPolicy() +{ +} + +int32_t AppRunningRecord::GetAddStageTimeout() const +{ + return 0; +} + +void AppRunningRecord::SetDebugFromLocal(bool isDebugFromLocal) +{ + isDebugFromLocal_ = isDebugFromLocal; +} + +std::optional AppRunningRecord::IsSupportMultiProcessDeviceFeature() const +{ + return supportMultiProcessDeviceFeature_; +} + +void AppRunningRecord::SetSupportMultiProcessDeviceFeature(bool support) +{ + supportMultiProcessDeviceFeature_ = support; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_exit_resident_process_manager.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_exit_resident_process_manager.cpp index 3e520ae3122..bda9a490c15 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_exit_resident_process_manager.cpp +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_exit_resident_process_manager.cpp @@ -88,6 +88,7 @@ int32_t ExitResidentProcessManager::HandleNoRequireBigMemoryOptimization ( void ExitResidentProcessManager::QueryExitBundleInfos(const std::vector &exitProcessInfos, std::vector& exitBundleInfos) { + AAFwk::MyStatus::GetInstance().queryExitBundleInfos_called_ = true; } bool ExitResidentProcessManager::IsKilledForUpgradeWeb(const std::string &bundleName) const diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_ipc_skeleton.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_ipc_skeleton.cpp index 9565882cb8b..7da8633890a 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_ipc_skeleton.cpp +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_ipc_skeleton.cpp @@ -23,11 +23,13 @@ using namespace IPC_SINGLE; pid_t IPCSkeleton::GetCallingUid() { + AAFwk::MyStatus::GetInstance().getCallingUidCalledTimes_++; return AAFwk::MyStatus::GetInstance().getCallingUid_; } pid_t IPCSkeleton::GetCallingPid() { + AAFwk::MyStatus::GetInstance().getCallingPid_++; return 0; } diff --git a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_parameters.cpp b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_parameters.cpp index 813ea647484..6da52031ce0 100644 --- a/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_parameters.cpp +++ b/test/unittest/app_mgr_service_inner_ninth_test/mock/src/mock_parameters.cpp @@ -18,9 +18,13 @@ namespace OHOS { namespace system { +constexpr const char* PRODUCT_ASSERT_FAULT_DIALOG_ENABLED = "persisit.sys.abilityms.support_assert_fault_dialog"; bool GetBoolParameter(const std::string& key, bool def) { + if (key == PRODUCT_ASSERT_FAULT_DIALOG_ENABLED) { + return OHOS::AAFwk::MyStatus::GetInstance().getDialogEnabled_; + } return OHOS::AAFwk::MyStatus::GetInstance().getBoolParameter_; } } // namespace system -- Gitee