From 87f743f4ddb703814126db14595e0e48099d4ecc Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Tue, 8 Jul 2025 19:50:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=AA=E9=99=A4ability=5Fmanager=5Fservice?= =?UTF-8?q?=5Ffourteenth=5Ftest=E5=A4=9A=E4=BD=99Mock=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../mock/include/mock_accesstoken_kit.h | 49 --- .../mock/include/mock_app_utils.h | 396 ------------------ .../mock/include/mock_data_ability_manager.h | 77 ---- .../mock_ecological_rule_interceptor.h | 58 --- .../mock/include/mock_free_install_manager.h | 254 ----------- .../mock/include/mock_ipc_skeleton.h | 66 --- .../mock/include/mock_my_status.h | 56 --- .../mock/include/mock_parameters.h | 31 -- .../mock/src/mock_accesstoken_kit.cpp | 54 --- .../mock/src/mock_app_utils.cpp | 233 ----------- .../mock/src/mock_data_ability_manager.cpp | 136 ------ .../src/mock_ecological_rule_interceptor.cpp | 59 --- .../mock/src/mock_free_install_manager.cpp | 195 --------- .../mock/src/mock_ipc_skeleton.cpp | 54 --- .../mock/src/mock_parameters.cpp | 31 -- 15 files changed, 1749 deletions(-) delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_accesstoken_kit.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_app_utils.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_data_ability_manager.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ecological_rule_interceptor.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_free_install_manager.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ipc_skeleton.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_my_status.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_parameters.h delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_accesstoken_kit.cpp delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_app_utils.cpp delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_data_ability_manager.cpp delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ecological_rule_interceptor.cpp delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_free_install_manager.cpp delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ipc_skeleton.cpp delete mode 100644 test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_parameters.cpp diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_accesstoken_kit.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_accesstoken_kit.h deleted file mode 100644 index 073361296e7..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_accesstoken_kit.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ACCESSTOKEN_KIT_H -#define ACCESSTOKEN_KIT_H - -#include "access_token.h" -#include "native_token_info.h" -#include "hap_token_info.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -class PermissionGrantInfo { -public: - std::string grantBundleName; - std::string grantServiceAbilityName; -}; -class AccessTokenKit { -public: - static ATokenTypeEnum GetTokenTypeFlag(AccessTokenID tokenID); - - static int GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo &nativeTokenInfoRes); - - static int GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo &hapInfo); - - static int VerifyAccessToken(AccessTokenID tokenID, const std::string &permissionName, bool crossIpc); - - static void GetPermissionManagerInfo(PermissionGrantInfo &info); - static uint32_t GetHapTokenID(int32_t userId, const std::string &bundleName, int32_t appIndex); -}; - -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // MOCK_ACCESSTOKEN_KIT_H diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_app_utils.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_app_utils.h deleted file mode 100644 index 2175d9bed90..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_app_utils.h +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_APP_UTILS_H -#define OHOS_ABILITY_RUNTIME_APP_UTILS_H - -#include -#include - -#include "nocopyable.h" - -namespace OHOS { -namespace AAFwk { -constexpr const int32_t DEFAULT_MAX_EXT_PER_PROC = 10; -constexpr const int32_t DEFAULT_MAX_EXT_PER_DEV = 100; -constexpr const int32_t DEFAULT_INVALID_VALUE = -1; -constexpr const int32_t DEFAULT_MAX_CHILD_PROCESS = 0; -template -class DeviceConfiguration { -public: - bool isLoaded = false; - T value; -}; - -/** - * @class AppUtils - * provides app utils. - */ -class AppUtils { -public: - /** - * GetInstance, get an instance of AppUtils. - * - * @return An instance of AppUtils. - */ - static AppUtils &GetInstance(); - - /** - * AppUtils, destructor. - * - */ - ~AppUtils(); - - /** - * IsLauncher, check if it is a launcher. - * - * @param bundleName The bundle name. - * @return Whether it is a launcher. - */ - bool IsLauncher(const std::string &bundleName) const; - - /** - * IsLauncherAbility, check if it is a launcher ability. - * - * @param abilityName The ability name. - * @return Whether it is a launcher ability. - */ - bool IsLauncherAbility(const std::string &abilityName) const; - - /** - * IsInheritWindowSplitScreenMode, check if it is inherit window split screen mode. - * - * @return Whether it is inherit window split screen mode. - */ - bool IsInheritWindowSplitScreenMode(); - - /** - * IsSupportAncoApp, check if it supports anco app. - * - * @return Whether it supports anco app. - */ - bool IsSupportAncoApp(); - - /** - * GetTimeoutUnitTimeRatio, get timeout unit time ratio. - * - * @return Timeout unit time ratio. - */ - int32_t GetTimeoutUnitTimeRatio(); - - /** - * IsSelectorDialogDefaultPossion, check if selector dialog is on the default position. - * - * @return Whether selector dialog is on the default position. - */ - bool IsSelectorDialogDefaultPossion(); - - /** - * IsStartSpecifiedProcess, check whether or not to start specified process. - * - * @return Whether or not to start specified process. - */ - bool IsStartSpecifiedProcess(); - - /** - * IsUseMultiRenderProcess, check whether uses multi-render process. - * - * @return Whether uses multi-render process. - */ - bool IsUseMultiRenderProcess(); - - /** - * IsLimitMaximumOfRenderProcess, check limit maximum of render process. - * - * @return Whether limit maximum of render process. - */ - bool IsLimitMaximumOfRenderProcess(); - - /** - * IsGrantPersistUriPermission, check whether to grant persist uri permission. - * - * @return Whether to grant persist uri permission. - */ - bool IsGrantPersistUriPermission(); - - /** - * IsStartOptionsWithAnimation, check whether the start options have animation. - * - * @return Whether the start options have animation. - */ - bool IsStartOptionsWithAnimation(); - - /** - * IsStartOptionsWithAnimation, check whether it is a multi-process model. - * - * @return Whether it is a multi-process model. - */ - bool IsMultiProcessModel(); - - /** - * IsStartOptionsWithProcessOptions, check whether the start options have process options. - * - * @return Whether the start options have process options. - */ - bool IsStartOptionsWithProcessOptions(); - - /** - * EnableMoveUIAbilityToBackgroundApi, enable move ui-ability to background api. - * - * @return Whether the enable move ui-ability to background api is successful. - */ - bool EnableMoveUIAbilityToBackgroundApi(); - - /** - * IsLaunchEmbededUIAbility, check if it is to launch embedded ui-ability. - * - * @return Whether it is to launch embedded ui-ability. - */ - bool IsLaunchEmbededUIAbility(); - - /** - * IsSupportNativeChildProcess, check if it supports native child process. - * - * @return Whether it supports native child process. - */ - bool IsSupportNativeChildProcess(); - - /** - * IsSupportMultiInstance, check if it supports multi-instance. - * - * @return Whether it supports multi-instance. - */ - bool IsSupportMultiInstance(); - - /** - * IsAllowResidentInExtremeMemory, check if it allows resident in extrem low memory. - * - * @param bundleName The bundle name. - * @param abilityName The ability name. - * @return Whether it allows resident in extrem low memory. - */ - bool IsAllowResidentInExtremeMemory(const std::string& bundleName, const std::string& abilityName = ""); - - /** - * IsAllowNativeChildProcess, check if it allows native child process. - * - * @param appIdentifier The app identifier. - * @return Whether it allows native child process. - */ - bool IsAllowNativeChildProcess(const std::string &appIdentifier); - - /** - * GetLimitMaximumExtensionsPerProc, get limit max extensions per proc. - * - * @return Limit max extensions per proc. - */ - int32_t GetLimitMaximumExtensionsPerProc(); - - /** - * IsBigMemoryUnrelatedKeepAliveProc, check if it refuses resident in memory quick kill. - * - * @param bundleName The bundle name. - */ - bool IsBigMemoryUnrelatedKeepAliveProc(const std::string &bundleName); - - /** - * IsRequireBigMemoryProcess, check if it requires big memory. - * - * @param bundleName The bundle name. - */ - bool IsRequireBigMemoryProcess(const std::string &bundleName); - - /** - * GetLimitMaximumExtensionsPerDevice, get limit max extensions per device. - * - * @return Limit max extensions per device. - */ - int32_t GetLimitMaximumExtensionsPerDevice(); - - /** - * GetCacheExtensionTypeList, get cache extension type list. - * - * @return Cache extension type list. - */ - std::string GetCacheExtensionTypeList(); - - /** - * IsAllowStartAbilityWithoutCallerToken, check if it allows start ability without caller token. - * - * @param bundleName The bundle name. - * @param abilityName The ability name. - * @return Whether it allows start ability without caller token. - */ - bool IsAllowStartAbilityWithoutCallerToken(const std::string& bundleName, const std::string& abilityName); - - /** - * GetBrokerDelegateBundleName, get broker delegate bundle name. - * - * @return Broker delegate bundle name. - */ - std::string GetBrokerDelegateBundleName(); - - /** - * GetCollaboratorBrokerUID, get collaborator broker id. - * - * @return Collaborator broker id. - */ - int32_t GetCollaboratorBrokerUID(); - - /** - * GetCollaboratorBrokerReserveUID, get collaborator broker reserve uid. - * - * @return Collaborator broker reserve uid. - */ - int32_t GetCollaboratorBrokerReserveUID(); - - /** - * MaxChildProcess, get max child process. - * - * @return Max child process. - */ - int32_t MaxChildProcess(); - - /** - * GetMigrateClientBundleName, get migrate client bundle name. - * - * @return Migrate client bundle name. - */ - std::string GetMigrateClientBundleName(); - - /** - * IsConnectSupportCrossUser, check if it support cross-user. - * - * @return Whether it supports cross-user. - */ - bool IsConnectSupportCrossUser(); - - /** - * IsPrepareTerminateEnabled, check if it supports prepare terminate. - * - * @return Whether it supports prepare terminate. - */ - bool IsPrepareTerminateEnabled(); - - /** - * IsCacheExtensionAbilityByList, check if it allows cache extension ability by list. - * - * @param bundleName The bundle name. - * @param abilityName The ability name. - * @return Whether it allows cache extensionability. - */ - bool IsCacheExtensionAbilityByList(const std::string& bundleName, const std::string& abilityName); - - /** - * IsSystemReasonMessage, check if it supports launch reason message. - * - * @param reasonMessage The launch reason message. - * @return Whether it supports launch reason message. - */ - bool IsSystemReasonMessage(const std::string &reasonMessage); - -private: - /** - * LoadResidentProcessInExtremeMemory, load resident process in extreme low memory. - * - */ - void LoadResidentProcessInExtremeMemory(); - - /** - * LoadAllowNativeChildProcessApps, load allow native child process apps. - * - */ - void LoadAllowNativeChildProcessApps(); - - /** - * LoadStartAbilityWithoutCallerToken, load start ability without caller token. - * - */ - void LoadStartAbilityWithoutCallerToken(); - - /** - * IsCacheAbilityEnabled, check cache ability parameter switch. - * - */ - bool IsCacheAbilityEnabled(); - - /** - * LoadCacheAbilityList, load cache ability list from file. - * - */ - void LoadCacheAbilityList(); - - /** - * LoadProcessProhibitedFromRestarting, load process prohibited in big memory. - * - */ - void LoadProcessProhibitedFromRestarting(); - - /** - * LoadRequireBigMemoryApp, load app name that require big memory. - * - */ - void LoadRequireBigMemoryApp(); - - /** - * AppUtils, private constructor. - * - */ - AppUtils(); - - volatile bool isSceneBoard_ = false; - volatile DeviceConfiguration isInheritWindowSplitScreenMode_ = {false, true}; - volatile DeviceConfiguration isSupportAncoApp_ = {false, false}; - volatile DeviceConfiguration timeoutUnitTimeRatio_ = {false, 1}; - volatile DeviceConfiguration isSelectorDialogDefaultPossion_ = {false, true}; - volatile DeviceConfiguration isStartSpecifiedProcess_ = {false, false}; - volatile DeviceConfiguration isUseMultiRenderProcess_ = {false, true}; - volatile DeviceConfiguration isLimitMaximumOfRenderProcess_ = {false, true}; - volatile DeviceConfiguration isGrantPersistUriPermission_ = {false, false}; - volatile DeviceConfiguration isStartOptionsWithAnimation_ = {false, false}; - volatile DeviceConfiguration isMultiProcessModel_ = {false, false}; - volatile DeviceConfiguration isStartOptionsWithProcessOptions_ = {false, false}; - volatile DeviceConfiguration enableMoveUIAbilityToBackgroundApi_ = {false, true}; - volatile DeviceConfiguration isLaunchEmbededUIAbility_ = {false, false}; - volatile DeviceConfiguration isSupportNativeChildProcess_ = {false, false}; - volatile DeviceConfiguration isSupportMultiInstance_ = {false, false}; - std::mutex isConnectSupportCrossUserMutex_; - volatile DeviceConfiguration isConnectSupportCrossUser_ = {false, false}; - DeviceConfiguration>> - residentProcessInExtremeMemory_ = {false, {}}; - std::mutex residentProcessInExtremeMemoryMutex_; - DeviceConfiguration> processProhibitedFromRestarting_ = {false, {}}; - std::mutex processProhibitedFromRestartingMutex_; - DeviceConfiguration> requireBigMemoryApp_ = {false, {}}; - std::mutex requireBigMemoryAppMutex_; - DeviceConfiguration> - allowStartNativeProcessApps_ = {false, {}}; - volatile DeviceConfiguration limitMaximumExtensionsPerProc_ = {false, DEFAULT_MAX_EXT_PER_PROC}; - volatile DeviceConfiguration limitMaximumExtensionsPerDevice_ = {false, DEFAULT_MAX_EXT_PER_DEV}; - DeviceConfiguration>> - startAbilityWithoutCallerToken_ = {false, {}}; - std::mutex startAbilityWithoutCallerTokenMutex_; - DeviceConfiguration brokerDelegateBundleName_ = {false, ""}; - volatile DeviceConfiguration collaboratorBrokerUid_ = {false, DEFAULT_INVALID_VALUE}; - volatile DeviceConfiguration collaboratorBrokerReserveUid_ = {false, DEFAULT_INVALID_VALUE}; - volatile DeviceConfiguration maxChildProcess_ = {false, DEFAULT_MAX_CHILD_PROCESS}; - DeviceConfiguration migrateClientBundleName_ = {true, "com.huwei.hmos.migratecilent"}; - DeviceConfiguration>> - cacheAbilityList_ = {false, {}}; - DISALLOW_COPY_AND_MOVE(AppUtils); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_APP_UTILS_H diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_data_ability_manager.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_data_ability_manager.h deleted file mode 100644 index dfe3b34eaff..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_data_ability_manager.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_DATA_ABILITY_MANAGER_H -#define OHOS_ABILITY_RUNTIME_DATA_ABILITY_MANAGER_H - -#include -#include -#include -#include -#include "cpp/mutex.h" - -#include "ability_record.h" -#include "ability_running_info.h" -#include "data_ability_record.h" -#include "nocopyable.h" - -namespace OHOS { -namespace AAFwk { -class DataAbilityManager : public NoCopyable { -public: - DataAbilityManager(); - virtual ~DataAbilityManager(); - -public: - sptr Acquire( - const AbilityRequest &abilityRequest, bool tryBind, const sptr &client, bool isNotHap); - int Release(const sptr &scheduler, const sptr &client, bool isNotHap); - int AttachAbilityThread(const sptr &scheduler, const sptr &token); - int AbilityTransitionDone(const sptr &token, int state); - void OnAbilityRequestDone(const sptr &token, const int32_t state); - void OnAppStateChanged(const AppInfo &info); - void OnAbilityDied(const std::shared_ptr &abilityRecord); - std::shared_ptr GetAbilityRecordById(int64_t id); - std::shared_ptr GetAbilityRecordByToken(const sptr &token); - std::shared_ptr GetAbilityRecordByScheduler(const sptr &scheduler); - void Dump(const char *func, int line); - void DumpState(std::vector &info, const std::string &args = "") const; - void DumpSysState(std::vector &info, bool isClient = false, const std::string &args = "") const; - bool ContainsDataAbility(const sptr &scheduler); - void GetAbilityRunningInfos(std::vector &info, bool isPerm); - -private: - using DataAbilityRecordPtr = std::shared_ptr; - using DataAbilityRecordPtrMap = std::map; - -private: - DataAbilityRecordPtr LoadLocked(const std::string &name, const AbilityRequest &req); - void DumpLocked(const char *func, int line); - void RestartDataAbility(const std::shared_ptr &abilityRecord); - void ReportDataAbilityAcquired(const sptr &client, bool isNotHap, - std::shared_ptr &record); - void ReportDataAbilityReleased(const sptr &client, bool isNotHap, - std::shared_ptr &record); - void DumpClientInfo(std::vector &info, bool isClient, - std::shared_ptr dataAbilityRecord) const; -private: - mutable ffrt::mutex mutex_; - DataAbilityRecordPtrMap dataAbilityRecordsLoaded_; - DataAbilityRecordPtrMap dataAbilityRecordsLoading_; -}; -} // namespace AAFwk -} // namespace OHOS - -#endif // OHOS_ABILITY_RUNTIME_DATA_ABILITY_MANAGER_H diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ecological_rule_interceptor.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ecological_rule_interceptor.h deleted file mode 100644 index f9bd3d54d0b..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ecological_rule_interceptor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_ECOLOGICAL_RULE_INTERCEPTOR_H -#define OHOS_ABILITY_RUNTIME_ECOLOGICAL_RULE_INTERCEPTOR_H - -#include "interceptor/ability_interceptor_interface.h" - -#include "query_erms_observer_interface.h" - -namespace OHOS { -namespace EcologicalRuleMgrService { -struct AbilityCallerInfo; -struct AbilityExperienceRule; -} -namespace AAFwk { -using namespace OHOS::EcologicalRuleMgrService; -using ErmsCallerInfo = OHOS::EcologicalRuleMgrService::AbilityCallerInfo; -using ExperienceRule = OHOS::EcologicalRuleMgrService::AbilityExperienceRule; -using AtomicServiceStartupRule = OHOS::AbilityRuntime::AtomicServiceStartupRule; - -class EcologicalRuleInterceptor : public IAbilityInterceptor { -public: - EcologicalRuleInterceptor() = default; - ~EcologicalRuleInterceptor() = default; - ErrCode DoProcess(AbilityInterceptorParam param) override; - bool DoProcess(Want &want, int32_t userId); - virtual void SetTaskHandler(std::shared_ptr taskHandler) override - { - return; - }; - ErrCode QueryAtomicServiceStartupRule(Want &want, sptr callerToken, - int32_t userId, AtomicServiceStartupRule &rule, sptr &replaceWant); - -private: - void GetEcologicalTargetInfo(const Want &want, const std::shared_ptr &abilityInfo, - ErmsCallerInfo &callerInfo); - void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId, - const sptr &callerToken = nullptr); - void InitErmsCallerInfo(const Want &want, const std::shared_ptr &abilityInfo, - ErmsCallerInfo &callerInfo, int32_t userId, const sptr &callerToken = nullptr); - static int32_t GetAppTypeByBundleType(int32_t bundleType); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_ECOLOGICAL_RULE_INTERCEPTOR_H \ No newline at end of file diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_free_install_manager.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_free_install_manager.h deleted file mode 100644 index 0772c7ec9f0..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_free_install_manager.h +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_FREE_INSTALL_MANAGER_H -#define OHOS_ABILITY_RUNTIME_FREE_INSTALL_MANAGER_H - -#include -#include "cpp/mutex.h" - -#include -#include -#include - -#include "ability_info.h" -#include "free_install_observer_manager.h" -#include "start_options.h" -#include "want.h" - -namespace OHOS { -namespace AAFwk { -class AbilityManagerService; - -struct FreeInstallInfo { - bool isInstalled = false; - bool isPreStartMissionCalled = false; - bool isStartUIAbilityBySCBCalled = false; - bool isFreeInstallFinished = false; - bool isOpenAtomicServiceShortUrl = false; - uint32_t specifyTokenId = 0; - int32_t userId = -1; - int32_t requestCode = -1; - int resultCode = 0; - std::shared_ptr> promise; - std::string identity; - sptr callerToken = nullptr; - sptr dmsCallback = nullptr; - std::shared_ptr originalWant = nullptr; - std::shared_ptr startOptions = nullptr; - Want want; -}; - -struct FreeInstallParams { - bool isAsync = false; - bool isOpenAtomicServiceShortUrl = false; - uint32_t specifyTokenId = 0; - std::shared_ptr originalWant = nullptr; - std::shared_ptr startOptions = nullptr; -}; - -/** - * @class FreeInstallManager - * FreeInstallManager. - */ -class FreeInstallManager : public std::enable_shared_from_this { -public: - explicit FreeInstallManager(const std::weak_ptr &server); - virtual ~FreeInstallManager() = default; - - /** - * OnInstallFinished, StartFreeInstall is complete. - * - * @param resultCode, ERR_OK on success, others on failure. - * @param want, installed ability. - * @param userId, user`s id. - */ - void OnInstallFinished(int32_t recordId, int resultCode, const Want &want, int32_t userId, bool isAsync = false); - - /** - * OnRemoteInstallFinished, DMS has finished. - * - * @param resultCode, ERR_OK on success, others on failure. - * @param want, installed ability. - * @param userId, user`s id. - */ - void OnRemoteInstallFinished(int32_t recordId, int resultCode, const Want &want, int32_t userId); - - /** - * Start to free install. - * - * @param want, the want of the ability to free install. - * @param userId, designation User ID. - * @param requestCode, ability request code. - * @param callerToken, caller ability token. - * @param isAsync, the request is async. - * @param isOpenAtomicServiceShortUrl, the flag of open atomic service short url. - * @return Returns ERR_OK on success, others on failure. - */ - int StartFreeInstall(const Want &want, int32_t userId, int requestCode, const sptr &callerToken, - std::shared_ptr param = nullptr); - - /** - * Start to remote free install. - * - * @param want, the want of the ability to free install. - * @param requestCode, ability request code. - * @param validUserId, designation User ID. - * @param callerToken, caller ability token. - * @return Returns ERR_OK on success, others on failure. - */ - int StartRemoteFreeInstall(const Want &want, int requestCode, int32_t validUserId, - const sptr &callerToken); - - /** - * Start to free install from another devices. - * The request is send from DMS. - * - * @param want, the want of the ability to free install. - * @param callback, used to notify caller the result of free install. - * @param userId, designation User ID. - * @param requestCode, ability request code. - * @return Returns ERR_OK on success, others on failure. - */ - int FreeInstallAbilityFromRemote(const Want &want, const sptr &callback, - int32_t userId, int requestCode); - - /** - * Connect if the request is free install. - * @param want, the want of the ability to free install. - * @param userId, designation User ID. - * @param callerToken, caller ability token. - * @param localDeviceId, the device id of local. - * @return Returns ERR_OK on success, others on failure. - */ - int ConnectFreeInstall(const Want &want, int32_t userId, const sptr &callerToken, - const std::string& localDeviceId); - - /** - * Add an observer from application into freeInstallObserverManager. - * @param observer, the observer of the ability to free install. - * @return Returns ERR_OK on success, others on failure. - */ - int AddFreeInstallObserver(const sptr &callerToken, - const sptr &observer); - - /** - * Get free install task info. - * - * @param bundleName, the bundle name of the task. - * @param abilityName, the ability name of the task. - * @param startTime, the start time of the task. - * @param taskInfo, the found task info - * @return Returns true on success, false on failure. - */ - bool GetFreeInstallTaskInfo(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, FreeInstallInfo& taskInfo); - - /** - * Get free install task info. - * - * @param sessionId, the sessionId of the task. - * @param taskInfo, the found task info - * @return Returns true on success, false on failure. - */ - bool GetFreeInstallTaskInfo(const std::string& sessionId, FreeInstallInfo& taskInfo); - - /** - * Set the isStartUIAbilityBySCBCalled flag of the given free install task. - * - * @param bundleName, the bundle name of the task. - * @param abilityName, the abilitu name of the task. - * @param startTime, the start time of the task. - * @param scbCallStatus, the status of whether StartUIAbilityBySCB is called. - */ - void SetSCBCallStatus(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, bool scbCallStatus); - - /** - * Set the isPreStartMissionCalled flag of the given free install task. - * - * @param bundleName, the bundle name of the task. - * @param abilityName, the abilitu name of the task. - * @param startTime, the start time of the task. - * @param preStartMissionCallStatus, the status of whether PreStartMission is called. - */ - void SetPreStartMissionCallStatus(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, bool preStartMissionCallStatus); - - /** - * Set the sessionId of the given free install task. - * - * @param bundleName, the bundle name of the task. - * @param abilityName, the abilitu name of the task. - * @param startTime, the start time of the task. - * @param sessionId, the sessionId of the free install task. - */ - void SetFreeInstallTaskSessionId(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, const std::string& sessionId); - -private: - std::weak_ptr server_; - std::vector freeInstallList_; - std::vector dmsFreeInstallCbs_; - std::map timeStampMap_; - ffrt::mutex distributedFreeInstallLock_; - ffrt::mutex freeInstallListLock_; - ffrt::mutex freeInstallObserverLock_; - - int SetAppRunningState(Want &want); - - /** - * Start remote free install. - * - * @param want, the want of the ability to remote free install. - * @param userId, designation User ID. - * @param requestCode, ability request code. - * @param callerToken, caller ability token. - * @return Returns ERR_OK on success, others on failure. - */ - int RemoteFreeInstall(const Want &want, int32_t userId, int requestCode, const sptr &callerToken); - - int NotifyDmsCallback(const Want &want, int resultCode); - bool IsTopAbility(const sptr &callerToken); - void NotifyFreeInstallResult(int32_t recordId, const Want &want, int resultCode, bool isAsync = false); - FreeInstallInfo BuildFreeInstallInfo(const Want &want, int32_t userId, int requestCode, - const sptr &callerToken, std::shared_ptr param = nullptr); - std::time_t GetTimeStamp(); - - void RemoveFreeInstallInfo(const std::string &bundleName, const std::string &abilityName, - const std::string &startTime); - - void PostUpgradeAtomicServiceTask(int resultCode, const Want &want, int32_t userId); - - void RemoveTimeoutTask(const std::string &bundleName, const std::string &abilityName, const std::string &startTime); - - void StartAbilityByFreeInstall(FreeInstallInfo &info, std::string &bundleName, std::string &abilityName, - std::string &startTime); - void StartAbilityByPreInstall(int32_t recordId, FreeInstallInfo &info, std::string &bundleName, - std::string &abilityName, std::string &startTime); - int32_t UpdateElementName(Want &want, int32_t userId) const; - void HandleFreeInstallResult(int32_t recordId, FreeInstallInfo &freeInstallInfo, int resultCode, bool isAsync); - void HandleOnFreeInstallSuccess(int32_t recordId, FreeInstallInfo &freeInstallInfo, bool isAsync); - void HandleOnFreeInstallFail(int32_t recordId, FreeInstallInfo &freeInstallInfo, int resultCode, bool isAsync); - void StartAbilityByConvertedWant(FreeInstallInfo &info, const std::string &startTime); - void StartAbilityByOriginalWant(FreeInstallInfo &info, const std::string &startTime); - bool VerifyStartFreeInstallPermission(const sptr &callerToken); - int32_t GetRecordIdByToken(const sptr &callerToken); - void NotifyInsightIntentFreeInstallResult(const Want &want, int resultCode); - void NotifyInsightIntentExecuteDone(const Want &want, int resultCode); -}; -} // namespace AAFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_FREE_INSTALL_MANAGER_H diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ipc_skeleton.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ipc_skeleton.h deleted file mode 100644 index 390cf365d1a..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_ipc_skeleton.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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, bool status = true); - - static void SetCallingUid(pid_t uid); - - static uint32_t SetCallingTokenID(pid_t tokenId); - - static uint32_t GetSelfTokenID(); - - static uint64_t GetCallingFullTokenID(); -}; -} // namespace OHOS -#endif // OHOS_IPC_IPC_SKELETON_H diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_my_status.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_my_status.h deleted file mode 100644 index 55ffdc4189b..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_my_status.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 "ability_record.h" - -namespace OHOS { -namespace AAFwk { -class MyStatus { -public: - static MyStatus &GetInstance() - { - static MyStatus instance; - return instance; - }; - - bool auIsLaunchEmbededUIAbility_ = true; - int atkGetTokenTypeFlag_ = 0; - bool smhGetUIAbilityManagerByUid_ = true; - bool smhGetUIAbilityManagerByUserId_ = true; - bool smhGetMissionListManagerByUserId_ = true; - bool smhGetCurrentDataAbilityManager_ = true; - bool smhGetConnectManagerByToken_ = true; - bool smhVerificationAllToken_ = true; - std::shared_ptr ualmGetAbilityRecordByToken_ = nullptr; - int ualmGetSessionIdByAbilityToken_ = 0; - int fimStartFreeInstall_ = ERR_OK; - int eriQueryAtomicServiceStartupRule_ = ERR_OK; - std::shared_ptr arGetAbilityRecord_ = nullptr; - AppExecFwk::AbilityInfo arGetAbilityInfo_ = {}; - bool sbjIsSceneBoardEnabled_ = false; - int ipcGetCallingUid_ = 1; - int ipcGetCallingPid_ = 1; - uint32_t ipcGetCallingTokenID_ = 1; - uint32_t ipcGetSelfTokenID_ = 1; - int permPermission_ = 1; - bool perJudgeCallerIsAllowedToUseSystemAPI_ = true; - bool paramGetBoolParameter_ = true; -}; -} // namespace AAFwk -} // namespace OHOS -#endif // MOCK_MY_STATUS_H diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_parameters.h b/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_parameters.h deleted file mode 100644 index 2fa291f7d99..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/include/mock_parameters.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SYSTEM_PARAMETERS_H -#define SYSTEM_PARAMETERS_H - -#include - -namespace OHOS { -namespace system { - -void SetBoolParameter(const std::string& key, bool def); - -bool GetBoolParameter(const std::string& key, bool def); - -} // namespace system -} // namespace OHOS - -#endif // MOCK_PARAMETERS_H diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_accesstoken_kit.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_accesstoken_kit.cpp deleted file mode 100644 index 8a586b8b7a8..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_accesstoken_kit.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mock_accesstoken_kit.h" -#include "mock_my_status.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -ATokenTypeEnum AccessTokenKit::GetTokenTypeFlag(AccessTokenID tokenID) -{ - return static_cast(AAFwk::MyStatus::GetInstance().atkGetTokenTypeFlag_); -} - -int AccessTokenKit::GetNativeTokenInfo(AccessTokenID tokenID, NativeTokenInfo &nativeTokenInfoRes) -{ - return -1; -} - -int AccessTokenKit::GetHapTokenInfo(AccessTokenID tokenID, HapTokenInfo &hapInfo) -{ - return -1; -} - -int AccessTokenKit::VerifyAccessToken(AccessTokenID tokenID, const std::string &permissionName, bool crossIpc) -{ - return -1; -} - -void AccessTokenKit::GetPermissionManagerInfo(PermissionGrantInfo &info) -{ -} - -uint32_t AccessTokenKit::GetHapTokenID(int32_t userId, const std::string &bundleName, int32_t appIndex) -{ - return -1; -} - -} // namespace AccessToken -} // namespace Security -} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_app_utils.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_app_utils.cpp deleted file mode 100644 index f03fe2dd31d..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_app_utils.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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_app_utils.h" -#include "mock_my_status.h" - - -namespace OHOS { -namespace AAFwk { - -AppUtils::~AppUtils() {} - -AppUtils::AppUtils() {} - -AppUtils &AppUtils::GetInstance() -{ - static AppUtils utils; - return utils; -} - -bool AppUtils::IsLauncher(const std::string &bundleName) const -{ - return true; -} - -bool AppUtils::IsLauncherAbility(const std::string &abilityName) const -{ - return true; -} - -bool AppUtils::IsInheritWindowSplitScreenMode() -{ - return true; -} - -bool AppUtils::IsSupportAncoApp() -{ - return true; -} - -int32_t AppUtils::GetTimeoutUnitTimeRatio() -{ - return 0; -} - -bool AppUtils::IsSelectorDialogDefaultPossion() -{ - return true; -} - -bool AppUtils::IsStartSpecifiedProcess() -{ - return true; -} - -bool AppUtils::IsUseMultiRenderProcess() -{ - return true; -} - -bool AppUtils::IsLimitMaximumOfRenderProcess() -{ - return true; -} - -bool AppUtils::IsGrantPersistUriPermission() -{ - return true; -} - -bool AppUtils::IsStartOptionsWithAnimation() -{ - return true; -} - -bool AppUtils::IsMultiProcessModel() -{ - return true; -} - -bool AppUtils::IsStartOptionsWithProcessOptions() -{ - return true; -} - -bool AppUtils::EnableMoveUIAbilityToBackgroundApi() -{ - return true; -} - -bool AppUtils::IsLaunchEmbededUIAbility() -{ - return MyStatus::GetInstance().auIsLaunchEmbededUIAbility_; -} - -bool AppUtils::IsSupportNativeChildProcess() -{ - return true; -} - -bool AppUtils::IsAllowResidentInExtremeMemory(const std::string& bundleName, const std::string& abilityName) -{ - return true; -} - -bool AppUtils::IsBigMemoryUnrelatedKeepAliveProc(const std::string &bundleName) -{ - return true; -} - -bool AppUtils::IsRequireBigMemoryProcess(const std::string &bundleName) -{ - return true; -} - -void AppUtils::LoadProcessProhibitedFromRestarting() -{ -} - -void AppUtils::LoadRequireBigMemoryApp() -{ -} - -void AppUtils::LoadResidentProcessInExtremeMemory() -{ -} - -bool AppUtils::IsAllowNativeChildProcess(const std::string &appIdentifier) -{ - return true; -} - -void AppUtils::LoadAllowNativeChildProcessApps() -{ -} - -int32_t AppUtils::GetLimitMaximumExtensionsPerProc() -{ - return 0; -} - -int32_t AppUtils::GetLimitMaximumExtensionsPerDevice() -{ - return 0; -} - -std::string AppUtils::GetCacheExtensionTypeList() -{ - return ""; -} - -bool AppUtils::IsAllowStartAbilityWithoutCallerToken(const std::string& bundleName, const std::string& abilityName) -{ - return true; -} - -void AppUtils::LoadStartAbilityWithoutCallerToken() -{ -} - -std::string AppUtils::GetBrokerDelegateBundleName() -{ - return ""; -} - -int32_t AppUtils::GetCollaboratorBrokerUID() -{ - return 0; -} - -int32_t AppUtils::GetCollaboratorBrokerReserveUID() -{ - return 0; -} - -int32_t AppUtils::MaxChildProcess() -{ - return 0; -} - -bool AppUtils::IsSupportMultiInstance() -{ - return true; -} - -std::string AppUtils::GetMigrateClientBundleName() -{ - return ""; -} - -bool AppUtils::IsConnectSupportCrossUser() -{ - return true; -} - -bool AppUtils::IsPrepareTerminateEnabled() -{ - return true; -} - -bool AppUtils::IsSystemReasonMessage(const std::string &reasonMessage) -{ - return true; -} - -bool AppUtils::IsCacheAbilityEnabled() -{ - return true; -} - -void AppUtils::LoadCacheAbilityList() -{ -} - -bool AppUtils::IsCacheExtensionAbilityByList(const std::string& bundleName, const std::string& abilityName) -{ - return true; -} - -} // namespace AAFwk -} // namespace OHOS diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_data_ability_manager.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_data_ability_manager.cpp deleted file mode 100644 index c7407a9c898..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_data_ability_manager.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mock_data_ability_manager.h" - -namespace OHOS { -namespace AAFwk { -using namespace std::chrono; -using namespace std::placeholders; - -namespace { -constexpr bool DEBUG_ENABLED = false; -constexpr system_clock::duration DATA_ABILITY_LOAD_TIMEOUT = 11000ms; -} // namespace - -DataAbilityManager::DataAbilityManager() -{ -} - -DataAbilityManager::~DataAbilityManager() -{ -} - -sptr DataAbilityManager::Acquire( - const AbilityRequest &abilityRequest, bool tryBind, const sptr &client, bool isNotHap) -{ - return nullptr; -} - -int DataAbilityManager::Release( - const sptr &scheduler, const sptr &client, bool isNotHap) -{ - return ERR_OK; -} - -bool DataAbilityManager::ContainsDataAbility(const sptr &scheduler) -{ - return false; -} - -int DataAbilityManager::AttachAbilityThread(const sptr &scheduler, const sptr &token) -{ - return ERR_OK; -} - -int DataAbilityManager::AbilityTransitionDone(const sptr &token, int state) -{ - return ERR_OK; -} - -void DataAbilityManager::OnAbilityRequestDone(const sptr &token, const int32_t state) -{ - /* Do nothing now. */ -} - -void DataAbilityManager::OnAbilityDied(const std::shared_ptr &abilityRecord) -{ -} - -void DataAbilityManager::OnAppStateChanged(const AppInfo &info) -{ -} - -std::shared_ptr DataAbilityManager::GetAbilityRecordById(int64_t id) -{ - return nullptr; -} - -std::shared_ptr DataAbilityManager::GetAbilityRecordByToken(const sptr &token) -{ - return nullptr; -} - -std::shared_ptr DataAbilityManager::GetAbilityRecordByScheduler(const sptr &scheduler) -{ - return nullptr; -} - -void DataAbilityManager::Dump(const char *func, int line) -{ -} - -DataAbilityManager::DataAbilityRecordPtr DataAbilityManager::LoadLocked( - const std::string &name, const AbilityRequest &req) -{ - return nullptr; -} - -void DataAbilityManager::DumpLocked(const char *func, int line) -{ -} - -void DataAbilityManager::DumpState(std::vector &info, const std::string &args) const -{ -} - -void DataAbilityManager::DumpClientInfo(std::vector &info, bool isClient, - std::shared_ptr record) const -{ -} - -void DataAbilityManager::DumpSysState(std::vector &info, bool isClient, const std::string &args) const -{ -} - -void DataAbilityManager::GetAbilityRunningInfos(std::vector &info, bool isPerm) -{ -} - -void DataAbilityManager::RestartDataAbility(const std::shared_ptr &abilityRecord) -{ -} - -void DataAbilityManager::ReportDataAbilityAcquired(const sptr &client, bool isNotHap, - std::shared_ptr &record) -{ -} - -void DataAbilityManager::ReportDataAbilityReleased(const sptr &client, bool isNotHap, - std::shared_ptr &record) -{ -} -} // namespace AAFwk -} // namespace OHOS diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ecological_rule_interceptor.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ecological_rule_interceptor.cpp deleted file mode 100644 index bdefa2b7103..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ecological_rule_interceptor.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mock_ecological_rule_interceptor.h" -#include "mock_my_status.h" - -namespace OHOS { -namespace AAFwk { - -ErrCode EcologicalRuleInterceptor::DoProcess(AbilityInterceptorParam param) -{ - return ERR_OK; -} - -bool EcologicalRuleInterceptor::DoProcess(Want &want, int32_t userId) -{ - return true; -} - -ErrCode EcologicalRuleInterceptor::QueryAtomicServiceStartupRule(Want &want, sptr callerToken, - int32_t userId, AtomicServiceStartupRule &rule, sptr &replaceWant) -{ - return MyStatus::GetInstance().eriQueryAtomicServiceStartupRule_; -} - -void EcologicalRuleInterceptor::GetEcologicalTargetInfo(const Want &want, - const std::shared_ptr &abilityInfo, ErmsCallerInfo &callerInfo) -{ -} - -void EcologicalRuleInterceptor::GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId, - const sptr &callerToken) -{ -} - -void EcologicalRuleInterceptor::InitErmsCallerInfo(const Want &want, - const std::shared_ptr &abilityInfo, - ErmsCallerInfo &callerInfo, int32_t userId, const sptr &callerToken) -{ -} - -int32_t EcologicalRuleInterceptor::GetAppTypeByBundleType(int32_t bundleType) -{ - return 0; -} -} // namespace AAFwk -} // namespace OHOS diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_free_install_manager.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_free_install_manager.cpp deleted file mode 100644 index e093ca048ea..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_free_install_manager.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mock_free_install_manager.h" -#include "mock_my_status.h" - -namespace OHOS { -namespace AAFwk { -FreeInstallManager::FreeInstallManager(const std::weak_ptr &server) - : server_(server) -{ -} - -bool FreeInstallManager::IsTopAbility(const sptr &callerToken) -{ - return true; -} - -int FreeInstallManager::StartFreeInstall(const Want &want, int32_t userId, int requestCode, - const sptr &callerToken, std::shared_ptr param) -{ - return MyStatus::GetInstance().fimStartFreeInstall_; -} - -int FreeInstallManager::RemoteFreeInstall(const Want &want, int32_t userId, int requestCode, - const sptr &callerToken) -{ - return NOT_TOP_ABILITY; -} - -FreeInstallInfo FreeInstallManager::BuildFreeInstallInfo(const Want &want, int32_t userId, int requestCode, - const sptr &callerToken, std::shared_ptr param) -{ - FreeInstallInfo info = {}; - return info; -} - -int FreeInstallManager::StartRemoteFreeInstall(const Want &want, int requestCode, int32_t validUserId, - const sptr &callerToken) -{ - return 0; -} - -int FreeInstallManager::NotifyDmsCallback(const Want &want, int resultCode) -{ - return ERR_OK; -} - -void FreeInstallManager::NotifyFreeInstallResult(int32_t recordId, const Want &want, int resultCode, bool isAsync) -{ -} - -void FreeInstallManager::HandleOnFreeInstallSuccess(int32_t recordId, FreeInstallInfo &freeInstallInfo, bool isAsync) -{ -} - -void FreeInstallManager::HandleOnFreeInstallFail(int32_t recordId, FreeInstallInfo &freeInstallInfo, int resultCode, - bool isAsync) -{ -} - -void FreeInstallManager::HandleFreeInstallResult(int32_t recordId, FreeInstallInfo &freeInstallInfo, int resultCode, - bool isAsync) -{ -} - -void FreeInstallManager::StartAbilityByFreeInstall(FreeInstallInfo &info, std::string &bundleName, - std::string &abilityName, std::string &startTime) -{ -} - -void FreeInstallManager::StartAbilityByPreInstall(int32_t recordId, FreeInstallInfo &info, std::string &bundleName, - std::string &abilityName, std::string &startTime) -{ -} - -void FreeInstallManager::StartAbilityByConvertedWant(FreeInstallInfo &info, const std::string &startTime) -{ -} - -void FreeInstallManager::StartAbilityByOriginalWant(FreeInstallInfo &info, const std::string &startTime) -{ -} - -int32_t FreeInstallManager::UpdateElementName(Want &want, int32_t userId) const -{ - return ERR_OK; -} - -int FreeInstallManager::FreeInstallAbilityFromRemote(const Want &want, const sptr &callback, - int32_t userId, int requestCode) -{ - return ERR_OK; -} - -int FreeInstallManager::ConnectFreeInstall(const Want &want, int32_t userId, - const sptr &callerToken, const std::string& localDeviceId) -{ - return ERR_OK; -} - -std::time_t FreeInstallManager::GetTimeStamp() -{ - std::chrono::time_point tp = - std::chrono::time_point_cast(std::chrono::system_clock::now()); - std::time_t timestamp = tp.time_since_epoch().count(); - return timestamp; -} - -void FreeInstallManager::OnInstallFinished(int32_t recordId, int resultCode, const Want &want, - int32_t userId, bool isAsync) -{ -} - -void FreeInstallManager::PostUpgradeAtomicServiceTask(int resultCode, const Want &want, int32_t userId) -{ -} - -void FreeInstallManager::OnRemoteInstallFinished(int32_t recordId, int resultCode, const Want &want, int32_t userId) -{ -} - -int FreeInstallManager::AddFreeInstallObserver(const sptr &callerToken, - const sptr &observer) -{ - return CHECK_PERMISSION_FAILED; -} - -void FreeInstallManager::RemoveFreeInstallInfo(const std::string &bundleName, const std::string &abilityName, - const std::string &startTime) -{ -} - -bool FreeInstallManager::VerifyStartFreeInstallPermission(const sptr &callerToken) -{ - return true; -} - -int32_t FreeInstallManager::GetRecordIdByToken(const sptr &callerToken) -{ - return 0; -} - -int FreeInstallManager::SetAppRunningState(Want &want) -{ - return ERR_OK; -} - -bool FreeInstallManager::GetFreeInstallTaskInfo(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, FreeInstallInfo& taskInfo) -{ - return false; -} - -bool FreeInstallManager::GetFreeInstallTaskInfo(const std::string& sessionId, FreeInstallInfo& taskInfo) -{ - return false; -} - -void FreeInstallManager::SetSCBCallStatus(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, bool scbCallStatus) -{ -} - -void FreeInstallManager::SetPreStartMissionCallStatus(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, bool preStartMissionCallStatus) -{ -} - -void FreeInstallManager::SetFreeInstallTaskSessionId(const std::string& bundleName, const std::string& abilityName, - const std::string& startTime, const std::string& sessionId) -{ -} - -void FreeInstallManager::NotifyInsightIntentFreeInstallResult(const Want &want, int resultCode) -{ -} - -void FreeInstallManager::NotifyInsightIntentExecuteDone(const Want &want, int resultCode) -{ -} -} // namespace AAFwk -} // namespace OHOS diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ipc_skeleton.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ipc_skeleton.cpp deleted file mode 100644 index 1c6f9ccd1d1..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_ipc_skeleton.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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" -#include "mock_my_status.h" - -namespace OHOS { -#ifdef CONFIG_IPC_SINGLE -using namespace IPC_SINGLE; -#endif - -pid_t IPCSkeleton::GetCallingUid() -{ - return static_cast(AAFwk::MyStatus::GetInstance().ipcGetCallingUid_); -} - -pid_t IPCSkeleton::GetCallingPid() -{ - return static_cast(AAFwk::MyStatus::GetInstance().ipcGetCallingUid_); -} - -uint32_t IPCSkeleton::GetCallingTokenID() -{ - return AAFwk::MyStatus::GetInstance().ipcGetCallingTokenID_; -} - -uint32_t IPCSkeleton::GetSelfTokenID() -{ - return AAFwk::MyStatus::GetInstance().ipcGetSelfTokenID_; -} - -bool IPCSkeleton::SetCallingIdentity(std::string &identity, bool status) -{ - return true; -} - -uint64_t IPCSkeleton::GetCallingFullTokenID() -{ - return 1; -} - -} // namespace OHOS diff --git a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_parameters.cpp b/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_parameters.cpp deleted file mode 100644 index 5e508e50eb9..00000000000 --- a/test/unittest/ability_manager_service_fourteenth_test/mock/src/mock_parameters.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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_parameters.h" -#include "mock_my_status.h" - -namespace OHOS { -namespace system { - -void SetBoolParameter(const std::string& key, bool def) -{ -} - -bool GetBoolParameter(const std::string& key, bool def) -{ - return AAFwk::MyStatus::GetInstance().paramGetBoolParameter_; -} -} // namespace system -} // namespace OHOS \ No newline at end of file -- Gitee