diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 0c925708f310303cc037db66aba457ad69238d54..3283291a340eb64a229bff82203eb2ec1cd7d624 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -252,6 +252,7 @@ group("unittest") { "app_mgr_service_inner_test:unittest", "app_mgr_service_second_test:unittest", "app_mgr_service_test:unittest", + "app_mgr_service_fourth_test:unittest", "app_mgr_service_third_test:unittest", "app_mgr_stub_test:unittest", "app_native_spawn_manager_test:unittest", diff --git a/test/unittest/app_mgr_service_fourth_test/BUILD.gn b/test/unittest/app_mgr_service_fourth_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..699b6d523201a35de7eeb4f8bb81a4ed1b1ed29c --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/BUILD.gn @@ -0,0 +1,115 @@ +# 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. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/ability_runtime/appmgr" + +ohos_unittest("app_mgr_service_fourth_test") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } + branch_protector_ret = "pac_ret" + module_out_path = module_output_path + + include_dirs = [ + "mock/include", + "${ability_runtime_test_path}/mock/services_appmgr_test/include", + "${ability_runtime_test_path}/mock/task_handler_wrap_mock/include", + "${ability_runtime_test_path}/mock/mock_appmgr_service/include", + "${ability_runtime_test_path}/mock/common/include", + "${ability_runtime_test_path}/mock/mock_sa_call", + ] + + sources = [ + "app_mgr_service_fourth_test.cpp", + "mock/src/mock_ipc_skeleton.cpp", + "mock/src/mock_my_status.cpp", + "mock/src/mock_permission_verification.cpp", + "mock/src/mock_app_running_record.cpp", + "mock/src/mock_remote_client_manager.cpp", + "mock/src/mock_bundle_mgr_helper.cpp", + "mock/src/mock_accesstoken_kit.cpp", + ] + + configs = [ "${ability_runtime_services_path}/appmgr:appmgr_config" ] + + cflags = [ + "-Dprivate=public", + "-Dprotected=public", + ] + + deps = [ + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_native_path}/appkit:appkit_native", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:task_handler_wrap", + ] + + external_deps = [ + "ability_base:configuration", + "ability_base:want", + "ability_runtime:app_manager", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "cJSON:cjson", + "c_utils:utils", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbeget_proxy", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "selinux_adapter:librestorecon", + ] + + defines = [] + if (background_task_mgr_continuous_task_enable) { + defines += [ "BGTASKMGR_CONTINUOUS_TASK_ENABLE" ] + } + + if (ability_command_for_test) { + defines += [ "ABILITY_COMMAND_FOR_TEST" ] + } + + if (ability_runtime_child_process) { + defines += [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +group("unittest") { + testonly = true + + deps = [ ":app_mgr_service_fourth_test" ] +} diff --git a/test/unittest/app_mgr_service_fourth_test/app_mgr_service_fourth_test.cpp b/test/unittest/app_mgr_service_fourth_test/app_mgr_service_fourth_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d824ceefc7eaafd07d925905b1c4314d5d5b3e9a --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/app_mgr_service_fourth_test.cpp @@ -0,0 +1,300 @@ +/* + * 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 + +#define private public +#include "accesstoken_kit.h" +#include "ability_manager_errors.h" +#include "app_mgr_service.h" +#include "app_running_record.h" +#include "mock_ability_token.h" +#include "mock_app_mgr_service_inner.h" +#include "mock_ipc_skeleton.h" +#include "mock_my_status.h" +#include "mock_permission_verification.h" +#include "task_handler_wrap.h" +#undef private +#include "hilog_tag_wrapper.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AAFwk; + +namespace OHOS { +namespace AppExecFwk { +namespace { +const std::string BUNDLE_NAME = "com.example.test"; +constexpr int UID = 1000; +constexpr pid_t PID = 1000; +} + +class MockTaskHandlerWrap : public TaskHandlerWrap { +public: + static std::shared_ptr CreateQueueHandler(const std::string &queueName, + TaskQoS queueQos = TaskQoS::DEFAULT) + { + return std::make_shared(); + } + static std::shared_ptr GetFfrtHandler() + { + return std::make_shared(); + } + MockTaskHandlerWrap() : TaskHandlerWrap("MockTaskHandlerWrap") {} + virtual ~MockTaskHandlerWrap() {} + + MOCK_METHOD2(SubmitTaskInner, + std::shared_ptr(std::function &&task, const TaskAttribute &)); + bool CancelTaskInner(const std::shared_ptr &taskHandle) override + { + return true; + } + void WaitTaskInner(const std::shared_ptr &taskHandle) override {} + bool RemoveTask(const std::string &name, const TaskHandle &taskHandle) + { + return true; + } + std::shared_ptr MockTaskHandler(const std::function &&, const TaskAttribute &); +}; + +class AppMgrServiceFourthTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + static std::shared_ptr IgnoreTask(std::function task, const TaskAttribute& attr); + static std::shared_ptr appMgrService_; + static std::shared_ptr mockAppMgrServiceInner_; + static std::shared_ptr eventHandler_; + static std::shared_ptr mockTaskHandler_; + static std::shared_ptr appRunningManager_; +}; + +std::shared_ptr AppMgrServiceFourthTest::appMgrService_ = nullptr; +std::shared_ptr AppMgrServiceFourthTest::mockAppMgrServiceInner_ = nullptr; +std::shared_ptr AppMgrServiceFourthTest::eventHandler_ = nullptr; +std::shared_ptr AppMgrServiceFourthTest::mockTaskHandler_ = nullptr; +std::shared_ptr AppMgrServiceFourthTest::appRunningManager_ = nullptr; + +void AppMgrServiceFourthTest::SetUpTestCase(void) +{ + appMgrService_ = std::make_shared(); + mockAppMgrServiceInner_ = std::make_shared(); + appMgrService_->appMgrServiceInner_ = mockAppMgrServiceInner_; + mockTaskHandler_ = MockTaskHandlerWrap::CreateQueueHandler(Constants::APP_MGR_SERVICE_NAME); + appMgrService_->taskHandler_ = mockTaskHandler_; + eventHandler_= std::make_shared(appMgrService_->taskHandler_, + appMgrService_->appMgrServiceInner_); + appMgrService_->eventHandler_ = eventHandler_; + appRunningManager_ = std::make_shared(); + appMgrService_->appMgrServiceInner_->appRunningManager_ = appRunningManager_; + auto appRecord = std::make_shared(nullptr, 0, ""); + appRecord->appInfo_ = std::make_shared(); + appRecord->appInfo_->accessTokenId = IPCSkeleton::GetCallingTokenID(); + appMgrService_->appMgrServiceInner_->appRunningManager_->appRunningRecordMap_.emplace(0, appRecord); +} + +void AppMgrServiceFourthTest::TearDownTestCase(void) {} + +void AppMgrServiceFourthTest::SetUp() +{ + appMgrService_->appMgrServiceInner_ = mockAppMgrServiceInner_; + appMgrService_->taskHandler_ = mockTaskHandler_; + appMgrService_->eventHandler_ = eventHandler_; + appMgrService_->appMgrServiceInner_->appRunningManager_ = appRunningManager_; +} + +void AppMgrServiceFourthTest::TearDown() {} + +std::shared_ptr AppMgrServiceFourthTest::IgnoreTask(std::function task, + const TaskAttribute& attr) +{ + TAG_LOGI(AAFwkTag::TEST, "SubmitTaskInner called but task not executed"); + return nullptr; +} + +/** + * @tc.name: ApplicationForegrounded_0100 + * @tc.desc: ApplicationForegrounded. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, ApplicationForegrounded_0100, TestSize.Level1) +{ + // return after JudgeAppSelfCalled failed + TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_0100 start"); + appMgrService_->eventHandler_ = nullptr; + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(0).WillOnce(Invoke(IgnoreTask)); + appMgrService_->ApplicationForegrounded(0); + appMgrService_->eventHandler_ = eventHandler_; + TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_0100 end"); +} + +/** + * @tc.name: ApplicationForegrounded_0200 + * @tc.desc: ApplicationForegrounded. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, ApplicationForegrounded_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_0200 start"); + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(1).WillOnce(Invoke(IgnoreTask)); + appMgrService_->ApplicationForegrounded(0); + TAG_LOGI(AAFwkTag::TEST, "ApplicationForegrounded_0200 end"); +} + +/** + * @tc.name: ApplicationBackgrounded_0100 + * @tc.desc: ApplicationBackgrounded. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, ApplicationBackgrounded_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ApplicationBackgrounded_0100 start"); + // return after JudgeAppSelfCalled failed + appMgrService_->eventHandler_ = nullptr; + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(0).WillOnce(Invoke(IgnoreTask)); + appMgrService_->ApplicationBackgrounded(0); + appMgrService_->eventHandler_ = eventHandler_; + TAG_LOGI(AAFwkTag::TEST, "ApplicationBackgrounded_0100 end"); +} + +/** + * @tc.name: ApplicationBackgrounded_0200 + * @tc.desc: ApplicationBackgrounded. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, ApplicationBackgrounded_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ApplicationBackgrounded_0200 start"); + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(1).WillOnce(Invoke(IgnoreTask)); + appMgrService_->ApplicationBackgrounded(0); + TAG_LOGI(AAFwkTag::TEST, "ApplicationBackgrounded_0200 end"); +} + +/** + * @tc.name: ApplicationTerminated_0100 + * @tc.desc: ApplicationTerminated. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, ApplicationTerminated_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ApplicationTerminated_0100 start"); + // return after JudgeAppSelfCalled failed + appMgrService_->eventHandler_ = nullptr; + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(0).WillOnce(Invoke(IgnoreTask)); + appMgrService_->ApplicationTerminated(0); + appMgrService_->eventHandler_ = eventHandler_; + TAG_LOGI(AAFwkTag::TEST, "ApplicationTerminated_0100 end"); +} + +/** + * @tc.name: ApplicationTerminated_0200 + * @tc.desc: ApplicationTerminated. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, ApplicationTerminated_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ApplicationTerminated_0200 start"); + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(1).WillOnce(Invoke(IgnoreTask)); + appMgrService_->ApplicationTerminated(0); + TAG_LOGI(AAFwkTag::TEST, "ApplicationTerminated_0200 end"); +} + +/** + * @tc.name: StartupResidentProcess_0100 + * @tc.desc: StartupResidentProcess. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, StartupResidentProcess_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "StartupResidentProcess_0100 start"); + IPCSkeleton::SetCallingPid(getprocpid()); + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(1).WillOnce(Invoke(IgnoreTask)); + std::vector bundleInfos; + appMgrService_->StartupResidentProcess(bundleInfos); + TAG_LOGI(AAFwkTag::TEST, "StartupResidentProcess_0100 end"); +} + +/** + * @tc.name: GetAmsMgr_0100 + * @tc.desc: GetAmsMgr. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, GetAmsMgr_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "GetAmsMgr_0100 start"); + auto amsMgr = appMgrService_->GetAmsMgr(); + EXPECT_EQ(amsMgr, appMgrService_->amsMgrScheduler_); + TAG_LOGI(AAFwkTag::TEST, "GetAmsMgr_0100 end"); +} + +/** + * @tc.name: NotifyProcMemoryLevel_0100 + * @tc.desc: NotifyProcMemoryLevel. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, NotifyProcMemoryLevel_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "NotifyProcMemoryLevel_0100 start"); + appMgrService_->eventHandler_ = nullptr; + std::map procLevelMap; + auto result = appMgrService_->NotifyProcMemoryLevel(procLevelMap); + EXPECT_EQ(result, ERR_INVALID_OPERATION); + appMgrService_->eventHandler_ = eventHandler_; + TAG_LOGI(AAFwkTag::TEST, "NotifyProcMemoryLevel_0100 end"); +} + +HWTEST_F(AppMgrServiceFourthTest, HasDumpPermission_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "HasDumpPermission_0100 start"); + AAFwk::MyStatus::GetInstance().isVerifyAccessToken_ = Security::AccessToken::PermissionState::PERMISSION_GRANTED; + AAFwk::MyStatus::GetInstance().isVerifyAccessToken_ += 1; + auto result = appMgrService_->HasDumpPermission(); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "HasDumpPermission_0100 end"); +} + +/** + * @tc.name: AddAbilityStageDone_0100 + * @tc.desc: AddAbilityStageDone. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, AddAbilityStageDone_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AddAbilityStageDone_0100 start"); + EXPECT_CALL(*mockTaskHandler_, SubmitTaskInner(_, _)).Times(1).WillOnce(Invoke(IgnoreTask)); + appMgrService_->AddAbilityStageDone(0); + TAG_LOGI(AAFwkTag::TEST, "AddAbilityStageDone_0100 end"); +} + +/** + * @tc.name: StartUserTestProcess_0100 + * @tc.desc: StartUserTestProcess. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceFourthTest, StartUserTestProcess_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "StartUserTestProcess_0100 start"); + AAFwk::MyStatus::GetInstance().isShellCall_ = false; + AAFwk::Want want; + sptr observer; + AppExecFwk::BundleInfo bundleInfo; + int32_t result = appMgrService_->StartUserTestProcess(want, observer, bundleInfo, 0); + EXPECT_EQ(result, ERR_INVALID_OPERATION); + TAG_LOGI(AAFwkTag::TEST, "StartUserTestProcess_0100 end"); +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_mgr_service_fourth_test/mock/include/mock_bundle_mgr_helper.h b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_bundle_mgr_helper.h new file mode 100755 index 0000000000000000000000000000000000000000..68693fbcd7d6e32a11ef338cd87f39219bfe2ae3 --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_bundle_mgr_helper.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H +#define OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H + +#include + +#include "bundle_mgr_interface.h" + +namespace OHOS { +constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000; +namespace AppExecFwk { +using Want = OHOS::AAFwk::Want; +class BundleMgrHelper : public std::enable_shared_from_this { +public: + DISALLOW_COPY_AND_MOVE(BundleMgrHelper); + void PreConnect(); + void ConnectTillSuccess(); + void SetBmsReady(bool bmsReady); + ErrCode GetNameForUid(const int32_t uid, std::string& name); + ErrCode GetNameAndIndexForUid(const int32_t uid, std::string& bundleName, int32_t& appIndex); + bool GetBundleInfo(const std::string& bundleName, const BundleFlag flag, BundleInfo& bundleInfo, int32_t userId); + ErrCode InstallSandboxApp(const std::string& bundleName, int32_t dlpType, int32_t userId, int32_t& appIndex); + ErrCode UninstallSandboxApp(const std::string& bundleName, int32_t appIndex, int32_t userId); + ErrCode GetUninstalledBundleInfo(const std::string bundleName, BundleInfo& bundleInfo); + ErrCode GetSandboxBundleInfo(const std::string& bundleName, int32_t appIndex, int32_t userId, BundleInfo& info); + ErrCode GetSandboxAbilityInfo( + const Want& want, int32_t appIndex, int32_t flags, int32_t userId, AbilityInfo& abilityInfo); + ErrCode GetSandboxExtAbilityInfos(const Want& want, int32_t appIndex, int32_t flags, int32_t userId, + std::vector& extensionInfos); + 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); + ErrCode GetBaseSharedBundleInfos(const std::string& bundleName, + std::vector& baseSharedBundleInfos, + GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO); + ErrCode GetBundleInfoForSelf(int32_t flags, BundleInfo& bundleInfo); + ErrCode GetDependentBundleInfo(const std::string& sharedBundleName, BundleInfo& sharedBundleInfo, + GetDependentBundleInfoFlag flag = GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO); + bool GetGroupDir(const std::string& dataGroupId, std::string& dir); + sptr GetOverlayManagerProxy(); + bool QueryAbilityInfo(const Want& want, AbilityInfo& abilityInfo); + bool QueryAbilityInfo(const Want& want, int32_t flags, int32_t userId, AbilityInfo& abilityInfo); + bool GetBundleInfos( + int32_t flags, std::vector& bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID); + sptr GetQuickFixManagerProxy(); + bool ProcessPreload(const Want& want); + sptr GetAppControlProxy(); + bool QueryExtensionAbilityInfos(const Want& want, const int32_t& flag, const int32_t& userId, + std::vector& extensionInfos); + ErrCode GetBundleInfoV9(const std::string& bundleName, int32_t flags, BundleInfo& bundleInfo, int32_t userId); + bool GetApplicationInfo( + const std::string& appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo& appInfo); + bool GetApplicationInfo(const std::string& appName, int32_t flags, int32_t userId, ApplicationInfo& appInfo); + bool GetApplicationInfoWithAppIndex( + const std::string& appName, int32_t appIndex, int32_t userId, ApplicationInfo& appInfo); + ErrCode GetJsonProfile(ProfileType profileType, const std::string& bundleName, const std::string& moduleName, + std::string& profile, int32_t userId = Constants::UNSPECIFIED_USERID); + bool UnregisterBundleEventCallback(const sptr& bundleEventCallback); + bool QueryExtensionAbilityInfoByUri( + const std::string& uri, int32_t userId, ExtensionAbilityInfo& extensionAbilityInfo); + bool ImplicitQueryInfoByPriority( + const Want& want, int32_t flags, int32_t userId, AbilityInfo& abilityInfo, ExtensionAbilityInfo& extensionInfo); + bool QueryAbilityInfoByUri(const std::string& abilityUri, int32_t userId, AbilityInfo& abilityInfo); + bool QueryAbilityInfo( + const Want& want, int32_t flags, int32_t userId, AbilityInfo& abilityInfo, const sptr& callBack); + void UpgradeAtomicService(const Want& want, int32_t userId); + bool ImplicitQueryInfos(const Want& want, int32_t flags, int32_t userId, bool withDefault, + std::vector& abilityInfos, std::vector& extensionInfos, + bool& findDefaultApp); + bool CleanBundleDataFiles(const std::string& bundleName, int32_t userId, int32_t appCloneIndex); + bool QueryDataGroupInfos(const std::string& bundleName, int32_t userId, std::vector& infos); + bool RegisterBundleEventCallback(const sptr& bundleEventCallback); + bool GetBundleInfos( + const BundleFlag flag, std::vector& bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID); + bool GetHapModuleInfo(const AbilityInfo& abilityInfo, int32_t userId, HapModuleInfo& hapModuleInfo); + bool QueryAppGalleryBundleName(std::string& bundleName); + ErrCode GetUidByBundleName(const std::string& bundleName, int32_t userId, int32_t appCloneIndex); + ErrCode QueryExtensionAbilityInfosOnlyWithTypeName(const std::string& extensionTypeName, const uint32_t flag, + const int32_t userId, std::vector& extensionInfos); + sptr GetDefaultAppProxy(); + ErrCode GetLaunchWantForBundle(const std::string& bundleName, Want& want, int32_t userId); + ErrCode QueryCloneAbilityInfo( + const ElementName& element, int32_t flags, int32_t appCloneIndex, AbilityInfo& abilityInfo, int32_t userId); + ErrCode GetCloneBundleInfo( + const std::string& bundleName, int32_t flags, int32_t appCloneIndex, BundleInfo& bundleInfo, int32_t userId); + ErrCode QueryCloneExtensionAbilityInfoWithAppIndex(const ElementName& element, int32_t flags, int32_t appCloneIndex, + ExtensionAbilityInfo& extensionInfo, int32_t userId); + ErrCode GetCloneAppIndexes(const std::string& bundleName, std::vector& appIndexes, int32_t userId); + ErrCode GetSignatureInfoByBundleName(const std::string& bundleName, SignatureInfo& signatureInfo); + std::string GetStringById( + const std::string& bundleName, const std::string& moduleName, uint32_t resId, int32_t userId); + std::string GetDataDir(const std::string& bundleName, const int32_t appIndex); + ErrCode GetAppProvisionInfo(const std::string& bundleName, int32_t userId, AppExecFwk::AppProvisionInfo& info); +private: + sptr Connect(); + sptr Connect(bool checkBmsReady); + sptr ConnectBundleInstaller(); + void OnDeath(); + std::string ParseBundleNameByAppId(const std::string& appId) const; + DECLARE_DELAYED_SINGLETON(BundleMgrHelper) + bool bmsReady_ = true; + sptr bundleMgr_; + sptr bundleInstaller_; + sptr deathRecipient_ = nullptr; + std::mutex mutex_; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H \ No newline at end of file diff --git a/test/unittest/app_mgr_service_fourth_test/mock/include/mock_ipc_skeleton.h b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_ipc_skeleton.h new file mode 100644 index 0000000000000000000000000000000000000000..ed7ad76a7ef1fb9ea3cc6a6256282a6c9f36ee20 --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_ipc_skeleton.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_IPC_IPC_SKELETON_H +#define OHOS_IPC_IPC_SKELETON_H + +#include "iremote_object.h" + +namespace OHOS { +class IPCSkeleton { +public: + IPCSkeleton() = default; + ~IPCSkeleton() = default; + static bool SetMaxWorkThreadNum(int maxThreadNum); + static void JoinWorkThread(); + static void StopWorkThread(); + static pid_t GetCallingPid(); + static pid_t GetCallingUid(); + static uint32_t GetCallingTokenID(); + static std::string GetLocalDeviceID(); + static std::string GetCallingDeviceID(); + static bool IsLocalCalling(); + static IPCSkeleton &GetInstance(); + static sptr GetContextObject(); + static bool SetContextObject(sptr &object); + static int FlushCommands(IRemoteObject *object); + static std::string ResetCallingIdentity(); + static bool SetCallingIdentity(std::string &identity); + static void SetCallingUid(pid_t uid); + static void SetCallingPid(pid_t pid); + static uint32_t SetCallingTokenID(pid_t tokenId); +}; +} // namespace OHOS +#endif // OHOS_IPC_IPC_SKELETON_H diff --git a/test/unittest/app_mgr_service_fourth_test/mock/include/mock_my_status.h b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_my_status.h new file mode 100644 index 0000000000000000000000000000000000000000..405a5d4a69ec0bf260a7998742ee77cce4259f02 --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_my_status.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MOCK_MY_STATUS_H +#define MOCK_MY_STATUS_H +#include "bundle_mgr_helper.h" +#include "remote_client_manager.h" +#include "app_running_record.h" +#include "iservice_registry.h" +#include "singleton.h" +#include "system_ability_definition.h" +#include "user_record_manager.h" +#include "hilog_tag_wrapper.h" +namespace OHOS { +namespace AAFwk { +class MyStatus { +public: + static MyStatus& GetInstance(); + ~MyStatus() = default; + bool isShouldKillProcess_ = false; + int32_t getAppIndex_ = 0; + bool isKeepAliveApp_ = false; + int32_t setProcessCacheBlockedTimes_ = 0; + bool isSACall_ = false; + bool isShellCall_ = false; + bool isVerifyPermissionByTokenId_ = false; + bool isVerifyCallingPermission_ = false; + bool isCheckSpecificSystemAbilityAccessPermission_ = false; + bool isVerifyRunningInfoPerm_ = false; + bool isCheckPermission_ = false; + bool isCheckPermissionByTokenId_ = false; + bool isAllowedToUseSystemAPI_ = false; + std::shared_ptr getBundleManagerHelper_ = nullptr; + ErrCode getBundleInfoV9Flag_ = ERR_OK; + ErrCode isGetHapModuleInfo_ = ERR_OK; + ErrCode getNameForUidFlag_ = ERR_OK; + ErrCode getSandboxExtAbilityInfosFlag_ = ERR_OK; + int isVerifyAccessToken_ = 0; +private: + MyStatus() = default; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // MOCK_MY_STATUS_H \ No newline at end of file diff --git a/test/unittest/app_mgr_service_fourth_test/mock/include/mock_permission_verification.h b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_permission_verification.h new file mode 100644 index 0000000000000000000000000000000000000000..fb17d2ac03c5aaecdfc0a2f8cebed6f673e919cd --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/include/mock_permission_verification.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H +#define OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H + +#include + +#include "ipc_skeleton.h" +#include "singleton.h" +#include "want.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 IsSACall() const; + bool CheckSpecificSystemAbilityAccessPermission(const std::string &processName) const; + bool IsAllowedToUseSystemAPI(const std::string &permissionName) const; + bool VerifyRunningInfoPerm() const; + bool IsShellCall() const; + bool VerifyCallingPermission(const std::string &permissionName) const; + bool VerifyCallingPermission(const std::string &permissionName, const uint32_t specifyTokenId) const; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H \ No newline at end of file diff --git a/test/unittest/app_mgr_service_fourth_test/mock/src/mock_accesstoken_kit.cpp b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_accesstoken_kit.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21eed41238e4db252e06fa4b54cbae038baacb0e --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_accesstoken_kit.cpp @@ -0,0 +1,28 @@ +/* + * 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 "accesstoken_kit.h" +#include "mock_my_status.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +int AccessTokenKit::VerifyAccessToken(AccessTokenID tokenID, const std::string &permissionName, bool crossIpc) +{ + return AAFwk::MyStatus::GetInstance().isVerifyAccessToken_; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_mgr_service_fourth_test/mock/src/mock_app_running_record.cpp b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_app_running_record.cpp new file mode 100644 index 0000000000000000000000000000000000000000..90f231a2afc24314e46ad0b9926a35cb196bee40 --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_app_running_record.cpp @@ -0,0 +1,1244 @@ +/* + * 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) +{ +} + +const std::string &AppRunningRecord::GetBundleName() const +{ + 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 +{ + return 0; +} + +const std::string &AppRunningRecord::GetName() const +{ + 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 +{ + 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 +{ + return curState_; +} + +void AppRunningRecord::SetState(const ApplicationState state) +{ + curState_ = state; +} + +void AppRunningRecord::SetRestartTimeMillis(const int64_t restartTimeMillis) +{ + restartTimeMillis_ = restartTimeMillis; +} + +const std::list> AppRunningRecord::GetAppInfoList() +{ + std::list> appInfoList; + return appInfoList; +} + +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() +{ + 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) +{ +} + +void AppRunningRecord::ScheduleTerminate() +{ +} + +void AppRunningRecord::LaunchPendingAbilities() +{ +} + +bool AppRunningRecord::ScheduleForegroundRunning() +{ + 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) +{ +} + +void AppRunningRecord::AddModule(std::shared_ptr appInfo, + std::shared_ptr abilityInfo, sptr token, + const HapModuleInfo &hapModuleInfo, std::shared_ptr want, int32_t abilityRecordId) +{ +} + +std::shared_ptr AppRunningRecord::GetModuleRecordByModuleName( + const std::string &bundleName, const std::string &moduleName) +{ + return nullptr; +} + +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 +{ + return nullptr; +} + +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) +{ + appDeathRecipient_ = appDeathRecipient; +} + +std::shared_ptr AppRunningRecord::GetPriorityObject() +{ + 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 +{ + return AAFwk::MyStatus::GetInstance().isKeepAliveApp_; +} + +bool AppRunningRecord::IsKeepAliveDkv() const +{ + return isKeepAliveDkv_; +} + +void AppRunningRecord::SetKeepAliveEnableState(bool isKeepAliveEnable) +{ + isKeepAliveRdb_ = isKeepAliveEnable; +} + +void AppRunningRecord::SetKeepAliveDkv(bool isKeepAliveDkv) +{ + 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) +{ +} + +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::SetSpecifiedAbilityFlagAndWant( + int requestId, const AAFwk::Want &want, const std::string &moduleName) +{ +} + +int32_t AppRunningRecord::GetSpecifiedRequestId() const +{ + return -1; +} + +void AppRunningRecord::ResetSpecifiedRequest() +{ +} + +void AppRunningRecord::SetScheduleNewProcessRequestState(int32_t requestId, + const AAFwk::Want &want, const std::string &moduleName) +{ +} + +bool AppRunningRecord::IsNewProcessRequest() const +{ + return false; +} + +bool AppRunningRecord::IsStartSpecifiedAbility() const +{ + return false; +} + +void AppRunningRecord::SchedulePrepareTerminate(const std::string &moduleName) +{ +} + +void AppRunningRecord::ScheduleAcceptWant(const std::string &moduleName) +{ +} + +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 +{ + return -1; +} + +void AppRunningRecord::ResetNewProcessRequest() +{ +} + +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 nullptr; +} + +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) +{ +} + +bool AppRunningRecord::IsDebugApp() +{ + 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() +{ + return parentAppRecord_.lock(); +} + +int32_t AppRunningRecord::ChangeAppGcState(int32_t state, uint64_t tid) +{ + return 0; +} + +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) +{ + 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) +{ +} + +std::shared_ptr AppRunningRecord::GetChildProcessRecordByPid(pid_t pid) +{ + return nullptr; +} + +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) +{ + 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) +{ + browserHost_ = browser; +} + +sptr AppRunningRecord::GetBrowserHost() +{ + 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() +{ + return 0; +} + +void AppRunningRecord::SetAttachedToStatusBar(bool isAttached) +{ + isAttachedToStatusBar = isAttached; +} + +bool AppRunningRecord::IsAttachedToStatusBar() +{ + return isAttachedToStatusBar; +} + +void AppRunningRecord::SetProcessCacheBlocked(bool isBlocked) +{ + AAFwk::MyStatus::GetInstance().setProcessCacheBlockedTimes_++; + processCacheBlocked = isBlocked; +} + +bool AppRunningRecord::GetProcessCacheBlocked() +{ + return processCacheBlocked; +} + +bool AppRunningRecord::IsAllAbilityReadyToCleanedByUserRequest() +{ + return false; +} + +void AppRunningRecord::SetUserRequestCleaning() +{ + 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) +{ +} + +void AppRunningRecord::SetNeedPreloadModule(bool isNeedPreloadModule) +{ + isNeedPreloadModule_ = isNeedPreloadModule; +} + +bool AppRunningRecord::GetNeedPreloadModule() +{ + return isNeedPreloadModule_; +} + +void AppRunningRecord::SetNWebPreload(const bool isAllowedNWebPreload) +{ + 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; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/app_mgr_service_fourth_test/mock/src/mock_bundle_mgr_helper.cpp b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_bundle_mgr_helper.cpp new file mode 100755 index 0000000000000000000000000000000000000000..8b5b148cd1245439ca077f654c1f6eac6201de4b --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_bundle_mgr_helper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mock_bundle_mgr_helper.h" +#include "mock_my_status.h" + +namespace OHOS { +namespace AppExecFwk { +namespace { +const std::string TEST_NAME = "testName"; +constexpr int32_t USER_ID = 2000000; +} // namespace +BundleMgrHelper::BundleMgrHelper() {} + +BundleMgrHelper::~BundleMgrHelper() {} + +ErrCode BundleMgrHelper::GetSandboxExtAbilityInfos(const Want& want, int32_t appIndex, int32_t flags, int32_t userId, + std::vector& extensionInfos) +{ + return AAFwk::MyStatus::GetInstance().getSandboxExtAbilityInfosFlag_; +} + +ErrCode BundleMgrHelper::GetBundleInfoV9( + const std::string& bundleName, int32_t flags, BundleInfo& bundleInfo, int32_t userId) +{ + return AAFwk::MyStatus::GetInstance().getBundleInfoV9Flag_; +} + +bool BundleMgrHelper::GetHapModuleInfo(const AbilityInfo& abilityInfo, int32_t userId, HapModuleInfo& hapModuleInfo) +{ + return AAFwk::MyStatus::GetInstance().isGetHapModuleInfo_; +} + +ErrCode BundleMgrHelper::GetNameForUid(const int32_t uid, std::string &name) +{ + return AAFwk::MyStatus::GetInstance().getNameForUidFlag_; +} + +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_mgr_service_fourth_test/mock/src/mock_ipc_skeleton.cpp b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_ipc_skeleton.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f41c4b6a59d97577c5e424cc3927278aa12d4e1 --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_ipc_skeleton.cpp @@ -0,0 +1,58 @@ +/* + * 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 "mock_ipc_skeleton.h" + +namespace OHOS { +#ifdef CONFIG_IPC_SINGLE +using namespace IPC_SINGLE; +#endif + +namespace { +pid_t uid_ = 0; +pid_t pid_ = 0; +pid_t tokenId_ = 0; +} // namespace + +pid_t IPCSkeleton::GetCallingUid() +{ + return uid_; +} + +pid_t IPCSkeleton::GetCallingPid() +{ + return pid_; +} + +void IPCSkeleton::SetCallingPid(pid_t pid) +{ + pid_ = pid; +} + +void IPCSkeleton::SetCallingUid(pid_t uid) +{ + uid_ = uid; +} + +uint32_t IPCSkeleton::GetCallingTokenID() +{ + return tokenId_; +} + +uint32_t IPCSkeleton::SetCallingTokenID(pid_t tokenId) +{ + return tokenId_ = tokenId; +} +} // namespace OHOS diff --git a/test/unittest/app_mgr_service_fourth_test/mock/src/mock_my_status.cpp b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_my_status.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f0a1073cb2c6bfa1d39f4b077333f0c873d5515c --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_my_status.cpp @@ -0,0 +1,25 @@ +/* + * 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 "mock_my_status.h" + +namespace OHOS { +namespace AAFwk { + MyStatus& MyStatus::GetInstance() + { + static MyStatus instance; + return instance; + } +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_mgr_service_fourth_test/mock/src/mock_permission_verification.cpp b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_permission_verification.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d0658f593bf5c1a841dd78888c75eba7a0c8db6 --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_permission_verification.cpp @@ -0,0 +1,58 @@ +/* + * 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 "mock_permission_verification.h" +#include "mock_my_status.h" + +namespace OHOS { +namespace AAFwk { + +bool PermissionVerification::IsSACall() const +{ + return MyStatus::GetInstance().isSACall_; +} + +bool PermissionVerification::CheckSpecificSystemAbilityAccessPermission(const std::string &processName) const +{ + return MyStatus::GetInstance().isCheckSpecificSystemAbilityAccessPermission_; +} + +bool PermissionVerification::VerifyRunningInfoPerm() const +{ + return MyStatus::GetInstance().isVerifyRunningInfoPerm_; +} + +bool PermissionVerification::IsShellCall() const +{ + return MyStatus::GetInstance().isShellCall_; +} + +bool PermissionVerification::IsAllowedToUseSystemAPI(const std::string &permissionName) const +{ + return MyStatus::GetInstance().isAllowedToUseSystemAPI_; +} + +bool PermissionVerification::VerifyCallingPermission(const std::string &permissionName) const +{ + return MyStatus::GetInstance().isVerifyCallingPermission_; +} + +bool PermissionVerification::VerifyCallingPermission( + const std::string &permissionName, const uint32_t specifyTokenId) const +{ + return MyStatus::GetInstance().isVerifyCallingPermission_; +} +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/app_mgr_service_fourth_test/mock/src/mock_remote_client_manager.cpp b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_remote_client_manager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..564fd661ca2f59ab92aca909b0ad15e49b202578 --- /dev/null +++ b/test/unittest/app_mgr_service_fourth_test/mock/src/mock_remote_client_manager.cpp @@ -0,0 +1,66 @@ +/* + * 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 "remote_client_manager.h" +#include "iservice_registry.h" +#include "singleton.h" +#include "system_ability_definition.h" +#include "mock_my_status.h" + +namespace OHOS { +namespace AppExecFwk { +RemoteClientManager::RemoteClientManager() + : appSpawnClient_(std::make_shared()), + nwebSpawnClient_(std::make_shared(true)), + cjAppSpawnClient_(std::make_shared("cjappspawn")), + nativeSpawnClient_(std::make_shared("nativespawn")) +{} + +RemoteClientManager::~RemoteClientManager() {} + +std::shared_ptr RemoteClientManager::GetSpawnClient() +{ + return nullptr; +} + +void RemoteClientManager::SetSpawnClient(const std::shared_ptr &appSpawnClient) +{ +} + +std::shared_ptr RemoteClientManager::GetBundleManagerHelper() +{ + return AAFwk::MyStatus::GetInstance().getBundleManagerHelper_; +} + +void RemoteClientManager::SetBundleManagerHelper(const std::shared_ptr &bundleMgrHelper) +{ +} + +std::shared_ptr RemoteClientManager::GetNWebSpawnClient() +{ + return nullptr; +} + +std::shared_ptr RemoteClientManager::GetCJSpawnClient() +{ + return nullptr; +} + +std::shared_ptr RemoteClientManager::GetNativeSpawnClient() +{ + return nullptr; +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file