diff --git a/common/utils/include/bundle_memory_guard.h b/common/utils/include/bundle_memory_guard.h index 6bc57dab1d4958f96ae1f430039b48891d30aed4..83a4e685533a1fdd8e0a56efe2c9f2b6023d8e23 100644 --- a/common/utils/include/bundle_memory_guard.h +++ b/common/utils/include/bundle_memory_guard.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,6 +21,8 @@ class BundleMemoryGuard final { public: BundleMemoryGuard(); ~BundleMemoryGuard(); + static void SetBundleMemoryGuard(); + static void ClearBundleMemoryGuard(); }; } // AppExecFwk } // OHOS diff --git a/common/utils/src/bundle_memory_guard.cpp b/common/utils/src/bundle_memory_guard.cpp index 833558dd12f64018fc1d30fbbbed885390e73743..81910549b15d2a17b3e113244b12d59350bec445 100644 --- a/common/utils/src/bundle_memory_guard.cpp +++ b/common/utils/src/bundle_memory_guard.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -37,5 +37,22 @@ BundleMemoryGuard::~BundleMemoryGuard() APP_LOGD("flush cache, result: %{public}d", err); #endif } +void BundleMemoryGuard::SetBundleMemoryGuard() +{ +#ifdef CONFIG_USE_JEMALLOC_DFX_INTF + // 0 indicates success + int32_t thread_cache_ret = mallopt(M_SET_THREAD_CACHE, M_THREAD_CACHE_DISABLE); + int32_t delay_free_ret = mallopt(M_DELAYED_FREE, M_DELAYED_FREE_DISABLE); + APP_LOGD("disable tcache and delay free, result:%{public}d, %{public}d", thread_cache_ret, delay_free_ret); +#endif +} + +void BundleMemoryGuard::ClearBundleMemoryGuard() +{ +#ifdef CONFIG_USE_JEMALLOC_DFX_INTF + int32_t flush_ret = mallopt(M_FLUSH_THREAD_CACHE, 0); + APP_LOGD("flush cache, result: %{public}d", flush_ret); +#endif +} } // AppExecFwk } // OHOS diff --git a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h index 62f8bae1aaf6b5444167845599a8c7a98649397c..9203a55c84b9236dccaea13bd3823b0b13bb34c6 100644 --- a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h +++ b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h @@ -626,6 +626,9 @@ enum { // ark startup cache ERR_APPEXECFWK_ARK_STARTUP_CACHE_ONLY_ALLOW_CREATE_APP_OR_ATOMIC = 8522591, ERR_APPEXECFWK_ARK_STARTUP_CACHE_ONLY_ALLOW_CREATE_IN_WHITE_LIST = 8522592, + + // IDL + ERR_APPEXECFWK_IDL_GET_RESULT_ERROR = 8522610, }; // Error code for Hidump diff --git a/interfaces/inner_api/appexecfwk_core/BUILD.gn b/interfaces/inner_api/appexecfwk_core/BUILD.gn index 161b580d852c8b5bdadd63dead08560d97a13fd7..784fa0d65773768f6ac93abe58d70e9c36933bab 100644 --- a/interfaces/inner_api/appexecfwk_core/BUILD.gn +++ b/interfaces/inner_api/appexecfwk_core/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,9 +11,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/config/components/idl_tool/idl.gni") import("//build/ohos.gni") import("../../../appexecfwk.gni") +idl_gen_interface("app_control_mgr_interface") { + sources = [ "IAppControlMgr.idl" ] + # log_domainid = "0xD001120" + # log_tag = "BMS" + sources_common = [ "IAppControlMgrTypes.idl" ] + subsystem_name = "bundlemanager" + part_name = "bundle_framework" +} + +config("bundlemgr_ipc_public_config") { + include_dirs = [ "${target_gen_dir}" ] +} + config("bundlemgr_sdk_config") { include_dirs = [ "include", @@ -22,10 +36,12 @@ config("bundlemgr_sdk_config") { "include/bundlemgr", "include/default_app", "include/extend_resource", + "include/ipc", "include/overlay", "include/quick_fix", "include/verify", "include/bundlemgr_ext", + "${target_gen_dir}", ] } @@ -138,10 +154,17 @@ ohos_shared_library("appexecfwk_core") { if (bundle_framework_app_control) { defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ] - sources += [ - "src/app_control/app_control_host.cpp", - "src/app_control/app_control_proxy.cpp", + output_values = get_target_outputs(":app_control_mgr_interface") + sources += filter_include(output_values, + [ + "*app_control_mgr_proxy.cpp", + "*app_control_mgr_stub.cpp", + ]) + sources += [ + "src/app_control/app_control_client.cpp", + "src/ipc/bundle_mgr_raw_data.cpp", ] + deps += [ ":app_control_mgr_interface" ] } if (bundle_framework_quick_fix) { @@ -225,6 +248,7 @@ ohos_shared_library("bundlemgr_mini") { deps = [ "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", + ":app_control_mgr_interface", ] external_deps = [ @@ -249,3 +273,87 @@ ohos_shared_library("bundlemgr_mini") { ] part_name = "bundle_framework" } + +ohos_source_set("app_control_mgr_proxy") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } + configs = [ + ":bundlemgr_sdk_config", + ":bundlemgr_ipc_public_config" + ] + cflags = [ + "-Os", + "-fstack-protector-strong", + ] + + cflags_cc = [ + "-Os", + "-fstack-protector-strong", + ] + + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + output_values = get_target_outputs(":app_control_mgr_interface") + sources = filter_include(output_values, [ "*app_control_mgr_proxy.cpp" ]) + deps = [ + ":app_control_mgr_interface", + "${base_path}:appexecfwk_base", + ] + external_deps = [ + "ability_base:want", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_single", + ] + subsystem_name = "bundlemanager" + part_name = "bundle_framework" +} + +ohos_source_set("app_control_mgr_stub") { + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + integer_overflow = true + ubsan = true + } + configs = [ + ":bundlemgr_sdk_config", + ":bundlemgr_ipc_public_config" + ] + cflags = [ + "-Os", + "-fstack-protector-strong", + ] + + cflags_cc = [ + "-Os", + "-fstack-protector-strong", + ] + + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + output_values = get_target_outputs(":app_control_mgr_interface") + sources = filter_include(output_values, [ "*app_control_mgr_stub.cpp" ]) + deps = [ + ":app_control_mgr_interface", + "${base_path}:appexecfwk_base", + ] + external_deps = [ + "ability_base:want", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_single", + ] + subsystem_name = "bundlemanager" + part_name = "bundle_framework" +} \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/IAppControlMgr.idl b/interfaces/inner_api/appexecfwk_core/IAppControlMgr.idl new file mode 100644 index 0000000000000000000000000000000000000000..9a8dd215ffbebdd8aa8ac81b634335d4ab50dd1c --- /dev/null +++ b/interfaces/inner_api/appexecfwk_core/IAppControlMgr.idl @@ -0,0 +1,60 @@ +/* + * 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. + */ + +package OHOS.AppExecFwk; + +import IAppControlMgrTypes; + +sequenceable OHOS.AAFwk.Want; +sequenceable OHOS.AppExecFwk.AppJumpControlRule; +sequenceable OHOS.AppExecFwk.AppRunningControlRule; +sequenceable OHOS.AppExecFwk.AppRunningControlRuleResult; +sequenceable OHOS.AppExecFwk.DisposedRule; +sequenceable DisposedRule..OHOS.AppExecFwk.UninstallDisposedRule; +sequenceable DisposedRule..OHOS.AppExecFwk.DisposedRuleConfiguration; +rawdata Ipc.BundleMgrRawData..OHOS.AppExecFwk.BundleMgrRawData; +option_stub_hooks on; +interface_token ohos.bundleManager.appControl; + +interface OHOS.AppExecFwk.IAppControlMgr { + [ipccode 0] void AddAppInstallControlRule([in] String[] appIds, [in] AppInstallControlRuleType controlRuleType, [in] int userId, [out] int funcResult); + [ipccode 1] void DeleteAppInstallControlRule([in] AppInstallControlRuleType controlRuleType, [in] String[] appIds, [in] int userId, [out] int funcResult); + [ipccode 2] void DeleteAppInstallControlRule([in] AppInstallControlRuleType controlRuleType, [in] int userId, [out] int funcResult); + [ipccode 3] void GetAppInstallControlRule([in] AppInstallControlRuleType controlRuleType, [in] int userId, [out] String[] appIds, [out] int funcResult); + [ipccode 4] void AddAppRunningControlRule([in] AppRunningControlRule[] controlRules, [in] int userId, [out] int funcResult); + [ipccode 5] void DeleteAppRunningControlRule([in] AppRunningControlRule[] controlRules, [in] int userId, [out] int funcResult); + [ipccode 6] void DeleteAppRunningControlRule([in] int userId, [out] int funcResult); + [ipccode 7] void GetAppRunningControlRule([in] int userId, [out] String[] appIds, [out] int funcResult); + [ipccode 8] void GetAppRunningControlRule([in] String bundleName, [in] int userId, [out] AppRunningControlRuleResult controlRuleResult, [out] int funcResult); + [ipccode 9] void SetDisposedStatus([in] String appId, [in] Want want, [in] int userId, [out] int funcResult); + [ipccode 10] void DeleteDisposedStatus([in] String appId, [in] int userId, [out] int funcResult); + [ipccode 11] void GetDisposedStatus([in] String appId, [in] int userId, [out] Want want, [out] int funcResult); + [ipccode 12] void ConfirmAppJumpControlRule([in] String callerBundleName, [in] String targetBundleName, [in] int userId, [out] int funcResult); + [ipccode 13] void AddAppJumpControlRule([in] AppJumpControlRule[] controlRules, [in] int userId, [out] int funcResult); + [ipccode 14] void DeleteAppJumpControlRule([in] AppJumpControlRule[] controlRules, [in] int userId, [out] int funcResult); + [ipccode 15] void DeleteRuleByCallerBundleName([in] String callerBundleName, [in] int userId, [out] int funcResult); + [ipccode 16] void DeleteRuleByTargetBundleName([in] String targetBundleName, [in] int userId, [out] int funcResult); + [ipccode 17] void GetAppJumpControlRule([in] String callerBundleName, [in] String targetBundleName, [in] int userId, [out] AppJumpControlRule controlRule, [out] int funcResult); + [ipccode 18] void GetDisposedRule([in] String appId, [in] int userId, [out] DisposedRule disposedRule, [out] int funcResult); + [ipccode 19] void SetDisposedRule([in] String appId, [in] int userId, [out] DisposedRule disposedRule, [out] int funcResult); + [ipccode 20] void GetAbilityRunningControlRule([in] String bundleName, [in] int userId, [in] int appIndex, [out] DisposedRule[] disposedRules, [out] int funcResult); + [ipccode 21] void GetDisposedRuleForCloneApp([in] String appId, [in] int appIndex, [in] int userId, [out] DisposedRule disposedRule, [out] int funcResult); + [ipccode 22] void SetDisposedRuleForCloneApp([in] String appId, [in] int appIndex, [in] int userId, [out] DisposedRule disposedRule, [out] int funcResult); + [ipccode 23] void DeleteDisposedRuleForCloneApp([in] String appId, [in] int appIndex, [in] int userId, [out] int funcResult); + [ipccode 24] void GetUninstallDisposedRule([in] String appIdentifier, [in] int appIndex, [in] int userId, [out] UninstallDisposedRule rule, [out] int funcResult); + [ipccode 25] void SetUninstallDisposedRule([in] String appIdentifier, [in] UninstallDisposedRule rule, [in] int appIndex, [in] int userId, [out] int funcResult); + [ipccode 26] void DeleteUninstallDisposedRule([in] String appIdentifier, [in] int appIndex, [in] int userId, [out] int funcResult); + [ipccode 27] void SetDisposedRules([in] int userId, [out] BundleMgrRawData disposedRuleConfigurationsRawData, [out] int funcResult); +} diff --git a/interfaces/inner_api/appexecfwk_core/IAppControlMgrTypes.idl b/interfaces/inner_api/appexecfwk_core/IAppControlMgrTypes.idl new file mode 100644 index 0000000000000000000000000000000000000000..18b5d4a896eb6b71d4f25bc51c8b73e479fab292 --- /dev/null +++ b/interfaces/inner_api/appexecfwk_core/IAppControlMgrTypes.idl @@ -0,0 +1,27 @@ +/* + * 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. + */ + +package OHOS.AppExecFwk; + +enum AppInstallControlRuleType { + UNSPECIFIED = 0, + DISALLOWED_UNINSTALL, + ALLOWED_INSTALL, + DISALLOWED_INSTALL, +}; + +enum AppRunControlRuleType { + DISALLOWED_RUN = 10, +}; \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_client.h b/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_client.h new file mode 100644 index 0000000000000000000000000000000000000000..6727159c962024bafc8a3fea646c3c5e6a607f99 --- /dev/null +++ b/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_client.h @@ -0,0 +1,108 @@ +/* + * 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_CLIENT_H +#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_CLIENT_H + +#include +#include +#include + +#include "appexecfwk_errors.h" +#include "bundle_constants.h" +#include "iapp_control_mgr.h" + +namespace OHOS { +namespace AppExecFwk { +class AppControlClient { +public: + static AppControlClient &GetInstance(); + + // for app install control rule + ErrCode AddAppInstallControlRule(const std::vector &appIds, + const AppInstallControlRuleType controlRuleType, int32_t userId); + ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, + const std::vector &appIds, int32_t userId); + ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId); + ErrCode GetAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId, + std::vector &appIds); + // for app running control rule + ErrCode AddAppRunningControlRule(const std::vector &controlRule, int32_t userId); + ErrCode DeleteAppRunningControlRule(const std::vector &controlRule, int32_t userId); + ErrCode DeleteAppRunningControlRule(int32_t userId); + ErrCode GetAppRunningControlRule(int32_t userId, std::vector &appIds); + ErrCode GetAppRunningControlRule(const std::string &bundleName, int32_t userId, + AppRunningControlRuleResult &controlRuleResult); + + // for app jump control rule + ErrCode ConfirmAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, + int32_t userId); + ErrCode AddAppJumpControlRule(const std::vector &controlRules, int32_t userId); + ErrCode DeleteAppJumpControlRule(const std::vector &controlRules, int32_t userId); + ErrCode DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId); + ErrCode DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId); + ErrCode GetAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, + int32_t userId, AppJumpControlRule &controlRule); + + ErrCode SetDisposedStatus(const std::string &appId, const Want &want, + int32_t userId = Constants::UNSPECIFIED_USERID); + ErrCode DeleteDisposedStatus(const std::string &appId, int32_t userId = Constants::UNSPECIFIED_USERID); + ErrCode GetDisposedStatus(const std::string &appId, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID); + ErrCode GetDisposedRule(const std::string &appId, DisposedRule& disposedRule, + int32_t userId = Constants::UNSPECIFIED_USERID); + ErrCode SetDisposedRule(const std::string &appId, DisposedRule& disposedRule, + int32_t userId = Constants::UNSPECIFIED_USERID); + ErrCode SetDisposedRules(std::vector &disposedRuleConfigurations, int32_t userId); + ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, + std::vector &disposedRules, int32_t appIndex = Constants::MAIN_APP_INDEX); + ErrCode GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule, int32_t appIndex, + int32_t userId = Constants::UNSPECIFIED_USERID); + ErrCode SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule, int32_t appIndex, + int32_t userId = Constants::UNSPECIFIED_USERID); + ErrCode DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, + int32_t userId = Constants::UNSPECIFIED_USERID); + + ErrCode SetUninstallDisposedRule(const std::string &appIdentifier, const UninstallDisposedRule &disposedRule, + int32_t appIndex, int32_t userId); + ErrCode GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, int32_t userId, + UninstallDisposedRule &rule); + ErrCode DeleteUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, int32_t userId); + +private: + class AppControlDeathRecipient : public IRemoteObject::DeathRecipient { + public: + AppControlDeathRecipient() = default; + ~AppControlDeathRecipient() override = default; + void OnRemoteDied(const wptr& remote) override; + + private: + DISALLOW_COPY_AND_MOVE(AppControlDeathRecipient); + }; + sptr GetAppControlProxy(); + void ResetAppControlProxy(const wptr &remote); + ErrCode ConvertResultToErrCode(ErrCode res, int32_t funcResult); + template + ErrCode WriteVectorToParcel(std::vector &parcelVector, MessageParcel &tempParcel); + + AppControlClient() = default; + ~AppControlClient() = default; + DISALLOW_COPY_AND_MOVE(AppControlClient); + std::mutex mutex_; + sptr appControlMgrProxy_; + sptr deathRecipient_; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_CLIENT_H \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_host.h b/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_host.h deleted file mode 100644 index 648cb4b6e44b2df32baab9f361fdfbac5951ff47..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_host.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_HOST_H -#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_HOST_H - - -#include "app_control_interface.h" -#include "iremote_stub.h" -#include "nocopyable.h" - -namespace OHOS { -namespace AppExecFwk { -class AppControlHost : public IRemoteStub { -public: - AppControlHost(); - virtual ~AppControlHost(); - - int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - -private: - template - ErrCode ReadParcelableVector(MessageParcel &data, std::vector &parcelableInfos); - bool WriteStringVector(const std::vector &stringVector, MessageParcel &reply); - template - bool WriteParcelableVector(std::vector &parcelableVector, MessageParcel &reply); - ErrCode HandleAddAppInstallControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteAppInstallControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleCleanAppInstallControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetAppInstallControlRule(MessageParcel& data, MessageParcel& reply); - - ErrCode HandleAddAppRunningControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteAppRunningControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleCleanAppRunningControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetAppRunningControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetAppRunningControlRuleResult(MessageParcel& data, MessageParcel& reply); - - ErrCode HandleConfirmAppJumpControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleAddAppJumpControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteAppJumpControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteRuleByCallerBundleName(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteRuleByTargetBundleName(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetAppJumpControlRule(MessageParcel& data, MessageParcel& reply); - - ErrCode HandleGetDisposedStatus(MessageParcel& data, MessageParcel& reply); - ErrCode HandleSetDisposedStatus(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteDisposedStatus(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetDisposedRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleSetDisposedRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleSetDisposedRules(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetAbilityRunningControlRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleGetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply); - ErrCode HandleSetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply); - - ErrCode HandleGetUninstallDisposedRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleSetUninstallDisposedRule(MessageParcel& data, MessageParcel& reply); - ErrCode HandleDeleteUninstallDisposedRule(MessageParcel& data, MessageParcel& reply); - - DISALLOW_COPY_AND_MOVE(AppControlHost); - template - ErrCode GetVectorParcelInfo(MessageParcel &data, std::vector &parcelInfos); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_HOST_H diff --git a/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_interface.h b/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_interface.h deleted file mode 100644 index 5f7cb2f8f3fb67aeb1f2c8a398394a066a695101..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_interface.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_I_APP_CONTROL_MGR_H -#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_I_APP_CONTROL_MGR_H - -#include -#include - -#include "appexecfwk_errors.h" -#include "app_jump_control_rule.h" -#include "app_running_control_rule_result.h" -#include "app_running_control_rule.h" -#include "bundle_constants.h" -#include "disposed_rule.h" -#include "iremote_broker.h" -#include "want.h" - -namespace OHOS { -namespace AppExecFwk { -enum class AppInstallControlRuleType : int8_t { - UNSPECIFIED = 0, - DISALLOWED_UNINSTALL, - ALLOWED_INSTALL, - DISALLOWED_INSTALL, -}; - -enum class AppRunControlRuleType : int8_t { - DISALLOWED_RUN = 10, -}; - -class IAppControlMgr : public IRemoteBroker { -public: - using Want = OHOS::AAFwk::Want; - - DECLARE_INTERFACE_DESCRIPTOR(u"ohos.bundleManager.appControl"); - - virtual ErrCode AddAppInstallControlRule(const std::vector &appIds, - const AppInstallControlRuleType controlRuleType, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, - const std::vector &appIds, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetAppInstallControlRule( - const AppInstallControlRuleType controlRuleType, int32_t userId, std::vector &appIds) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode AddAppRunningControlRule( - const std::vector &controlRules, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteAppRunningControlRule( - const std::vector &controlRules, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteAppRunningControlRule(int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetAppRunningControlRule(int32_t userId, std::vector &appIds) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetAppRunningControlRule( - const std::string &bundleName, int32_t userId, AppRunningControlRuleResult &controlRuleResult) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode ConfirmAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, - int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode AddAppJumpControlRule(const std::vector &controlRules, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteAppJumpControlRule(const std::vector &controlRules, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, - int32_t userId, AppJumpControlRule &controlRule) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode SetDisposedStatus( - const std::string &appId, const Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteDisposedStatus(const std::string &appId, int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetDisposedStatus( - const std::string &appId, Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetDisposedRule( - const std::string &appId, DisposedRule& disposedRule, int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode SetDisposedRule( - const std::string &appId, DisposedRule& disposedRule, int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode SetDisposedRules(std::vector &disposedRuleConfigurations, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, - std::vector& disposedRules, int32_t appIndex = Constants::MAIN_APP_INDEX) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule, - int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule, - int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, - int32_t userId = Constants::UNSPECIFIED_USERID) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, - int32_t userId, UninstallDisposedRule &rule) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode SetUninstallDisposedRule(const std::string &appIdentifier, const UninstallDisposedRule &rule, - int32_t appIndex, int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } - virtual ErrCode DeleteUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, - int32_t userId) - { - return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; - } -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_I_APP_CONTROL_MGR_H diff --git a/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_proxy.h b/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_proxy.h deleted file mode 100644 index 997765c4f26c6ed7f1b67f1be89d233af79f41a2..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/appexecfwk_core/include/app_control/app_control_proxy.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_PROXY_H -#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_PROXY_H - -#include "app_control_interface.h" -#include "bundle_framework_core_ipc_interface_code.h" -#include "iremote_proxy.h" - -namespace OHOS { -namespace AppExecFwk { -class AppControlProxy : public IRemoteProxy { -public: - explicit AppControlProxy(const sptr& object); - virtual ~AppControlProxy(); - // for app install control rule - virtual ErrCode AddAppInstallControlRule(const std::vector &appIds, - const AppInstallControlRuleType controlRuleType, int32_t userId) override; - virtual ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, - const std::vector &appIds, int32_t userId) override; - virtual ErrCode DeleteAppInstallControlRule( - const AppInstallControlRuleType controlRuleType, int32_t userId) override; - virtual ErrCode GetAppInstallControlRule( - const AppInstallControlRuleType controlRuleType, int32_t userId, std::vector &appIds) override; - // for app running control rule - virtual ErrCode AddAppRunningControlRule( - const std::vector &controlRule, int32_t userId) override; - virtual ErrCode DeleteAppRunningControlRule( - const std::vector &controlRule, int32_t userId) override; - virtual ErrCode DeleteAppRunningControlRule(int32_t userId) override; - virtual ErrCode GetAppRunningControlRule(int32_t userId, std::vector &appIds) override; - virtual ErrCode GetAppRunningControlRule( - const std::string &bundleName, int32_t userId, AppRunningControlRuleResult &controlRuleResult) override; - - // for app jump control rule - virtual ErrCode ConfirmAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, - int32_t userId) override; - virtual ErrCode AddAppJumpControlRule(const std::vector &controlRules, int32_t userId) override; - virtual ErrCode DeleteAppJumpControlRule(const std::vector &controlRules, - int32_t userId) override; - virtual ErrCode DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId) override; - virtual ErrCode DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId) override; - virtual ErrCode GetAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, - int32_t userId, AppJumpControlRule &controlRule) override; - - virtual ErrCode SetDisposedStatus( - const std::string &appId, const Want &want, int32_t userId = Constants::UNSPECIFIED_USERID) override; - virtual ErrCode DeleteDisposedStatus( - const std::string &appId, int32_t userId = Constants::UNSPECIFIED_USERID) override; - virtual ErrCode GetDisposedStatus(const std::string &appId, Want &want, - int32_t userId = Constants::UNSPECIFIED_USERID) override; - virtual ErrCode GetDisposedRule(const std::string &appId, - DisposedRule& disposedRule, int32_t userId = Constants::UNSPECIFIED_USERID) override; - virtual ErrCode SetDisposedRules(std::vector &disposedRuleConfigurations, - int32_t userId) override; - virtual ErrCode SetDisposedRule(const std::string &appId, - DisposedRule& disposedRule, int32_t userId = Constants::UNSPECIFIED_USERID) override; - virtual ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, - std::vector& disposedRules, int32_t appIndex = Constants::MAIN_APP_INDEX) override; - virtual ErrCode GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule, - int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) override; - virtual ErrCode SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule, - int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) override; - virtual ErrCode DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, - int32_t userId = Constants::UNSPECIFIED_USERID) override; - - virtual ErrCode SetUninstallDisposedRule(const std::string &appIdentifier, - const UninstallDisposedRule &disposedRule, int32_t appIndex, int32_t userId) override; - virtual ErrCode GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, - int32_t userId, UninstallDisposedRule &rule) override; - virtual ErrCode DeleteUninstallDisposedRule(const std::string &appIdentifier, - int32_t appIndex, int32_t userId) override; - -private: - bool WriteParcelableVector(const std::vector &stringVector, MessageParcel &data); - template - ErrCode GetParcelableInfo(AppControlManagerInterfaceCode code, MessageParcel& data, T& parcelableInfo); - template - bool WriteParcelableVector(const std::vector &parcelableVector, MessageParcel &data); - bool WriteStringVector(const std::vector &stringVector, MessageParcel &data); - int32_t GetParcelableInfos( - AppControlManagerInterfaceCode code, MessageParcel &data, std::vector &stringVector); - int32_t SendRequest(AppControlManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply); - template - ErrCode GetParcelableInfosWithErrCode(AppControlManagerInterfaceCode code, MessageParcel &data, - std::vector &parcelableInfos); - static inline BrokerDelegator delegator_; - template - ErrCode WriteVectorToParcel(std::vector &parcelVector, MessageParcel &reply); -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_APP_CONTROL_PROXY_H \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h b/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h index 6505aed18c20eba8d48818f3ce2949ff0ec667e0..72a03d1a2986e951f3515b424dcbab16cdf82c95 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h @@ -223,38 +223,6 @@ enum class BundleMgrInterfaceCode : uint32_t { GET_SHORTCUT_INFO_BY_APPINDEX = 197, }; -/* SAID: 401-85 Interface No.85 subservice also provides the following interfaces */ -enum class AppControlManagerInterfaceCode : uint8_t { - ADD_APP_INSTALL_CONTROL_RULE = 0, - DELETE_APP_INSTALL_CONTROL_RULE = 1, - CLEAN_APP_INSTALL_CONTROL_RULE = 2, - GET_APP_INSTALL_CONTROL_RULE = 3, - ADD_APP_RUNNING_CONTROL_RULE = 4, - DELETE_APP_RUNNING_CONTROL_RULE = 5, - CLEAN_APP_RUNNING_CONTROL_RULE = 6, - GET_APP_RUNNING_CONTROL_RULE = 7, - GET_APP_RUNNING_CONTROL_RULE_RESULT = 8, - SET_DISPOSED_STATUS = 9, - DELETE_DISPOSED_STATUS = 10, - GET_DISPOSED_STATUS = 11, - CONFIRM_APP_JUMP_CONTROL_RULE = 12, - ADD_APP_JUMP_CONTROL_RULE = 13, - DELETE_APP_JUMP_CONTROL_RULE = 14, - DELETE_APP_JUMP_CONTROL_RULE_BY_CALLER = 15, - DELETE_APP_JUMP_CONTROL_RULE_BY_TARGET = 16, - GET_APP_JUMP_CONTROL_RULE = 17, - SET_DISPOSED_RULE = 18, - GET_DISPOSED_RULE = 19, - GET_ABILITY_RUNNING_CONTROL_RULE = 20, - GET_DISPOSED_RULE_FOR_CLONE_APP = 21, - SET_DISPOSED_RULE_FOR_CLONE_APP = 22, - DELETE_DISPOSED_RULE_FOR_CLONE_APP = 23, - SET_UNINSTALL_DISPOSED_RULE = 24, - GET_UNINSTALL_DISPOSED_RULE = 25, - DELETE_UNINSTALL_DISPOSED_RULE = 26, - SET_DISPOSED_RULES = 27, -}; - /* SAID: 401-96 Interface No.96 subservice also provides the following interfaces */ enum class BundleEventCallbackInterfaceCode : uint8_t { ON_RECEIVE_EVENT = 0, diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h index 9fb263296e76bcf59a64078ea3bddc39e7503ab8..25d481725929f6c0968757d65c03f1f28674062c 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h @@ -35,7 +35,7 @@ #include "clean_cache_callback_interface.h" #include "common_event_info.h" #include "data_group_info.h" -#include "app_control_interface.h" +#include "iapp_control_mgr.h" #include "bundle_resource_interface.h" #include "default_app_interface.h" #include "extend_resource_manager_interface.h" diff --git a/interfaces/inner_api/appexecfwk_core/include/ipc/bundle_mgr_raw_data.h b/interfaces/inner_api/appexecfwk_core/include/ipc/bundle_mgr_raw_data.h new file mode 100644 index 0000000000000000000000000000000000000000..cf76e6a77325dee084d0eabf37af52d580ebaf27 --- /dev/null +++ b/interfaces/inner_api/appexecfwk_core/include/ipc/bundle_mgr_raw_data.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_BUNDLE_MGR_RAW_DATA_H +#define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_BUNDLE_MGR_RAW_DATA_H + +#include + +namespace OHOS { +namespace AppExecFwk { +class BundleMgrRawData { +public: + std::string ownedData; + uint32_t size = 0; + const void* data = nullptr; + bool isMalloc = false; + + int32_t RawDataCpy(const void* readdata); + ~BundleMgrRawData(); +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_IPC_BUNDLE_MGR_RAW_DATA_H \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_client.cpp b/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_client.cpp new file mode 100644 index 0000000000000000000000000000000000000000..836af8d6f00f0ac4ce3bb23292d371fb19452ec1 --- /dev/null +++ b/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_client.cpp @@ -0,0 +1,666 @@ +/* + * 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_control_client.h" +#include "app_control_constants.h" +#include "app_log_wrapper.h" +#include "app_log_tag_wrapper.h" +#include "bundle_mgr_proxy.h" +#include "ipc/bundle_mgr_raw_data.h" +#include "iservice_registry.h" +#include "system_ability_definition.h" + +namespace OHOS { +namespace AppExecFwk { +namespace { +const int16_t MAX_VECTOR_NUM = 1000; +constexpr size_t MAX_IPC_ALLOWED_CAPACITY = 100 * 1024 * 1024; // max ipc size 100MB +} + +AppControlClient &AppControlClient::GetInstance() +{ + static AppControlClient instance; + return instance; +} + +ErrCode AppControlClient::ConvertResultToErrCode(ErrCode res, int32_t funcResult) +{ + if (res != ERR_OK) { + LOG_E(BMS_TAG_DEFAULT, "ipc failed, errCode is %{public}d", res); + } + switch (res) { + case ERR_INVALID_VALUE: + return ERR_APPEXECFWK_PARCEL_ERROR; + case ERR_INVALID_DATA: + return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; + case ERR_TRANSACTION_FAILED: + return ERR_NULL_OBJECT; + case ERR_OK: + return funcResult; + default: + return res; + } +} + +ErrCode AppControlClient::AddAppInstallControlRule(const std::vector &appIds, + const AppInstallControlRuleType controlRuleType, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + LOG_D(BMS_TAG_DEFAULT, "begin to call AddAppInstallControlRule"); + if (appIds.empty()) { + LOG_E(BMS_TAG_DEFAULT, "AddAppInstallControlRule failed due to params error"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + if (appIds.size() > AppControlConstants::LIST_MAX_SIZE) { + LOG_E(BMS_TAG_DEFAULT, "elements num exceeds the limit %{public}d", AppControlConstants::LIST_MAX_SIZE); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call AddAppInstallControlRule"); + ErrCode res = proxy->AddAppInstallControlRule(appIds, controlRuleType, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "AddAppInstallControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, + const std::vector &appIds, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + LOG_D(BMS_TAG_DEFAULT, "begin to call DeleteAppInstallControlRule"); + if (appIds.empty()) { + LOG_E(BMS_TAG_DEFAULT, "DeleteAppInstallControlRule failed due to params error"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + if (appIds.size() > AppControlConstants::LIST_MAX_SIZE) { + LOG_E(BMS_TAG_DEFAULT, "elements num exceeds the limit %{public}d", AppControlConstants::LIST_MAX_SIZE); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteAppInstallControlRule"); + ErrCode res = proxy->DeleteAppInstallControlRule(controlRuleType, appIds, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteAppInstallControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteAppInstallControlRule"); + ErrCode res = proxy->DeleteAppInstallControlRule(controlRuleType, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteAppInstallControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId, + std::vector &appIds) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetAppInstallControlRule"); + ErrCode res = proxy->GetAppInstallControlRule(controlRuleType, userId, appIds, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetAppInstallControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::AddAppRunningControlRule(const std::vector &controlRule, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + LOG_D(BMS_TAG_DEFAULT, "begin to call AddAppRunningControlRule"); + if (controlRule.empty()) { + LOG_E(BMS_TAG_DEFAULT, "AddAppRunningControlRule failed due to params error"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + if (controlRule.size() > AppControlConstants::LIST_MAX_SIZE) { + LOG_E(BMS_TAG_DEFAULT, "elements num exceeds the limit %{public}d", AppControlConstants::LIST_MAX_SIZE); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call AddAppRunningControlRule"); + ErrCode res = proxy->AddAppRunningControlRule(controlRule, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "AddAppRunningControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteAppRunningControlRule(const std::vector &controlRule, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + LOG_D(BMS_TAG_DEFAULT, "begin to call delete AppRunningControlRules"); + if (controlRule.empty()) { + LOG_E(BMS_TAG_DEFAULT, "DeleteAppRunningControlRule failed due to params error"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + if (controlRule.size() > AppControlConstants::LIST_MAX_SIZE) { + LOG_E(BMS_TAG_DEFAULT, "elements num exceeds the limit %{public}d", AppControlConstants::LIST_MAX_SIZE); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteAppRunningControlRule"); + ErrCode res = proxy->DeleteAppRunningControlRule(controlRule, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteAppRunningControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteAppRunningControlRule(int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteAppRunningControlRule"); + ErrCode res = proxy->DeleteAppRunningControlRule(userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteAppRunningControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetAppRunningControlRule(int32_t userId, std::vector &appIds) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetAppRunningControlRule"); + ErrCode res = proxy->GetAppRunningControlRule(userId, appIds, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetAppRunningControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetAppRunningControlRule(const std::string &bundleName, int32_t userId, + AppRunningControlRuleResult &controlRuleResult) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetAppRunningControlRule"); + ErrCode res = proxy->GetAppRunningControlRule(bundleName, userId, controlRuleResult, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + if (funcResult != ERR_OK) { + LOG_D(BMS_TAG_DEFAULT, "GetAppRunningControlRule failed, reset AppRunningControlRuleResult"); + controlRuleResult.isEdm = false; + controlRuleResult.controlMessage = ""; + controlRuleResult.controlWant = nullptr; + } + LOG_D(BMS_TAG_DEFAULT, "GetAppRunningControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::ConfirmAppJumpControlRule(const std::string &callerBundleName, + const std::string &targetBundleName, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + if (callerBundleName.empty() || targetBundleName.empty()) { + LOG_E(BMS_TAG_DEFAULT, "ConfirmAppJumpControlRule failed due to params error"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call ConfirmAppJumpControlRule"); + ErrCode res = proxy->ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "ConfirmAppJumpControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::AddAppJumpControlRule(const std::vector &controlRules, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + if (controlRules.empty()) { + LOG_E(BMS_TAG_DEFAULT, "AppJumpControlRule failed due to params error"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + if (controlRules.size() > AppControlConstants::LIST_MAX_SIZE) { + LOG_E(BMS_TAG_DEFAULT, "elements num exceeds the limit %{public}d", AppControlConstants::LIST_MAX_SIZE); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call AddAppJumpControlRule"); + ErrCode res = proxy->AddAppJumpControlRule(controlRules, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "AddAppJumpControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteAppJumpControlRule(const std::vector &controlRules, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + if (controlRules.size() > AppControlConstants::LIST_MAX_SIZE) { + LOG_E(BMS_TAG_DEFAULT, "elements num exceeds the limit %{public}d", AppControlConstants::LIST_MAX_SIZE); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteAppJumpControlRule"); + ErrCode res = proxy->DeleteAppJumpControlRule(controlRules, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteAppJumpControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteRuleByCallerBundleName"); + ErrCode res = proxy->DeleteRuleByCallerBundleName(callerBundleName, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteRuleByCallerBundleName errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteRuleByTargetBundleName"); + ErrCode res = proxy->DeleteRuleByTargetBundleName(targetBundleName, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteRuleByTargetBundleName errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetAppJumpControlRule(const std::string &callerBundleName, + const std::string &targetBundleName, int32_t userId, AppJumpControlRule &controlRule) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetAppJumpControlRule"); + ErrCode res = proxy->GetAppJumpControlRule(callerBundleName, targetBundleName, userId, controlRule, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetAppJumpControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::SetDisposedStatus(const std::string &appId, const Want &want, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call SetDisposedStatus"); + ErrCode res = proxy->SetDisposedStatus(appId, want, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "SetDisposedStatus errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteDisposedStatus(const std::string &appId, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteDisposedStatus"); + ErrCode res = proxy->DeleteDisposedStatus(appId, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteDisposedStatus errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetDisposedStatus(const std::string &appId, Want &want, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetDisposedStatus"); + ErrCode res = proxy->GetDisposedStatus(appId, userId, want, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetDisposedStatus errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetDisposedRule(const std::string &appId, DisposedRule& disposedRule, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetDisposedRule"); + ErrCode res = proxy->GetDisposedRule(appId, userId, disposedRule, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetDisposedRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::SetDisposedRule(const std::string &appId, DisposedRule& disposedRule, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call SetDisposedRule"); + ErrCode res = proxy->SetDisposedRule(appId, userId, disposedRule, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "SetDisposedRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::SetDisposedRules(std::vector &disposedRuleConfigurations, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + if (disposedRuleConfigurations.empty() || disposedRuleConfigurations.size() > MAX_VECTOR_NUM) { + LOG_E(BMS_TAG_DEFAULT, "SetDisposedRules failed due to params error"); + return ERR_BUNDLE_MANAGER_PARAM_ERROR; + } + MessageParcel tempParcel; + ErrCode res = WriteVectorToParcel(disposedRuleConfigurations, tempParcel); + if (res != ERR_OK) { + LOG_E(BMS_TAG_DEFAULT, "write DisposedRuleConfiguration failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + BundleMgrRawData disposedRuleConfigurationsRawData; + disposedRuleConfigurationsRawData.size = static_cast(tempParcel.GetDataSize()); + ErrCode ret = disposedRuleConfigurationsRawData.RawDataCpy(reinterpret_cast(tempParcel.GetData())); + if (ret != ERR_OK) { + LOG_E(BMS_TAG_DEFAULT, "Failed to copy dispose rules raw data"); + return ERR_APPEXECFWK_INSTALLD_PARAM_ERROR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call SetDisposedRules"); + res = proxy->SetDisposedRules(userId, disposedRuleConfigurationsRawData, funcResult); + ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "SetDisposedRules errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, + std::vector& disposedRules, int32_t appIndex) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetAbilityRunningControlRule"); + ErrCode res = proxy->GetAbilityRunningControlRule(bundleName, userId, appIndex, disposedRules, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetAbilityRunningControlRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &disposedRule, + int32_t appIndex, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetDisposedRuleForCloneApp"); + ErrCode res = proxy->GetDisposedRuleForCloneApp(appId, appIndex, userId, disposedRule, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetDisposedRuleForCloneApp errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &disposedRule, + int32_t appIndex, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call SetDisposedRuleForCloneApp"); + ErrCode res = proxy->SetDisposedRuleForCloneApp(appId, appIndex, userId, disposedRule, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "SetDisposedRuleForCloneApp errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, + int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteDisposedRuleForCloneApp"); + ErrCode res = proxy->DeleteDisposedRuleForCloneApp(appId, appIndex, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteDisposedRuleForCloneApp errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::SetUninstallDisposedRule(const std::string &appIdentifier, + const UninstallDisposedRule &disposedRule, int32_t appIndex, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call SetUninstallDisposedRule"); + ErrCode res = proxy->SetUninstallDisposedRule(appIdentifier, disposedRule, appIndex, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "SetUninstallDisposedRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, + int32_t userId, UninstallDisposedRule &rule) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call GetUninstallDisposedRule"); + ErrCode res = proxy->GetUninstallDisposedRule(appIdentifier, appIndex, userId, rule, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "GetUninstallDisposedRule errCode: %{public}d", ret); + return ret; +} + +ErrCode AppControlClient::DeleteUninstallDisposedRule(const std::string &appIdentifier, + int32_t appIndex, int32_t userId) +{ + auto proxy = GetAppControlProxy(); + if (proxy == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get app control mgr proxy"); + return ERR_APPEXECFWK_NULL_PTR; + } + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + LOG_D(BMS_TAG_DEFAULT, "proxy begin to call DeleteUninstallDisposedRule"); + ErrCode res = proxy->DeleteUninstallDisposedRule(appIdentifier, appIndex, userId, funcResult); + ErrCode ret = ConvertResultToErrCode(res, funcResult); + LOG_D(BMS_TAG_DEFAULT, "DeleteUninstallDisposedRule errCode: %{public}d", ret); + return ret; +} + +sptr AppControlClient::GetAppControlProxy() +{ + std::lock_guard lock(mutex_); + if (appControlMgrProxy_ != nullptr) { + return appControlMgrProxy_; + } + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (systemAbilityManager == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to get system ability manager"); + return nullptr; + } + + sptr remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); + if (remoteObject == nullptr) { + LOG_NOFUNC_E(BMS_TAG_DEFAULT, "get bms sa failed"); + return nullptr; + } + auto bundleMgr = iface_cast(remoteObject); + if (bundleMgr == nullptr) { + LOG_NOFUNC_E(BMS_TAG_DEFAULT, "iface_cast failed"); + return nullptr; + } + appControlMgrProxy_ = bundleMgr->GetAppControlProxy(); + if ((appControlMgrProxy_ == nullptr) || (appControlMgrProxy_->AsObject() == nullptr)) { + LOG_E(BMS_TAG_DEFAULT, "failed to get appConrol proxy"); + return nullptr; + } + deathRecipient_ = new (std::nothrow) AppControlDeathRecipient(); + if (deathRecipient_ == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "failed to create app control death recipient"); + return nullptr; + } + if ((appControlMgrProxy_->AsObject()->IsProxyObject()) && + (!appControlMgrProxy_->AsObject()->AddDeathRecipient(deathRecipient_))) { + LOG_E(BMS_TAG_DEFAULT, "Failed to add death recipient"); + appControlMgrProxy_ = nullptr; + deathRecipient_ = nullptr; + return nullptr; + } + + return appControlMgrProxy_; +} + +void AppControlClient::ResetAppControlProxy(const wptr& remote) +{ + std::lock_guard lock(mutex_); + if (appControlMgrProxy_ == nullptr) { + APP_LOGE("Proxy is nullptr"); + return; + } + auto serviceRemote = appControlMgrProxy_->AsObject(); + if ((serviceRemote != nullptr) && (serviceRemote == remote.promote())) { + serviceRemote->RemoveDeathRecipient(deathRecipient_); + } + appControlMgrProxy_ = nullptr; + deathRecipient_ = nullptr; +} + +void AppControlClient::AppControlDeathRecipient::OnRemoteDied(const wptr &remote) +{ + if (remote == nullptr) { + APP_LOGE("remote is nullptr"); + return; + } + AppControlClient::GetInstance().ResetAppControlProxy(remote); +} + +template +ErrCode AppControlClient::WriteVectorToParcel(std::vector &parcelVector, MessageParcel &tempParcel) +{ + (void)tempParcel.SetMaxCapacity(Constants::MAX_PARCEL_CAPACITY); + if (!tempParcel.WriteInt32(static_cast(parcelVector.size()))) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + for (auto &parcel : parcelVector) { + if (!tempParcel.WriteParcelable(&parcel)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + } + + size_t dataSize = tempParcel.GetDataSize(); + if (dataSize > MAX_IPC_ALLOWED_CAPACITY) { + APP_LOGE("datasize is too large"); + return ERR_BUNDLE_MANAGER_PARAM_ERROR; + } + return ERR_OK; +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_host.cpp b/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_host.cpp deleted file mode 100644 index 752eb8cc68b762611a3e646541d0fca01997d4b5..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_host.cpp +++ /dev/null @@ -1,683 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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_control_host.h" - -#include "securec.h" -#include "string_ex.h" - -#include "app_control_constants.h" -#include "app_log_tag_wrapper.h" -#include "app_log_wrapper.h" -#include "appexecfwk_errors.h" -#include "bundle_framework_core_ipc_interface_code.h" -#include "bundle_memory_guard.h" -#include "disposed_rule.h" -#include "ipc_types.h" -#include "parcel_macro.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -const int16_t MAX_VECTOR_NUM = 1000; -constexpr size_t MAX_IPC_ALLOWED_CAPACITY = 100 * 1024 * 1024; // max ipc size 100MB -bool GetData(size_t size, const void *data, void *&buffer) -{ - if (data == nullptr) { - APP_LOGE("failed due to null data"); - return false; - } - if ((size == 0) || size > Constants::MAX_PARCEL_CAPACITY) { - APP_LOGE("failed due to wrong size"); - return false; - } - buffer = malloc(size); - if (buffer == nullptr) { - APP_LOGE("failed due to malloc buffer failed"); - return false; - } - if (memcpy_s(buffer, size, data, size) != EOK) { - free(buffer); - APP_LOGE("failed due to memcpy_s failed"); - return false; - } - return true; -} -} -AppControlHost::AppControlHost() -{ - LOG_D(BMS_TAG_DEFAULT, "create AppControlHost"); -} - -AppControlHost::~AppControlHost() -{ - LOG_D(BMS_TAG_DEFAULT, "destroy AppControlHost"); -} - -int AppControlHost::OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - BundleMemoryGuard memoryGuard; - APP_LOGD("AppControlHost OnRemoteRequest, message code : %{public}u", code); - std::u16string descriptor = AppControlHost::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - LOG_E(BMS_TAG_DEFAULT, "descriptor invalid"); - return OBJECT_NULL; - } - - switch (code) { - case static_cast(AppControlManagerInterfaceCode::ADD_APP_INSTALL_CONTROL_RULE): - return HandleAddAppInstallControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_APP_INSTALL_CONTROL_RULE): - return HandleDeleteAppInstallControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::CLEAN_APP_INSTALL_CONTROL_RULE): - return HandleCleanAppInstallControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_APP_INSTALL_CONTROL_RULE): - return HandleGetAppInstallControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::ADD_APP_RUNNING_CONTROL_RULE): - return HandleAddAppRunningControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_APP_RUNNING_CONTROL_RULE): - return HandleDeleteAppRunningControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::CLEAN_APP_RUNNING_CONTROL_RULE): - return HandleCleanAppRunningControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_APP_RUNNING_CONTROL_RULE): - return HandleGetAppRunningControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_APP_RUNNING_CONTROL_RULE_RESULT): - return HandleGetAppRunningControlRuleResult(data, reply); - case static_cast(AppControlManagerInterfaceCode::CONFIRM_APP_JUMP_CONTROL_RULE): - return HandleConfirmAppJumpControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::ADD_APP_JUMP_CONTROL_RULE): - return HandleAddAppJumpControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE): - return HandleDeleteAppJumpControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE_BY_CALLER): - return HandleDeleteRuleByCallerBundleName(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE_BY_TARGET): - return HandleDeleteRuleByTargetBundleName(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_APP_JUMP_CONTROL_RULE): - return HandleGetAppJumpControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_STATUS): - return HandleSetDisposedStatus(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_DISPOSED_STATUS): - return HandleGetDisposedStatus(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_DISPOSED_STATUS): - return HandleDeleteDisposedStatus(data, reply); - case static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_RULE): - return HandleSetDisposedRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_RULES): - return HandleSetDisposedRules(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_DISPOSED_RULE): - return HandleGetDisposedRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_ABILITY_RUNNING_CONTROL_RULE): - return HandleGetAbilityRunningControlRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_DISPOSED_RULE_FOR_CLONE_APP): - return HandleGetDisposedRuleForCloneApp(data, reply); - case static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_RULE_FOR_CLONE_APP): - return HandleSetDisposedRuleForCloneApp(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_DISPOSED_RULE_FOR_CLONE_APP): - return HandleDeleteDisposedRuleForCloneApp(data, reply); - case static_cast(AppControlManagerInterfaceCode::SET_UNINSTALL_DISPOSED_RULE): - return HandleSetUninstallDisposedRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::GET_UNINSTALL_DISPOSED_RULE): - return HandleGetUninstallDisposedRule(data, reply); - case static_cast(AppControlManagerInterfaceCode::DELETE_UNINSTALL_DISPOSED_RULE): - return HandleDeleteUninstallDisposedRule(data, reply); - default: - LOG_W(BMS_TAG_DEFAULT, "AppControlHost receive unknown code, code = %{public}d", code); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } -} - -ErrCode AppControlHost::HandleAddAppInstallControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::vector appIds; - int32_t appIdSize = data.ReadInt32(); - if (appIdSize > AppControlConstants::LIST_MAX_SIZE || appIdSize < 0) { - LOG_E(BMS_TAG_DEFAULT, "HandleAddAppInstallControlRule parameter is invalid"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - appIds.reserve(appIdSize); - for (int32_t i = 0; i < appIdSize; i++) { - appIds.emplace_back(data.ReadString()); - } - AppInstallControlRuleType controlRuleType = static_cast(data.ReadInt32()); - int32_t userId = data.ReadInt32(); - int32_t ret = AddAppInstallControlRule(appIds, controlRuleType, userId); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleAddAppInstallControlRule failed"); - } - return ret; -} - -ErrCode AppControlHost::HandleDeleteAppInstallControlRule(MessageParcel& data, MessageParcel& reply) -{ - AppInstallControlRuleType controlRuleType = static_cast(data.ReadInt32()); - std::vector appIds; - int32_t appIdSize = data.ReadInt32(); - if (appIdSize > AppControlConstants::LIST_MAX_SIZE || appIdSize < 0) { - LOG_E(BMS_TAG_DEFAULT, "HandleDeleteAppInstallControlRule parameter is invalid"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - appIds.reserve(appIdSize); - for (int32_t i = 0; i < appIdSize; i++) { - appIds.emplace_back(data.ReadString()); - } - int32_t userId = data.ReadInt32(); - int32_t ret = DeleteAppInstallControlRule(controlRuleType, appIds, userId); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleDeleteAppInstallControlRule failed"); - } - return ret; -} - -ErrCode AppControlHost::HandleCleanAppInstallControlRule(MessageParcel& data, MessageParcel& reply) -{ - AppInstallControlRuleType controlRuleType = static_cast(data.ReadInt32()); - int32_t userId = data.ReadInt32(); - int32_t ret = DeleteAppInstallControlRule(controlRuleType, userId); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleCleanAppInstallControlRule failed"); - } - return ret; -} - -ErrCode AppControlHost::HandleGetAppInstallControlRule(MessageParcel& data, MessageParcel& reply) -{ - AppInstallControlRuleType controlRuleType = static_cast(data.ReadInt32()); - int32_t userId = data.ReadInt32(); - std::vector appIds; - int32_t ret = GetAppInstallControlRule(controlRuleType, userId, appIds); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleGetAppInstallControlRule failed"); - return ret; - } - if (!WriteStringVector(appIds, reply)) { - LOG_E(BMS_TAG_DEFAULT, "write appIds failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleAddAppRunningControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::vector controlRules; - auto ret = ReadParcelableVector(data, controlRules); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "AddAppRunningControlRule read controlRuleParam failed"); - return ret; - } - int32_t userId = data.ReadInt32(); - return AddAppRunningControlRule(controlRules, userId); -} - -ErrCode AppControlHost::HandleDeleteAppRunningControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::vector controlRules; - auto ret = ReadParcelableVector(data, controlRules); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "DeleteAppRunningControlRule read controlRuleParam failed"); - return ret; - } - int32_t userId = data.ReadInt32(); - return DeleteAppRunningControlRule(controlRules, userId); -} - -ErrCode AppControlHost::HandleCleanAppRunningControlRule(MessageParcel& data, MessageParcel& reply) -{ - int32_t userId = data.ReadInt32(); - int32_t ret = DeleteAppRunningControlRule(userId); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleCleanAppInstallControlRule failed"); - } - return ret; -} - -ErrCode AppControlHost::HandleGetAppRunningControlRule(MessageParcel& data, MessageParcel& reply) -{ - int32_t userId = data.ReadInt32(); - std::vector appIds; - int32_t ret = GetAppRunningControlRule(userId, appIds); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleGetAppRunningControlRule failed"); - return ret; - } - if (!WriteStringVector(appIds, reply)) { - LOG_E(BMS_TAG_DEFAULT, "write appIds failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleGetAppRunningControlRuleResult(MessageParcel& data, MessageParcel& reply) -{ - std::string bundleName = data.ReadString(); - int32_t userId = data.ReadInt32(); - AppRunningControlRuleResult ruleResult; - int32_t ret = GetAppRunningControlRule(bundleName, userId, ruleResult); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleGetAppRunningControlRuleResult failed"); - } - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write result failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if ((ret == ERR_OK) && !reply.WriteParcelable(&ruleResult)) { - LOG_E(BMS_TAG_DEFAULT, "write AppRunningControlRuleResult failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleConfirmAppJumpControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::string callerBundleName = data.ReadString(); - std::string targetBundleName = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t ret = ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleConfirmAppJumpControlRule failed"); - } - return ret; -} - -ErrCode AppControlHost::HandleAddAppJumpControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::vector controlRules; - auto ret = ReadParcelableVector(data, controlRules); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleAddAppJumpControlRule read controlRuleParam failed"); - return ret; - } - int32_t userId = data.ReadInt32(); - return AddAppJumpControlRule(controlRules, userId); -} - -ErrCode AppControlHost::HandleDeleteAppJumpControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::vector controlRules; - auto ret = ReadParcelableVector(data, controlRules); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleDeleteAppJumpControlRule read controlRuleParam failed"); - return ret; - } - int32_t userId = data.ReadInt32(); - return DeleteAppJumpControlRule(controlRules, userId); -} - -ErrCode AppControlHost::HandleDeleteRuleByCallerBundleName(MessageParcel& data, MessageParcel& reply) -{ - std::string callerBundleName = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t ret = DeleteRuleByCallerBundleName(callerBundleName, userId); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleDeleteRuleByCallerBundleName failed"); - } - return ret; -} - -ErrCode AppControlHost::HandleDeleteRuleByTargetBundleName(MessageParcel& data, MessageParcel& reply) -{ - std::string targetBundleName = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t ret = DeleteRuleByTargetBundleName(targetBundleName, userId); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleDeleteRuleByTargetBundleName failed"); - } - return ret; -} - -ErrCode AppControlHost::HandleGetAppJumpControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::string callerBundleName = data.ReadString(); - std::string targetBundleName = data.ReadString(); - int32_t userId = data.ReadInt32(); - AppJumpControlRule rule; - int32_t ret = GetAppJumpControlRule(callerBundleName, targetBundleName, userId, rule); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleGetAppJumpControlRule failed"); - } - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write result failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if ((ret == ERR_OK) && !reply.WriteParcelable(&rule)) { - LOG_E(BMS_TAG_DEFAULT, "write AppJumpControlRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleSetDisposedStatus(MessageParcel& data, MessageParcel& reply) -{ - std::string appId = data.ReadString(); - std::unique_ptr want(data.ReadParcelable()); - int32_t userId = data.ReadInt32(); - if (want == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - ErrCode ret = SetDisposedStatus(appId, *want, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleDeleteDisposedStatus(MessageParcel& data, MessageParcel &reply) -{ - std::string appId = data.ReadString(); - int32_t userId = data.ReadInt32(); - ErrCode ret = DeleteDisposedStatus(appId, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleGetDisposedStatus(MessageParcel& data, MessageParcel &reply) -{ - std::string appId = data.ReadString(); - int32_t userId = data.ReadInt32(); - Want want; - ErrCode ret = GetDisposedStatus(appId, want, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (ret == ERR_OK) { - if (!reply.WriteParcelable(&want)) { - LOG_E(BMS_TAG_DEFAULT, "write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleGetDisposedRule(MessageParcel& data, MessageParcel &reply) -{ - std::string appId = data.ReadString(); - int32_t userId = data.ReadInt32(); - DisposedRule rule; - ErrCode ret = GetDisposedRule(appId, rule, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (ret == ERR_OK) { - if (!reply.WriteParcelable(&rule)) { - LOG_E(BMS_TAG_DEFAULT, "write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleSetDisposedRule(MessageParcel& data, MessageParcel& reply) -{ - std::string appId = data.ReadString(); - std::unique_ptr disposedRule(data.ReadParcelable()); - int32_t userId = data.ReadInt32(); - if (disposedRule == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - ErrCode ret = SetDisposedRule(appId, *disposedRule, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleSetDisposedRules(MessageParcel& data, MessageParcel& reply) -{ - std::vector disposedRuleConfigurations; - auto ret = GetVectorParcelInfo(data, disposedRuleConfigurations); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "HandleSetDisposedRules read DisposedRuleConfiguration failed"); - return ret; - } - if (disposedRuleConfigurations.empty() || disposedRuleConfigurations.size() > MAX_VECTOR_NUM) { - LOG_E(BMS_TAG_DEFAULT, "disposedRuleConfiguration count is error"); - return ERR_BUNDLE_MANAGER_PARAM_ERROR; - } - int32_t userId = data.ReadInt32(); - ret = SetDisposedRules(disposedRuleConfigurations, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleGetAbilityRunningControlRule(MessageParcel& data, MessageParcel& reply) -{ - std::string bundleName = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t appIndex = data.ReadInt32(); - std::vector rules; - ErrCode ret = GetAbilityRunningControlRule(bundleName, userId, rules, appIndex); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (ret == ERR_OK) { - if (!WriteParcelableVector(rules, reply)) { - LOG_E(BMS_TAG_DEFAULT, "write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleGetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel &reply) -{ - std::string appId = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t appIndex = data.ReadInt32(); - DisposedRule rule; - ErrCode ret = GetDisposedRuleForCloneApp(appId, rule, appIndex, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (ret == ERR_OK) { - if (!reply.WriteParcelable(&rule)) { - LOG_E(BMS_TAG_DEFAULT, "write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleSetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply) -{ - std::string appId = data.ReadString(); - std::unique_ptr disposedRule(data.ReadParcelable()); - int32_t userId = data.ReadInt32(); - int32_t appIndex = data.ReadInt32(); - if (disposedRule == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - ErrCode ret = SetDisposedRuleForCloneApp(appId, *disposedRule, appIndex, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleDeleteDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply) -{ - std::string appId = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t appIndex = data.ReadInt32(); - ErrCode ret = DeleteDisposedRuleForCloneApp(appId, appIndex, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -bool AppControlHost::WriteStringVector(const std::vector &stringVector, MessageParcel &reply) -{ - if (!reply.WriteInt32(stringVector.size())) { - LOG_E(BMS_TAG_DEFAULT, "write ParcelableVector failed"); - return false; - } - - for (auto &string : stringVector) { - if (!reply.WriteString(string)) { - LOG_E(BMS_TAG_DEFAULT, "write string failed"); - return false; - } - } - return true; -} - -template -bool AppControlHost::WriteParcelableVector(std::vector &parcelableVector, MessageParcel &reply) -{ - if (!reply.WriteInt32(parcelableVector.size())) { - LOG_E(BMS_TAG_DEFAULT, "write ParcelableVector failed"); - return false; - } - - for (auto &parcelable : parcelableVector) { - if (!reply.WriteParcelable(&parcelable)) { - LOG_E(BMS_TAG_DEFAULT, "write ParcelableVector failed"); - return false; - } - } - return true; -} - -template -ErrCode AppControlHost::ReadParcelableVector(MessageParcel &data, std::vector &parcelableInfos) -{ - int32_t infoSize = data.ReadInt32(); - if (infoSize > AppControlConstants::LIST_MAX_SIZE) { - LOG_E(BMS_TAG_DEFAULT, "elements num exceeds the limit %{public}d", AppControlConstants::LIST_MAX_SIZE); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - for (int32_t i = 0; i < infoSize; i++) { - std::unique_ptr info(data.ReadParcelable()); - if (info == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "read parcelable infos failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - parcelableInfos.emplace_back(*info); - } - LOG_D(BMS_TAG_DEFAULT, "read parcelable infos success"); - return ERR_OK; -} - -ErrCode AppControlHost::HandleGetUninstallDisposedRule(MessageParcel& data, MessageParcel& reply) -{ - std::string appIdentifier = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t appIndex = data.ReadInt32(); - UninstallDisposedRule rule; - ErrCode ret = GetUninstallDisposedRule(appIdentifier, appIndex, userId, rule); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (ret == ERR_OK) { - if (!reply.WriteParcelable(&rule)) { - LOG_E(BMS_TAG_DEFAULT, "write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleSetUninstallDisposedRule(MessageParcel& data, MessageParcel& reply) -{ - std::string appIdentifier = data.ReadString(); - std::unique_ptr uninstallDisposedRule(data.ReadParcelable()); - if (uninstallDisposedRule == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - int32_t userId = data.ReadInt32(); - int32_t appIndex = data.ReadInt32(); - ErrCode ret = SetUninstallDisposedRule(appIdentifier, *uninstallDisposedRule, appIndex, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -ErrCode AppControlHost::HandleDeleteUninstallDisposedRule(MessageParcel& data, MessageParcel& reply) -{ - std::string appIdentifier = data.ReadString(); - int32_t userId = data.ReadInt32(); - int32_t appIndex = data.ReadInt32(); - ErrCode ret = DeleteUninstallDisposedRule(appIdentifier, appIndex, userId); - if (!reply.WriteInt32(ret)) { - LOG_E(BMS_TAG_DEFAULT, "write ret failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} - -template -ErrCode AppControlHost::GetVectorParcelInfo(MessageParcel &data, std::vector &parcelInfos) -{ - size_t dataSize = data.ReadUint32(); - if (dataSize == 0) { - APP_LOGW("Parcel no data"); - return ERR_OK; - } - - void *buffer = nullptr; - if (dataSize > MAX_IPC_ALLOWED_CAPACITY) { - APP_LOGE("dataSize is too large"); - return ERR_BUNDLE_MANAGER_PARAM_ERROR; - } else { - if (!GetData(dataSize, data.ReadRawData(dataSize), buffer)) { - APP_LOGE("GetData failed dataSize: %{public}zu", dataSize); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - - MessageParcel tempParcel; - if (!tempParcel.ParseFrom(reinterpret_cast(buffer), dataSize)) { - APP_LOGE("Fail to ParseFrom"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - int32_t infoSize = tempParcel.ReadInt32(); - CONTAINER_SECURITY_VERIFY(tempParcel, infoSize, &parcelInfos); - for (int32_t i = 0; i < infoSize; i++) { - std::unique_ptr info(tempParcel.ReadParcelable()); - if (info == nullptr) { - APP_LOGE("Read Parcelable infos failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - parcelInfos.emplace_back(*info); - } - - return ERR_OK; -} -} // AppExecFwk -} // OHOS diff --git a/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_proxy.cpp deleted file mode 100644 index 71711f25bb035d29819ec03c7ecda6f7d35e34fb..0000000000000000000000000000000000000000 --- a/interfaces/inner_api/appexecfwk_core/src/app_control/app_control_proxy.cpp +++ /dev/null @@ -1,948 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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_control_proxy.h" - -#include "app_log_tag_wrapper.h" -#include "app_log_wrapper.h" -#include "appexecfwk_errors.h" -#include "bundle_constants.h" -#include "ipc_types.h" -#include "parcel_macro.h" - -namespace OHOS { -namespace AppExecFwk { -namespace { -const int16_t MAX_VECTOR_NUM = 1000; -constexpr size_t MAX_IPC_ALLOWED_CAPACITY = 100 * 1024 * 1024; // max ipc size 100MB -} -AppControlProxy::AppControlProxy(const sptr &object) : IRemoteProxy(object) -{ - LOG_D(BMS_TAG_DEFAULT, "create AppControlProxy"); -} - -AppControlProxy::~AppControlProxy() -{ - LOG_D(BMS_TAG_DEFAULT, "destroy AppControlProxy"); -} - -ErrCode AppControlProxy::AddAppInstallControlRule(const std::vector &appIds, - const AppInstallControlRuleType controlRuleType, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call AddAppInstallControlRule"); - if (appIds.empty()) { - LOG_E(BMS_TAG_DEFAULT, "AddAppInstallControlRule failed due to params error"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!WriteStringVector(appIds, data)) { - LOG_E(BMS_TAG_DEFAULT, "write appIds failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(static_cast(controlRuleType))) { - LOG_E(BMS_TAG_DEFAULT, "write controlRuleType failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::ADD_APP_INSTALL_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, - const std::vector &appIds, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call DeleteAppInstallControlRule"); - if (appIds.empty()) { - LOG_E(BMS_TAG_DEFAULT, "DeleteAppInstallControlRule failed due to params error"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(static_cast(controlRuleType))) { - LOG_E(BMS_TAG_DEFAULT, "write controlRuleType failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!WriteStringVector(appIds, data)) { - LOG_E(BMS_TAG_DEFAULT, "write appIds failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::DELETE_APP_INSTALL_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::DeleteAppInstallControlRule( - const AppInstallControlRuleType controlRuleType, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call DeleteAppInstallControlRule"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(static_cast(controlRuleType))) { - LOG_E(BMS_TAG_DEFAULT, "write controlRuleType failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::CLEAN_APP_INSTALL_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::GetAppInstallControlRule( - const AppInstallControlRuleType controlRuleType, int32_t userId, std::vector &appIds) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call GetAppInstallControlRule"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(static_cast(controlRuleType))) { - LOG_E(BMS_TAG_DEFAULT, "write controlRuleType failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return GetParcelableInfos(AppControlManagerInterfaceCode::GET_APP_INSTALL_CONTROL_RULE, data, appIds); -} - -ErrCode AppControlProxy::AddAppRunningControlRule( - const std::vector &controlRules, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call AddAppRunningControlRule"); - if (controlRules.empty()) { - LOG_E(BMS_TAG_DEFAULT, "AddAppRunningControlRule failed due to params error"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!WriteParcelableVector(controlRules, data)) { - LOG_E(BMS_TAG_DEFAULT, "write AppRunningControlRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::ADD_APP_RUNNING_CONTROL_RULE, data, reply); -} -ErrCode AppControlProxy::DeleteAppRunningControlRule( - const std::vector &controlRules, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call delete AppRunningControlRules"); - if (controlRules.empty()) { - LOG_E(BMS_TAG_DEFAULT, "DeleteAppRunningControlRule failed due to params error"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!WriteParcelableVector(controlRules, data)) { - LOG_E(BMS_TAG_DEFAULT, "write AppRunningControlRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::DELETE_APP_RUNNING_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::DeleteAppRunningControlRule(int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call delete appRunningControlRuleType"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::CLEAN_APP_RUNNING_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::GetAppRunningControlRule(int32_t userId, std::vector &appIds) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call GetAppInstallControlRule"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return GetParcelableInfos(AppControlManagerInterfaceCode::GET_APP_RUNNING_CONTROL_RULE, data, appIds); -} - -ErrCode AppControlProxy::GetAppRunningControlRule( - const std::string &bundleName, int32_t userId, AppRunningControlRuleResult &controlRuleResult) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call GetAppRunningControlRuleResult"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(bundleName)) { - LOG_E(BMS_TAG_DEFAULT, "fail to GetMediaData due to write bundleName fail"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return GetParcelableInfo( - AppControlManagerInterfaceCode::GET_APP_RUNNING_CONTROL_RULE_RESULT, data, controlRuleResult); -} - -ErrCode AppControlProxy::ConfirmAppJumpControlRule(const std::string &callerBundleName, - const std::string &targetBundleName, int32_t userId) -{ - if (callerBundleName.empty() || targetBundleName.empty()) { - LOG_E(BMS_TAG_DEFAULT, "ConfirmAppJumpControlRule failed due to params error"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(callerBundleName)) { - LOG_E(BMS_TAG_DEFAULT, "fail to write callerBundleName fail"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(targetBundleName)) { - LOG_E(BMS_TAG_DEFAULT, "fail to write targetBundleName fail"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::CONFIRM_APP_JUMP_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::AddAppJumpControlRule(const std::vector &controlRules, int32_t userId) -{ - if (controlRules.empty()) { - LOG_E(BMS_TAG_DEFAULT, "DeleteAppJumpControlRule failed due to params error"); - return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; - } - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!WriteParcelableVector(controlRules, data)) { - LOG_E(BMS_TAG_DEFAULT, "write AppJumpControlRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::ADD_APP_JUMP_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::DeleteAppJumpControlRule(const std::vector &controlRules, int32_t userId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!WriteParcelableVector(controlRules, data)) { - LOG_E(BMS_TAG_DEFAULT, "write AppJumpControlRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE, data, reply); -} - -ErrCode AppControlProxy::DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(callerBundleName)) { - LOG_E(BMS_TAG_DEFAULT, "fail to write callerBundleName fail"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE_BY_CALLER, data, reply); -} - -ErrCode AppControlProxy::DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(targetBundleName)) { - LOG_E(BMS_TAG_DEFAULT, "fail to write targetBundleName fail"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - MessageParcel reply; - return SendRequest(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE_BY_TARGET, data, reply); -} - -ErrCode AppControlProxy::GetAppJumpControlRule(const std::string &callerBundleName, - const std::string &targetBundleName, int32_t userId, AppJumpControlRule &controlRule) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(callerBundleName)) { - LOG_E(BMS_TAG_DEFAULT, "fail to write callerBundleName fail"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(targetBundleName)) { - LOG_E(BMS_TAG_DEFAULT, "fail to write targetBundleName fail"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return GetParcelableInfo( - AppControlManagerInterfaceCode::GET_APP_JUMP_CONTROL_RULE, data, controlRule); -} - -ErrCode AppControlProxy::SetDisposedStatus( - const std::string &appId, const Want &want, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to SetDisposedStatus"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write bundleName failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteParcelable(&want)) { - LOG_E(BMS_TAG_DEFAULT, "write want failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ErrCode ret = SendRequest(AppControlManagerInterfaceCode::SET_DISPOSED_STATUS, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::DeleteDisposedStatus(const std::string &appId, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to DeleteDisposedStatus"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write bundleName failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ErrCode ret = SendRequest(AppControlManagerInterfaceCode::DELETE_DISPOSED_STATUS, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::GetDisposedStatus(const std::string &appId, Want &want, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to GetDisposedStatus"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write bundleName failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - ErrCode ret = GetParcelableInfo(AppControlManagerInterfaceCode::GET_DISPOSED_STATUS, data, want); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::SetDisposedRule( - const std::string &appId, DisposedRule &disposedRule, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to SetDisposedRule"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write appId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteParcelable(&disposedRule)) { - LOG_E(BMS_TAG_DEFAULT, "write disposedRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ErrCode ret = SendRequest(AppControlManagerInterfaceCode::SET_DISPOSED_RULE, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::SetDisposedRules( - std::vector &disposedRuleConfigurations, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call SetDisposedRules"); - if (disposedRuleConfigurations.empty() || disposedRuleConfigurations.size() > MAX_VECTOR_NUM) { - LOG_E(BMS_TAG_DEFAULT, "SetDisposedRules failed due to params error"); - return ERR_BUNDLE_MANAGER_PARAM_ERROR; - } - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - auto ret = WriteVectorToParcel(disposedRuleConfigurations, data); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "write DisposedRuleConfiguration failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ret = SendRequest(AppControlManagerInterfaceCode::SET_DISPOSED_RULES, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::GetDisposedRule(const std::string &appId, DisposedRule &rule, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to GetDisposedRule"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write appId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - ErrCode ret = GetParcelableInfo(AppControlManagerInterfaceCode::GET_DISPOSED_RULE, data, rule); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::GetAbilityRunningControlRule( - const std::string &bundleName, int32_t userId, std::vector &rules, int32_t appIndex) -{ - LOG_D(BMS_TAG_DEFAULT, "begin to call GetAbilityRunningControlRule"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(bundleName)) { - LOG_E(BMS_TAG_DEFAULT, "write bundleName failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(appIndex)) { - LOG_E(BMS_TAG_DEFAULT, "write appIndex failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return GetParcelableInfosWithErrCode(AppControlManagerInterfaceCode::GET_ABILITY_RUNNING_CONTROL_RULE, data, rules); -} - -ErrCode AppControlProxy::SetDisposedRuleForCloneApp( - const std::string &appId, DisposedRule &disposedRule, int32_t appIndex, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to SetDisposedRuleForCloneApp"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write appId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteParcelable(&disposedRule)) { - LOG_E(BMS_TAG_DEFAULT, "write disposedRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(appIndex)) { - LOG_E(BMS_TAG_DEFAULT, "write appIndex failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ErrCode ret = SendRequest(AppControlManagerInterfaceCode::SET_DISPOSED_RULE_FOR_CLONE_APP, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &rule, - int32_t appIndex, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to GetDisposedRuleForCloneApp"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write appId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(appIndex)) { - LOG_E(BMS_TAG_DEFAULT, "write appIndex failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - ErrCode ret = GetParcelableInfo(AppControlManagerInterfaceCode::GET_DISPOSED_RULE_FOR_CLONE_APP, - data, rule); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "proxy begin to DeleteDisposedRuleForCloneApp"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appId)) { - LOG_E(BMS_TAG_DEFAULT, "write appId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(appIndex)) { - LOG_E(BMS_TAG_DEFAULT, "write appIndex failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ErrCode ret = SendRequest(AppControlManagerInterfaceCode::DELETE_DISPOSED_RULE_FOR_CLONE_APP, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -bool AppControlProxy::WriteStringVector(const std::vector &stringVector, MessageParcel &data) -{ - if (!data.WriteInt32(stringVector.size())) { - LOG_E(BMS_TAG_DEFAULT, "write ParcelableVector failed"); - return false; - } - - for (auto &string : stringVector) { - if (!data.WriteString(string)) { - LOG_E(BMS_TAG_DEFAULT, "write string failed"); - return false; - } - } - return true; -} - -template -bool AppControlProxy::WriteParcelableVector(const std::vector &parcelableVector, MessageParcel &data) -{ - data.SetDataCapacity(Constants::CAPACITY_SIZE); - if (!data.WriteInt32(parcelableVector.size())) { - LOG_E(BMS_TAG_DEFAULT, "write ParcelableVector failed"); - return false; - } - - for (const auto &parcelable : parcelableVector) { - if (!data.WriteParcelable(&parcelable)) { - LOG_E(BMS_TAG_DEFAULT, "write ParcelableVector failed"); - return false; - } - } - return true; -} - -template -ErrCode AppControlProxy::GetParcelableInfo(AppControlManagerInterfaceCode code, MessageParcel& data, T& parcelableInfo) -{ - MessageParcel reply; - int32_t ret = SendRequest(code, data, reply); - if (ret != NO_ERROR) { - LOG_E(BMS_TAG_DEFAULT, "get return error=%{public}d from host", ret); - return ret; - } - ret = reply.ReadInt32(); - if (ret != NO_ERROR) { - return ret; - } - std::unique_ptr info(reply.ReadParcelable()); - if (info == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "ReadParcelable failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - parcelableInfo = *info; - LOG_D(BMS_TAG_DEFAULT, "GetParcelableInfo success"); - return NO_ERROR; -} - -int32_t AppControlProxy::GetParcelableInfos( - AppControlManagerInterfaceCode code, MessageParcel &data, std::vector &stringVector) -{ - MessageParcel reply; - int32_t ret = SendRequest(code, data, reply); - if (ret != NO_ERROR) { - return ret; - } - - int32_t infoSize = reply.ReadInt32(); - CONTAINER_SECURITY_VERIFY(reply, infoSize, &stringVector); - for (int32_t i = 0; i < infoSize; i++) { - stringVector.emplace_back(reply.ReadString()); - } - LOG_D(BMS_TAG_DEFAULT, "Read string vector success"); - return NO_ERROR; -} - -template -ErrCode AppControlProxy::GetParcelableInfosWithErrCode(AppControlManagerInterfaceCode code, MessageParcel &data, - std::vector &parcelableInfos) -{ - MessageParcel reply; - if (SendRequest(code, data, reply) != NO_ERROR) { - APP_LOGE("SendTransactCmd failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - ErrCode res = reply.ReadInt32(); - if (res == ERR_OK) { - int32_t infoSize = reply.ReadInt32(); - CONTAINER_SECURITY_VERIFY(reply, infoSize, &parcelableInfos); - for (int32_t i = 0; i < infoSize; i++) { - std::unique_ptr info(reply.ReadParcelable()); - if (info == nullptr) { - APP_LOGE("Read Parcelable infos failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - parcelableInfos.emplace_back(*info); - } - APP_LOGD("get parcelable infos success"); - } - APP_LOGD("GetParcelableInfosWithErrCode ErrCode : %{public}d", res); - return res; -} - -int32_t AppControlProxy::SendRequest(AppControlManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply) -{ - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "failed to send request %{public}hhu due to remote object null", code); - return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; - } - int32_t result = remote->SendRequest(static_cast(code), data, reply, option); - if (result != NO_ERROR) { - LOG_E(BMS_TAG_DEFAULT, "receive error code %{public}d in transact %{public}hhu", result, code); - } - return result; -} - -ErrCode AppControlProxy::SetUninstallDisposedRule(const std::string &appIdentifier, - const UninstallDisposedRule &uninstallDisposedRule, int32_t appIndex, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appIdentifier)) { - LOG_E(BMS_TAG_DEFAULT, "write appIdentifier failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteParcelable(&uninstallDisposedRule)) { - LOG_E(BMS_TAG_DEFAULT, "write uninstallDisposedRule failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(appIndex)) { - LOG_E(BMS_TAG_DEFAULT, "write appIndex failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ErrCode ret = SendRequest(AppControlManagerInterfaceCode::SET_UNINSTALL_DISPOSED_RULE, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, - int32_t userId, UninstallDisposedRule &rule) -{ - LOG_D(BMS_TAG_DEFAULT, "begin"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appIdentifier)) { - LOG_E(BMS_TAG_DEFAULT, "write appIdentifier failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(appIndex)) { - LOG_E(BMS_TAG_DEFAULT, "write appIndex failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - ErrCode ret = GetParcelableInfo( - AppControlManagerInterfaceCode::GET_UNINSTALL_DISPOSED_RULE, data, rule); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -ErrCode AppControlProxy::DeleteUninstallDisposedRule(const std::string &appIdentifier, - int32_t appIndex, int32_t userId) -{ - LOG_D(BMS_TAG_DEFAULT, "begin"); - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOG_E(BMS_TAG_DEFAULT, "WriteInterfaceToken failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteString(appIdentifier)) { - LOG_E(BMS_TAG_DEFAULT, "write appIdentifier failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(userId)) { - LOG_E(BMS_TAG_DEFAULT, "write userId failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - if (!data.WriteInt32(appIndex)) { - LOG_E(BMS_TAG_DEFAULT, "write appIndex failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - MessageParcel reply; - ErrCode ret = SendRequest( - AppControlManagerInterfaceCode::DELETE_UNINSTALL_DISPOSED_RULE, data, reply); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "SendRequest failed"); - return ret; - } - ret = reply.ReadInt32(); - if (ret != ERR_OK) { - LOG_E(BMS_TAG_DEFAULT, "host return error : %{public}d", ret); - return ret; - } - return ERR_OK; -} - -template -ErrCode AppControlProxy::WriteVectorToParcel(std::vector &parcelVector, MessageParcel &reply) -{ - MessageParcel tempParcel; - (void)tempParcel.SetMaxCapacity(Constants::MAX_PARCEL_CAPACITY); - if (!tempParcel.WriteInt32(static_cast(parcelVector.size()))) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - for (auto &parcel : parcelVector) { - if (!tempParcel.WriteParcelable(&parcel)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - } - - size_t dataSize = tempParcel.GetDataSize(); - if (!reply.WriteUint32(dataSize)) { - APP_LOGE("write failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - - if (dataSize > MAX_IPC_ALLOWED_CAPACITY) { - APP_LOGE("datasize is too large"); - return ERR_BUNDLE_MANAGER_PARAM_ERROR; - } - if (!reply.WriteRawData(reinterpret_cast(tempParcel.GetData()), dataSize)) { - APP_LOGE("write parcel failed"); - return ERR_APPEXECFWK_PARCEL_ERROR; - } - return ERR_OK; -} -} // AppExecFwk -} // OHOS \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/src/ipc/bundle_mgr_raw_data.cpp b/interfaces/inner_api/appexecfwk_core/src/ipc/bundle_mgr_raw_data.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eae62e4fd5f11425a2654957c6a453f12c8faadf --- /dev/null +++ b/interfaces/inner_api/appexecfwk_core/src/ipc/bundle_mgr_raw_data.cpp @@ -0,0 +1,55 @@ +/* + * 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 "ipc_types.h" +#include "securec.h" +#include "ipc/bundle_mgr_raw_data.h" + +namespace OHOS { +namespace AppExecFwk { +int32_t BundleMgrRawData::RawDataCpy(const void* readdata) +{ + if (readdata == nullptr || size == 0) { + return ERR_INVALID_DATA; + } + void* newData = malloc(size); + isMalloc = true; + if (newData == nullptr) { + isMalloc = false; + return ERR_INVALID_DATA; + } + if (memcpy_s(newData, size, readdata, size) != EOK) { + free(newData); + isMalloc = false; + return ERR_INVALID_DATA; + } + if (data != nullptr) { + free(const_cast(data)); + data = nullptr; + } + data = newData; + return ERR_NONE; +} + +BundleMgrRawData::~BundleMgrRawData() +{ + if (data != nullptr && isMalloc) { + free(const_cast(data)); + isMalloc = false; + data = nullptr; + } +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/app_control/js_app_control.cpp b/interfaces/kits/js/app_control/js_app_control.cpp index cfc2e1c56414aaf82c54e3541bc90a2ec77bd1ef..57054017591d978464920c00be1b2ac65f3fad77 100644 --- a/interfaces/kits/js/app_control/js_app_control.cpp +++ b/interfaces/kits/js/app_control/js_app_control.cpp @@ -17,7 +17,7 @@ #include #include "app_log_wrapper.h" -#include "app_control_interface.h" +#include "app_control_client.h" #include "bundle_constants.h" #include "bundle_mgr_interface.h" #include "bundle_mgr_proxy.h" @@ -25,6 +25,7 @@ #include "business_error.h" #include "common_func.h" #include "disposed_rule.h" +#include "iapp_control_mgr.h" #include "ipc_skeleton.h" #include "napi_arg.h" #include "napi_common_want.h" @@ -54,51 +55,34 @@ const char* SET_UNINSTALL_DISPOSED_RULE = "SetUninstallDisposedRule"; const char* DELETE_UNINSTALL_DISPOSED_RULE = "DeleteUninstallDisposedRule"; const char* GET_UNINSTALL_DISPOSED_RULE = "GetUninstallDisposedRule"; } -static OHOS::sptr GetAppControlProxy() -{ - auto bundleMgr = CommonFunc::GetBundleMgr(); - if (bundleMgr == nullptr) { - APP_LOGE("CommonFunc::GetBundleMgr failed"); - return nullptr; - } - auto appControlProxy = bundleMgr->GetAppControlProxy(); - if (appControlProxy == nullptr) { - APP_LOGE("GetAppControlProxy failed"); - return nullptr; - } - return appControlProxy; -} static ErrCode InnerGetDisposedStatus(napi_env, const std::string& appId, Want& disposedWant) { - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + ErrCode ret = AppControlClient::GetInstance().GetDisposedStatus(appId, disposedWant); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); return ERROR_SYSTEM_ABILITY_NOT_FOUND; } - ErrCode ret = appControlProxy->GetDisposedStatus(appId, disposedWant); return CommonFunc::ConvertErrCode(ret); } static ErrCode InnerSetDisposedStatus(napi_env, const std::string& appId, Want& disposedWant) { - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + ErrCode ret = AppControlClient::GetInstance().SetDisposedStatus(appId, disposedWant); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); return ERROR_SYSTEM_ABILITY_NOT_FOUND; } - ErrCode ret = appControlProxy->SetDisposedStatus(appId, disposedWant); return CommonFunc::ConvertErrCode(ret); } static ErrCode InnerDeleteDisposedStatus(napi_env, const std::string& appId) { - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + ErrCode ret = AppControlClient::GetInstance().DeleteDisposedStatus(appId); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); return ERROR_SYSTEM_ABILITY_NOT_FOUND; } - ErrCode ret = appControlProxy->DeleteDisposedStatus(appId); return CommonFunc::ConvertErrCode(ret); } @@ -213,15 +197,15 @@ napi_value SetDisposedStatusSync(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, DISPOSED_WANT, TYPE_WANT); return nRet; } - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + + ErrCode ret = AppControlClient::GetInstance().SetDisposedStatus(appId, want); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, SET_DISPOSED_STATUS_SYNC); napi_throw(env, error); return nRet; } - ErrCode ret = appControlProxy->SetDisposedStatus(appId, want); ret = CommonFunc::ConvertErrCode(ret); if (ret != NO_ERROR) { APP_LOGE("SetDisposedStatusSync err = %{public}d", ret); @@ -320,20 +304,19 @@ static napi_value InnerDeleteDisposedStatusSync(napi_env env, std::string &appId napi_throw(env, businessError); return nullptr; } - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + ErrCode ret = ERR_OK; + if (appIndex == Constants::MAIN_APP_INDEX) { + ret = AppControlClient::GetInstance().DeleteDisposedStatus(appId); + } else { + ret = AppControlClient::GetInstance().DeleteDisposedRuleForCloneApp(appId, appIndex); + } + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, DELETE_DISPOSED_STATUS_SYNC); napi_throw(env, error); return nullptr; } - ErrCode ret = ERR_OK; - if (appIndex == Constants::MAIN_APP_INDEX) { - ret = appControlProxy->DeleteDisposedStatus(appId); - } else { - ret = appControlProxy->DeleteDisposedRuleForCloneApp(appId, appIndex); - } ret = CommonFunc::ConvertErrCode(ret); if (ret != ERR_OK) { APP_LOGE("DeleteDisposedStatusSync failed"); @@ -478,16 +461,15 @@ napi_value GetDisposedStatusSync(napi_env env, napi_callback_info info) napi_throw(env, businessError); return nullptr; } - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + OHOS::AAFwk::Want disposedWant; + ErrCode ret = AppControlClient::GetInstance().GetDisposedStatus(appId, disposedWant); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, GET_DISPOSED_STATUS_SYNC); napi_throw(env, error); return nullptr; } - OHOS::AAFwk::Want disposedWant; - ErrCode ret = appControlProxy->GetDisposedStatus(appId, disposedWant); ret = CommonFunc::ConvertErrCode(ret); if (ret != ERR_OK) { APP_LOGE("GetDisposedStatusSync failed"); @@ -701,21 +683,20 @@ static napi_value InnerGetDisposedRule(napi_env env, std::string &appId, int32_t napi_throw(env, businessError); return nullptr; } - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + DisposedRule disposedRule; + ErrCode ret = ERR_OK; + if (appIndex == Constants::MAIN_APP_INDEX) { + ret = AppControlClient::GetInstance().GetDisposedRule(appId, disposedRule); + } else { + ret = AppControlClient::GetInstance().GetDisposedRuleForCloneApp(appId, disposedRule, appIndex); + } + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, GET_DISPOSED_STATUS_SYNC); napi_throw(env, error); return nullptr; } - DisposedRule disposedRule; - ErrCode ret = ERR_OK; - if (appIndex == Constants::MAIN_APP_INDEX) { - ret = appControlProxy->GetDisposedRule(appId, disposedRule); - } else { - ret = appControlProxy->GetDisposedRuleForCloneApp(appId, disposedRule, appIndex); - } ret = CommonFunc::ConvertErrCode(ret); if (ret != ERR_OK) { APP_LOGE("GetDisposedStatusSync failed"); @@ -764,20 +745,20 @@ static napi_value InnerSetDisposedRule(napi_env env, std::string &appId, Dispose { napi_value nRet; napi_get_undefined(env, &nRet); - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + + ErrCode ret = ERR_OK; + if (appIndex == Constants::MAIN_APP_INDEX) { + ret = AppControlClient::GetInstance().SetDisposedRule(appId, rule); + } else { + ret = AppControlClient::GetInstance().SetDisposedRuleForCloneApp(appId, rule, appIndex); + } + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null."); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, SET_DISPOSED_STATUS_SYNC); napi_throw(env, error); return nRet; } - ErrCode ret = ERR_OK; - if (appIndex == Constants::MAIN_APP_INDEX) { - ret = appControlProxy->SetDisposedRule(appId, rule); - } else { - ret = appControlProxy->SetDisposedRuleForCloneApp(appId, rule, appIndex); - } ret = CommonFunc::ConvertErrCode(ret); if (ret != NO_ERROR) { APP_LOGE("SetDisposedStatusSync err = %{public}d", ret); @@ -848,16 +829,15 @@ napi_value SetDisposedRules(napi_env env, napi_callback_info info) BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, DISPOSED_RULE, DISPOSED_RULE_TYPE); return nRet; } - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + int32_t userId = OHOS::IPCSkeleton::GetCallingUid() / Constants::BASE_USER_RANGE; + ErrCode ret = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, userId); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("AppControlProxy is null"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, GET_DISPOSED_STATUS_SYNC); napi_throw(env, error); return nullptr; } - int32_t userId = OHOS::IPCSkeleton::GetCallingUid() / Constants::BASE_USER_RANGE; - ErrCode ret = appControlProxy->SetDisposedRules(disposedRuleConfigurations, userId); ret = CommonFunc::ConvertErrCode(ret); if (ret != ERR_OK) { APP_LOGE("SetDisposedRules failed"); @@ -932,17 +912,17 @@ static napi_value InnerGetUninstallDisposedRule(napi_env env, std::string &appId napi_throw(env, businessError); return nullptr; } - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + UninstallDisposedRule uninstallDisposedRule; + ErrCode ret = ERR_OK; + ret = AppControlClient::GetInstance().GetUninstallDisposedRule(appIdentifier, appIndex, userId, + uninstallDisposedRule); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("null appControlProxy"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, GET_UNINSTALL_DISPOSED_RULE); napi_throw(env, error); return nullptr; } - UninstallDisposedRule uninstallDisposedRule; - ErrCode ret = ERR_OK; - ret = appControlProxy->GetUninstallDisposedRule(appIdentifier, appIndex, userId, uninstallDisposedRule); ret = CommonFunc::ConvertErrCode(ret); if (ret != ERR_OK) { APP_LOGE("GetUninstallDisposedRule failed"); @@ -993,16 +973,15 @@ static napi_value InnerSetUninstallDisposedRule(napi_env env, std::string &appId { napi_value nRet; napi_get_undefined(env, &nRet); - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + ErrCode ret = ERR_OK; + ret = AppControlClient::GetInstance().SetUninstallDisposedRule(appIdentifier, rule, appIndex, userId); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("null appControlProxy"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, SET_UNINSTALL_DISPOSED_RULE); napi_throw(env, error); return nRet; } - ErrCode ret = ERR_OK; - ret = appControlProxy->SetUninstallDisposedRule(appIdentifier, rule, appIndex, userId); ret = CommonFunc::ConvertErrCode(ret); if (ret != NO_ERROR) { APP_LOGE("SetUninstallDisposedRule err = %{public}d", ret); @@ -1071,16 +1050,15 @@ static napi_value InnerDeleteUninstallDisposedRule(napi_env env, std::string &ap napi_throw(env, businessError); return nullptr; } - auto appControlProxy = GetAppControlProxy(); - if (appControlProxy == nullptr) { + ErrCode ret = ERR_OK; + ret = AppControlClient::GetInstance().DeleteUninstallDisposedRule(appIdentifier, appIndex, userId); + if (ret == ERR_APPEXECFWK_NULL_PTR) { APP_LOGE("null appControlProxy"); napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND, DELETE_UNINSTALL_DISPOSED_RULE); napi_throw(env, error); return nullptr; } - ErrCode ret = ERR_OK; - ret = appControlProxy->DeleteUninstallDisposedRule(appIdentifier, appIndex, userId); ret = CommonFunc::ConvertErrCode(ret); if (ret != ERR_OK) { APP_LOGE("DeleteUninstallDisposedRule failed"); diff --git a/interfaces/kits/js/overlay/js_app_overlay.cpp b/interfaces/kits/js/overlay/js_app_overlay.cpp index 094102c2e73f282af5bdf693a662640362772d50..6a8c455a56290f1268909712965566abf501adb6 100644 --- a/interfaces/kits/js/overlay/js_app_overlay.cpp +++ b/interfaces/kits/js/overlay/js_app_overlay.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,12 +17,12 @@ #include #include "app_log_wrapper.h" -#include "app_control_interface.h" #include "bundle_mgr_interface.h" #include "bundle_mgr_proxy.h" #include "bundle_errors.h" #include "business_error.h" #include "common_func.h" +#include "iapp_control_mgr.h" #include "ipc_skeleton.h" #include "napi_arg.h" #include "napi_constants.h" diff --git a/services/bundlemgr/BUILD.gn b/services/bundlemgr/BUILD.gn index 8c854da0868eda7a9a4111da9bf47876c629a338..3b36baf24f538f5af55cd0f1fedc3461254b3c74 100644 --- a/services/bundlemgr/BUILD.gn +++ b/services/bundlemgr/BUILD.gn @@ -270,7 +270,10 @@ ohos_shared_library("libbms") { defines += [ "BUILD_VARIANT_USER" ] } - configs = [ ":bundlemgr_common_config" ] + configs = [ + ":bundlemgr_common_config", + "${core_path}:bundlemgr_ipc_public_config", + ] cflags = [ "-fvisibility=hidden", "-fdata-sections", @@ -456,6 +459,10 @@ ohos_shared_library("libbms") { configs += [ ":app_control_config" ] defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ] sources += app_control + deps += [ + "${core_path}:app_control_mgr_proxy", + "${core_path}:app_control_mgr_stub", + ] } if (bundle_framework_bundle_resource) { diff --git a/services/bundlemgr/include/app_control/app_control_manager_db_interface.h b/services/bundlemgr/include/app_control/app_control_manager_db_interface.h index b98a1c699a91778deb40e9e895146343edf18865..07b01da9d9b7412dfaacaa21e10087bf8e6cc09a 100644 --- a/services/bundlemgr/include/app_control/app_control_manager_db_interface.h +++ b/services/bundlemgr/include/app_control/app_control_manager_db_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,7 +19,7 @@ #include #include -#include "app_control_interface.h" +#include "iapp_control_mgr.h" #include "app_running_control_rule.h" namespace OHOS { diff --git a/services/bundlemgr/include/app_control/app_control_manager_host_impl.h b/services/bundlemgr/include/app_control/app_control_manager_host_impl.h index a9e7128c900c30c2de760c1659f73f2b956147c3..78038c5189e70259aa5fc9fbe2ee735694360445 100644 --- a/services/bundlemgr/include/app_control/app_control_manager_host_impl.h +++ b/services/bundlemgr/include/app_control/app_control_manager_host_impl.h @@ -16,89 +16,97 @@ #ifndef FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_HOST_IMPL_H #define FOUNDATION_BUNDLE_FRAMEWORK_SERVICE_INCLUDE_APP_CONTROL_MANAGER_HOST_IMPL_H -#include "app_control_host.h" +#include "app_control_mgr_stub.h" #include "app_control_manager.h" #include "bundle_data_mgr.h" #include "event_report.h" +#include "ipc/bundle_mgr_raw_data.h" namespace OHOS { namespace AppExecFwk { -class AppControlManagerHostImpl : public OHOS::AppExecFwk::AppControlHost { +class AppControlManagerHostImpl : public OHOS::AppExecFwk::AppControlMgrStub { public: AppControlManagerHostImpl(); virtual ~AppControlManagerHostImpl(); - virtual ErrCode AddAppInstallControlRule(const std::vector &appIds, - const AppInstallControlRuleType controlRuleType, int32_t userId) override; + int32_t CallbackEnter(uint32_t code) override; - virtual ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, - const std::vector &appIds, int32_t userId) override; + int32_t CallbackExit(uint32_t code, int32_t result) override; - virtual ErrCode DeleteAppInstallControlRule( - const AppInstallControlRuleType controlRuleType, int32_t userId) override; + ErrCode AddAppInstallControlRule(const std::vector &appIds, + const AppInstallControlRuleType controlRuleType, int32_t userId, int32_t &funcResult) override; - virtual ErrCode GetAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId, - std::vector &appIds) override; + ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, + const std::vector &appIds, int32_t userId, int32_t &funcResult) override; - // for app running control rule - virtual ErrCode AddAppRunningControlRule( - const std::vector &controlRules, int32_t userId) override; - virtual ErrCode DeleteAppRunningControlRule( - const std::vector &controlRules, int32_t userId) override; - virtual ErrCode DeleteAppRunningControlRule(int32_t userId) override; - virtual ErrCode GetAppRunningControlRule(int32_t userId, std::vector &appIds) override; - virtual ErrCode GetAppRunningControlRule( - const std::string &bundleName, int32_t userId, AppRunningControlRuleResult &controlRule) override; - - // for app jump control rule - virtual ErrCode ConfirmAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, - int32_t userId) override; - virtual ErrCode AddAppJumpControlRule(const std::vector &controlRules, int32_t userId) override; - virtual ErrCode DeleteAppJumpControlRule(const std::vector &controlRules, - int32_t userId) override; - virtual ErrCode DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId) override; - virtual ErrCode DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId) override; - virtual ErrCode GetAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, - int32_t userId, AppJumpControlRule &controlRule) override; - - virtual ErrCode SetDisposedStatus( - const std::string &appId, const Want &want, int32_t userId) override; - - virtual ErrCode DeleteDisposedStatus( - const std::string &appId, int32_t userId) override; + ErrCode DeleteAppInstallControlRule( + const AppInstallControlRuleType controlRuleType, int32_t userId, int32_t &funcResult) override; - virtual ErrCode GetDisposedStatus( - const std::string &appId, Want &want, int32_t userId) override; + ErrCode GetAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId, + std::vector &appIds, int32_t &funcResult) override; - virtual ErrCode SetDisposedRule( - const std::string &appId, DisposedRule &DisposedRule, int32_t userId) override; - - virtual ErrCode SetDisposedRules( - std::vector &disposedRuleConfigurations, int32_t userId) override; - - virtual ErrCode GetDisposedRule( - const std::string &appId, DisposedRule &DisposedRule, int32_t userId) override; + // for app running control rule + ErrCode AddAppRunningControlRule( + const std::vector &controlRules, int32_t userId, int32_t &funcResult) override; + ErrCode DeleteAppRunningControlRule( + const std::vector &controlRules, int32_t userId, int32_t &funcResult) override; + ErrCode DeleteAppRunningControlRule(int32_t userId, int32_t &funcResult) override; + ErrCode GetAppRunningControlRule(int32_t userId, std::vector &appIds, int32_t &funcResult) override; + ErrCode GetAppRunningControlRule(const std::string &bundleName, int32_t userId, + AppRunningControlRuleResult &controlRule, int32_t &funcResult) override; - virtual ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, - std::vector& disposedRules, int32_t appIndex = Constants::MAIN_APP_INDEX) override; + // for app jump control rule + ErrCode ConfirmAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, + int32_t userId, int32_t &funcResult) override; + ErrCode AddAppJumpControlRule(const std::vector &controlRules, int32_t userId, + int32_t &funcResult) override; + ErrCode DeleteAppJumpControlRule(const std::vector &controlRules, + int32_t userId, int32_t &funcResult) override; + ErrCode DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId, + int32_t &funcResult) override; + ErrCode DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId, + int32_t &funcResult) override; + ErrCode GetAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, + int32_t userId, AppJumpControlRule &controlRule, int32_t &funcResult) override; + + ErrCode SetDisposedStatus( + const std::string &appId, const Want &want, int32_t userId, int32_t &funcResult) override; + + ErrCode DeleteDisposedStatus( + const std::string &appId, int32_t userId, int32_t &funcResult) override; + + ErrCode GetDisposedStatus( + const std::string &appId, int32_t userId, Want &want, int32_t &funcResult) override; + + ErrCode SetDisposedRule( + const std::string &appId, int32_t userId, DisposedRule &DisposedRule, int32_t &funcResult) override; + + ErrCode SetDisposedRules(int32_t userId, BundleMgrRawData &disposedRuleConfigurationsRawData, + int32_t &funcResult) override; + + ErrCode GetDisposedRule( + const std::string &appId, int32_t userId, DisposedRule &DisposedRule, int32_t &funcResult) override; + + ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, + int32_t appIndex, std::vector& disposedRules, int32_t &funcResult) override; - virtual ErrCode SetDisposedRuleForCloneApp( - const std::string &appId, DisposedRule &DisposedRule, int32_t appIndex, int32_t userId) override; + ErrCode SetDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, int32_t userId, + DisposedRule &DisposedRule, int32_t &funcResult) override; - virtual ErrCode GetDisposedRuleForCloneApp( - const std::string &appId, DisposedRule &DisposedRule, int32_t appIndex, int32_t userId) override; + ErrCode GetDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, int32_t userId, + DisposedRule &DisposedRule, int32_t &funcResult) override; - virtual ErrCode DeleteDisposedRuleForCloneApp( - const std::string &appId, int32_t appIndex, int32_t userId) override; + ErrCode DeleteDisposedRuleForCloneApp( + const std::string &appId, int32_t appIndex, int32_t userId, int32_t &funcResult) override; - virtual ErrCode GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, - int32_t userId, UninstallDisposedRule &rule) override; + ErrCode GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, + int32_t userId, UninstallDisposedRule &rule, int32_t &funcResult) override; - virtual ErrCode SetUninstallDisposedRule(const std::string &appIdentifier, const UninstallDisposedRule &rule, - int32_t appIndex, int32_t userId) override; + ErrCode SetUninstallDisposedRule(const std::string &appIdentifier, const UninstallDisposedRule &rule, + int32_t appIndex, int32_t userId, int32_t &funcResult) override; - virtual ErrCode DeleteUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, - int32_t userId) override; + ErrCode DeleteUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, + int32_t userId, int32_t &funcResult) override; private: int32_t GetCallingUserId(); @@ -109,6 +117,8 @@ private: void SendAppControlEvent(ControlActionType actionType, ControlOperationType operationType, const std::string &callingName, int32_t userId, int32_t appIndex, const std::vector &appIds, const std::string &rule); + template + ErrCode GetVectorParcelInfo(BundleMgrRawData &rawData, std::vector &parcelInfos); std::shared_ptr appControlManager_ = nullptr; std::shared_ptr dataMgr_ = nullptr; diff --git a/services/bundlemgr/include/app_control/app_jump_interceptor_manager_db_interface.h b/services/bundlemgr/include/app_control/app_jump_interceptor_manager_db_interface.h index c3c430409cd4ff1f7a3eae23414911c0dc41e3c4..c53ca260a81830150676914feaac6b61899804de 100644 --- a/services/bundlemgr/include/app_control/app_jump_interceptor_manager_db_interface.h +++ b/services/bundlemgr/include/app_control/app_jump_interceptor_manager_db_interface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,7 +19,7 @@ #include #include -#include "app_control_interface.h" +#include "iapp_control_mgr.h" #include "app_jump_control_rule.h" namespace OHOS { diff --git a/services/bundlemgr/src/app_control/app_control_manager_host_impl.cpp b/services/bundlemgr/src/app_control/app_control_manager_host_impl.cpp index 62627d8cbfd41ba1f9ca3785c84f659f158ee6ec..d7a5df434e49bc50118a66d20d38ca61a81eb01c 100644 --- a/services/bundlemgr/src/app_control/app_control_manager_host_impl.cpp +++ b/services/bundlemgr/src/app_control/app_control_manager_host_impl.cpp @@ -20,10 +20,12 @@ #include "appexecfwk_errors.h" #include "app_control_constants.h" #include "bundle_constants.h" +#include "bundle_memory_guard.h" #include "bundle_mgr_service.h" #include "bundle_permission_mgr.h" #include "bundle_service_constants.h" #include "ipc_skeleton.h" +#include "parcel_macro.h" namespace OHOS { namespace AppExecFwk { @@ -31,7 +33,22 @@ namespace { constexpr const char* PERMISSION_DISPOSED_STATUS = "ohos.permission.MANAGE_DISPOSED_APP_STATUS"; constexpr const char* PERMISSION_GET_DISPOSED_STATUS = "ohos.permission.GET_DISPOSED_APP_STATUS"; constexpr const char* APP_MARKET_CALLING = "app market"; + const int16_t MAX_VECTOR_NUM = 1000; + constexpr size_t MAX_IPC_ALLOWED_CAPACITY = 100 * 1024 * 1024; // max ipc size 100MB } + +int32_t AppControlManagerHostImpl::CallbackEnter(uint32_t code) +{ + BundleMemoryGuard::SetBundleMemoryGuard(); + return ERR_NONE; +} + +int32_t AppControlManagerHostImpl::CallbackExit(uint32_t code, int32_t result) +{ + BundleMemoryGuard::ClearBundleMemoryGuard(); + return ERR_NONE; +} + AppControlManagerHostImpl::AppControlManagerHostImpl() { appControlManager_ = DelayedSingleton::GetInstance(); @@ -51,84 +68,97 @@ AppControlManagerHostImpl::~AppControlManagerHostImpl() } ErrCode AppControlManagerHostImpl::AddAppInstallControlRule(const std::vector &appIds, - const AppInstallControlRuleType controlRuleType, int32_t userId) + const AppInstallControlRuleType controlRuleType, int32_t userId, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "AddAppInstallControlRule start"); std::string callingName = GetCallingName(); std::string ruleType = GetControlRuleType(controlRuleType); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (ruleType.empty()) { LOG_E(BMS_TAG_DEFAULT, "controlRuleType is invalid"); - return ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + funcResult = ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->AddAppInstallControlRule(callingName, appIds, ruleType, userId); if (ret != ERR_OK) { LOG_E(BMS_TAG_DEFAULT, "AddAppInstallControlRule failed due to error %{public}d", ret); - return ret; + funcResult = ret; + return ERR_OK; } if (ruleType == AppControlConstants::APP_DISALLOWED_UNINSTALL) { UpdateAppControlledInfo(userId, appIds); } SendAppControlEvent(ControlActionType::INSTALL, ControlOperationType::ADD_RULE, callingName, userId, Constants::MAIN_APP_INDEX, appIds, ruleType); + funcResult = ERR_OK; return ERR_OK; } ErrCode AppControlManagerHostImpl::DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, - const std::vector &appIds, int32_t userId) + const std::vector &appIds, int32_t userId, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "DeleteAppInstallControlRule start"); std::string ruleType = GetControlRuleType(controlRuleType); if (ruleType.empty()) { LOG_E(BMS_TAG_DEFAULT, "controlRuleType is invalid"); - return ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + funcResult = ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + return ERR_OK; } std::string callingName = GetCallingName(); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->DeleteAppInstallControlRule(callingName, ruleType, appIds, userId); if (ret != ERR_OK) { LOG_E(BMS_TAG_DEFAULT, "DeleteAppInstallControlRule failed due to error %{public}d", ret); - return ret; + funcResult = ret; + return ERR_OK; } if (ruleType == AppControlConstants::APP_DISALLOWED_UNINSTALL) { UpdateAppControlledInfo(userId, appIds); } SendAppControlEvent(ControlActionType::INSTALL, ControlOperationType::REMOVE_RULE, callingName, userId, Constants::MAIN_APP_INDEX, appIds, ruleType); + funcResult = ERR_OK; return ERR_OK; } ErrCode AppControlManagerHostImpl::DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, - int32_t userId) + int32_t userId, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "CleanAppInstallControlRule start"); std::string callingName = GetCallingName(); std::string ruleType = GetControlRuleType(controlRuleType); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (ruleType.empty()) { LOG_E(BMS_TAG_DEFAULT, "controlRuleType is invalid"); - return ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + funcResult = ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } std::vector modifyAppIds; if (ruleType == AppControlConstants::APP_DISALLOWED_UNINSTALL) { @@ -141,50 +171,58 @@ ErrCode AppControlManagerHostImpl::DeleteAppInstallControlRule(const AppInstallC auto ret = appControlManager_->DeleteAppInstallControlRule(callingName, ruleType, userId); if (ret != ERR_OK) { LOG_E(BMS_TAG_DEFAULT, "CleanAppInstallControlRule failed due to error %{public}d", ret); - return ret; + funcResult = ret; + return ERR_OK; } if (ruleType == AppControlConstants::APP_DISALLOWED_UNINSTALL) { UpdateAppControlledInfo(userId, modifyAppIds); } SendAppControlEvent(ControlActionType::INSTALL, ControlOperationType::REMOVE_RULE, callingName, userId, Constants::MAIN_APP_INDEX, {}, ruleType); + funcResult = ERR_OK; return ERR_OK; } -ErrCode AppControlManagerHostImpl::GetAppInstallControlRule( - const AppInstallControlRuleType controlRuleType, int32_t userId, std::vector &appIds) +ErrCode AppControlManagerHostImpl::GetAppInstallControlRule(const AppInstallControlRuleType controlRuleType, + int32_t userId, std::vector &appIds, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "GetAppInstallControlRule start"); std::string callingName = GetCallingName(); std::string ruleType = GetControlRuleType(controlRuleType); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (ruleType.empty()) { LOG_E(BMS_TAG_DEFAULT, "controlRuleType is invalid"); - return ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + funcResult = ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - return appControlManager_->GetAppInstallControlRule(callingName, ruleType, userId, appIds); + funcResult = appControlManager_->GetAppInstallControlRule(callingName, ruleType, userId, appIds); + return ERR_OK; } ErrCode AppControlManagerHostImpl::AddAppRunningControlRule( - const std::vector &controlRules, int32_t userId) + const std::vector &controlRules, int32_t userId, int32_t &funcResult) { std::string callingName = GetCallingName(); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - ErrCode result = appControlManager_->AddAppRunningControlRule(callingName, controlRules, userId); + funcResult = appControlManager_->AddAppRunningControlRule(callingName, controlRules, userId); std::vector appIds; std::string rules; for (const auto &rule : controlRules) { @@ -193,152 +231,180 @@ ErrCode AppControlManagerHostImpl::AddAppRunningControlRule( } SendAppControlEvent(ControlActionType::RUNUING, ControlOperationType::ADD_RULE, callingName, userId, Constants::MAIN_APP_INDEX, appIds, rules); - return result; + return ERR_OK; } ErrCode AppControlManagerHostImpl::DeleteAppRunningControlRule( - const std::vector &controlRules, int32_t userId) + const std::vector &controlRules, int32_t userId, int32_t &funcResult) { std::string callingName = GetCallingName(); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } - ErrCode result = appControlManager_->DeleteAppRunningControlRule(callingName, controlRules, userId); + funcResult = appControlManager_->DeleteAppRunningControlRule(callingName, controlRules, userId); std::vector appIds; for (const auto &rule : controlRules) { appIds.emplace_back(rule.appId); } SendAppControlEvent(ControlActionType::RUNUING, ControlOperationType::REMOVE_RULE, callingName, userId, Constants::MAIN_APP_INDEX, appIds, Constants::EMPTY_STRING); - return result; + return ERR_OK; } -ErrCode AppControlManagerHostImpl::DeleteAppRunningControlRule(int32_t userId) +ErrCode AppControlManagerHostImpl::DeleteAppRunningControlRule(int32_t userId, int32_t &funcResult) { std::string callingName = GetCallingName(); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } - ErrCode result = appControlManager_->DeleteAppRunningControlRule(callingName, userId); + funcResult = appControlManager_->DeleteAppRunningControlRule(callingName, userId); SendAppControlEvent(ControlActionType::RUNUING, ControlOperationType::REMOVE_RULE, callingName, userId, Constants::MAIN_APP_INDEX, {}, Constants::EMPTY_STRING); - return result; + return ERR_OK; } -ErrCode AppControlManagerHostImpl::GetAppRunningControlRule(int32_t userId, std::vector &appIds) +ErrCode AppControlManagerHostImpl::GetAppRunningControlRule(int32_t userId, std::vector &appIds, + int32_t &funcResult) { std::string callingName = GetCallingName(); if (callingName.empty()) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } - return appControlManager_->GetAppRunningControlRule(callingName, userId, appIds); + funcResult = appControlManager_->GetAppRunningControlRule(callingName, userId, appIds); + return ERR_OK; } ErrCode AppControlManagerHostImpl::GetAppRunningControlRule( - const std::string &bundleName, int32_t userId, AppRunningControlRuleResult &controlRuleResult) + const std::string &bundleName, int32_t userId, AppRunningControlRuleResult &controlRuleResult, int32_t &funcResult) { if (bundleName.empty()) { LOG_NOFUNC_E(BMS_TAG_DEFAULT, "GetAppRunningControlRule bundleName is empty"); - return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; + funcResult = ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { LOG_W(BMS_TAG_DEFAULT, "calling permission denied, uid : %{public}d, pid : %{public}d", uid, OHOS::IPCSkeleton::GetCallingPid()); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - return appControlManager_->GetAppRunningControlRule(bundleName, userId, controlRuleResult); + funcResult = appControlManager_->GetAppRunningControlRule(bundleName, userId, controlRuleResult); + return ERR_OK; } ErrCode AppControlManagerHostImpl::ConfirmAppJumpControlRule(const std::string &callerBundleName, - const std::string &targetBundleName, int32_t userId) + const std::string &targetBundleName, int32_t userId, int32_t &funcResult) { int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid, uid : %{public}d", uid); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } - return appControlManager_->ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId); + funcResult = appControlManager_->ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId); + return ERR_OK; } ErrCode AppControlManagerHostImpl::AddAppJumpControlRule(const std::vector &controlRules, - int32_t userId) + int32_t userId, int32_t &funcResult) { int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid, uid : %{public}d", uid); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - return appControlManager_->AddAppJumpControlRule(controlRules, userId); + funcResult = appControlManager_->AddAppJumpControlRule(controlRules, userId); + return ERR_OK; } ErrCode AppControlManagerHostImpl::DeleteAppJumpControlRule(const std::vector &controlRules, - int32_t userId) + int32_t userId, int32_t &funcResult) { int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid, uid : %{public}d", uid); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - return appControlManager_->DeleteAppJumpControlRule(controlRules, userId); + funcResult = appControlManager_->DeleteAppJumpControlRule(controlRules, userId); + return ERR_OK; } -ErrCode AppControlManagerHostImpl::DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId) +ErrCode AppControlManagerHostImpl::DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId, + int32_t &funcResult) { int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid, uid : %{public}d", uid); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - return appControlManager_->DeleteRuleByCallerBundleName(callerBundleName, userId); + funcResult = appControlManager_->DeleteRuleByCallerBundleName(callerBundleName, userId); + return ERR_OK; } -ErrCode AppControlManagerHostImpl::DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId) +ErrCode AppControlManagerHostImpl::DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId, + int32_t &funcResult) { int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { LOG_E(BMS_TAG_DEFAULT, "callingName is invalid, uid : %{public}d", uid); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } - return appControlManager_->DeleteRuleByTargetBundleName(targetBundleName, userId); + funcResult = appControlManager_->DeleteRuleByTargetBundleName(targetBundleName, userId); + return ERR_OK; } ErrCode AppControlManagerHostImpl::GetAppJumpControlRule(const std::string &callerBundleName, - const std::string &targetBundleName, int32_t userId, AppJumpControlRule &controlRule) + const std::string &targetBundleName, int32_t userId, AppJumpControlRule &controlRule, int32_t &funcResult) { int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { LOG_W(BMS_TAG_DEFAULT, "calling permission denied, uid : %{public}d", uid); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - return appControlManager_->GetAppJumpControlRule(callerBundleName, targetBundleName, userId, controlRule); + funcResult = appControlManager_->GetAppJumpControlRule(callerBundleName, targetBundleName, userId, controlRule); + return ERR_OK; } std::string AppControlManagerHostImpl::GetCallingName() @@ -367,23 +433,27 @@ int32_t AppControlManagerHostImpl::GetCallingUserId() return OHOS::IPCSkeleton::GetCallingUid() / Constants::BASE_USER_RANGE; } -ErrCode AppControlManagerHostImpl::SetDisposedStatus(const std::string &appId, const Want &want, int32_t userId) +ErrCode AppControlManagerHostImpl::SetDisposedStatus(const std::string &appId, const Want &want, int32_t userId, + int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to SetDisposedStatus"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (userId == Constants::UNSPECIFIED_USERID) { userId = GetCallingUserId(); } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } ErrCode ret = appControlManager_->SetDisposedStatus(appId, want, userId); if (ret != ERR_OK) { @@ -391,26 +461,30 @@ ErrCode AppControlManagerHostImpl::SetDisposedStatus(const std::string &appId, c } SendAppControlEvent(ControlActionType::DISPOSE_STATUS, ControlOperationType::ADD_RULE, APP_MARKET_CALLING, userId, Constants::MAIN_APP_INDEX, { appId }, Constants::EMPTY_STRING); - return ret; + funcResult = ret; + return ERR_OK; } -ErrCode AppControlManagerHostImpl::DeleteDisposedStatus(const std::string &appId, int32_t userId) +ErrCode AppControlManagerHostImpl::DeleteDisposedStatus(const std::string &appId, int32_t userId, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to DeleteDisposedStatus"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (userId == Constants::UNSPECIFIED_USERID) { userId = GetCallingUserId(); } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } ErrCode ret = appControlManager_->DeleteDisposedStatus(appId, userId); if (ret != ERR_OK) { @@ -425,33 +499,39 @@ ErrCode AppControlManagerHostImpl::DeleteDisposedStatus(const std::string &appId ret = appControlManager_->DeleteDisposedRule(callerName, appId, Constants::MAIN_APP_INDEX, userId); SendAppControlEvent(ControlActionType::DISPOSE_STATUS, ControlOperationType::REMOVE_RULE, callerName, userId, Constants::MAIN_APP_INDEX, { appId }, Constants::EMPTY_STRING); - return ret; + funcResult = ret; + return ERR_OK; } -ErrCode AppControlManagerHostImpl::GetDisposedStatus(const std::string &appId, Want &want, int32_t userId) +ErrCode AppControlManagerHostImpl::GetDisposedStatus(const std::string &appId, int32_t userId, Want &want, + int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to GetDisposedStatus"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionsForAll({PERMISSION_DISPOSED_STATUS, PERMISSION_GET_DISPOSED_STATUS})) { LOG_W(BMS_TAG_DEFAULT, "verify get disposed status permission failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (userId == Constants::UNSPECIFIED_USERID) { userId = GetCallingUserId(); } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } ErrCode ret = appControlManager_->GetDisposedStatus(appId, want, userId); if (ret != ERR_OK) { LOG_W(BMS_TAG_DEFAULT, "host GetDisposedStatus error:%{public}d", ret); } - return ret; + funcResult = ret; + return ERR_OK; } void AppControlManagerHostImpl::UpdateAppControlledInfo(int32_t userId, @@ -521,17 +601,20 @@ void AppControlManagerHostImpl::GetCallerByUid(const int32_t uid, std::string &c } } -ErrCode AppControlManagerHostImpl::GetDisposedRule(const std::string &appId, DisposedRule &rule, int32_t userId) +ErrCode AppControlManagerHostImpl::GetDisposedRule(const std::string &appId, int32_t userId, DisposedRule &rule, + int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to GetDisposedRule"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionsForAll({PERMISSION_DISPOSED_STATUS, PERMISSION_GET_DISPOSED_STATUS})) { LOG_W(BMS_TAG_DEFAULT, "verify get disposed rule permission failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); @@ -542,30 +625,47 @@ ErrCode AppControlManagerHostImpl::GetDisposedRule(const std::string &appId, Dis } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->GetDisposedRule(callerName, appId, rule, Constants::MAIN_APP_INDEX, userId); if (ret != ERR_OK) { LOG_W(BMS_TAG_DEFAULT, "host GetDisposedStatus error:%{public}d", ret); } - return ret; + funcResult = ret; + return ERR_OK; } ErrCode AppControlManagerHostImpl::SetDisposedRules( - std::vector &disposedRuleConfigurations, int32_t userId) + int32_t userId, BundleMgrRawData &disposedRuleConfigurationsRawData, int32_t &funcResult) { + std::vector disposedRuleConfigurations; + auto ret = GetVectorParcelInfo(disposedRuleConfigurationsRawData, disposedRuleConfigurations); + if (ret != ERR_OK) { + LOG_E(BMS_TAG_DEFAULT, "SetDisposedRules read DisposedRuleConfiguration failed"); + funcResult = ret; + return ERR_OK; + } + if (disposedRuleConfigurations.empty() || disposedRuleConfigurations.size() > MAX_VECTOR_NUM) { + LOG_E(BMS_TAG_DEFAULT, "disposedRuleConfiguration count is error"); + funcResult = ERR_BUNDLE_MANAGER_PARAM_ERROR; + return ERR_OK; + } LOG_I(BMS_TAG_DEFAULT, "host begin to SetDisposedRules"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); @@ -582,22 +682,27 @@ ErrCode AppControlManagerHostImpl::SetDisposedRules( if (ret != ERR_OK) { LOG_E(BMS_TAG_DEFAULT, "host SetDisposedRules error:%{public}d", ret); - return ret; + funcResult = ret; + return ERR_OK; } } + funcResult = ERR_OK; return ERR_OK; } -ErrCode AppControlManagerHostImpl::SetDisposedRule(const std::string &appId, DisposedRule &rule, int32_t userId) +ErrCode AppControlManagerHostImpl::SetDisposedRule(const std::string &appId, int32_t userId, DisposedRule &rule, + int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to SetDisposedRule"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); @@ -611,7 +716,8 @@ ErrCode AppControlManagerHostImpl::SetDisposedRule(const std::string &appId, Dis } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->SetDisposedRule(callerName, appId, rule, Constants::MAIN_APP_INDEX, userId); if (ret != ERR_OK) { @@ -619,41 +725,47 @@ ErrCode AppControlManagerHostImpl::SetDisposedRule(const std::string &appId, Dis } SendAppControlEvent(ControlActionType::DISPOSE_RULE, ControlOperationType::ADD_RULE, callerName, userId, Constants::MAIN_APP_INDEX, { appId }, rule.ToString()); - return ret; + funcResult = ret; + return ERR_OK; } ErrCode AppControlManagerHostImpl::GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, - std::vector& disposedRules, int32_t appIndex) + int32_t appIndex, std::vector& disposedRules, int32_t &funcResult) { int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); if (uid != AppControlConstants::FOUNDATION_UID) { - LOG_E(BMS_TAG_DEFAULT, "uid:%{public}d is forbidden", uid); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + LOG_E(BMS_TAG_DEFAULT, "callingName is invalid, uid : %{public}d", uid); + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } - return appControlManager_->GetAbilityRunningControlRule(bundleName, appIndex, userId, - disposedRules); + funcResult = appControlManager_->GetAbilityRunningControlRule(bundleName, appIndex, userId, disposedRules); + return ERR_OK; } -ErrCode AppControlManagerHostImpl::GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &rule, - int32_t appIndex, int32_t userId) +ErrCode AppControlManagerHostImpl::GetDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, + int32_t userId, DisposedRule &rule, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to GetDisposedRuleForCloneApp"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionsForAll({PERMISSION_DISPOSED_STATUS, PERMISSION_GET_DISPOSED_STATUS})) { LOG_W(BMS_TAG_DEFAULT, "verify get disposed rule permission failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (appIndex < Constants::MAIN_APP_INDEX || appIndex > ServiceConstants::CLONE_APP_INDEX_MAX) { LOG_E(BMS_TAG_DEFAULT, "appIndex %{public}d is invalid", appIndex); - return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + funcResult = ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); std::string callerName; @@ -663,30 +775,35 @@ ErrCode AppControlManagerHostImpl::GetDisposedRuleForCloneApp(const std::string } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->GetDisposedRule(callerName, appId, rule, appIndex, userId); if (ret != ERR_OK) { LOG_W(BMS_TAG_DEFAULT, "GetDisposedRuleForCloneApp error:%{public}d, appIndex:%{public}d", ret, appIndex); } - return ret; + funcResult = ret; + return ERR_OK; } -ErrCode AppControlManagerHostImpl::SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &rule, - int32_t appIndex, int32_t userId) +ErrCode AppControlManagerHostImpl::SetDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, + int32_t userId, DisposedRule &rule, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to SetDisposedRuleForCloneApp"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (appIndex < Constants::MAIN_APP_INDEX || appIndex > ServiceConstants::CLONE_APP_INDEX_MAX) { LOG_E(BMS_TAG_DEFAULT, "appIndex %{public}d is invalid", appIndex); - return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + funcResult = ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); std::string callerName; @@ -699,7 +816,8 @@ ErrCode AppControlManagerHostImpl::SetDisposedRuleForCloneApp(const std::string } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->SetDisposedRule(callerName, appId, rule, appIndex, userId); if (ret != ERR_OK) { @@ -707,30 +825,35 @@ ErrCode AppControlManagerHostImpl::SetDisposedRuleForCloneApp(const std::string } SendAppControlEvent(ControlActionType::DISPOSE_RULE, ControlOperationType::ADD_RULE, callerName, userId, appIndex, { appId }, rule.ToString()); - return ret; + funcResult = ret; + return ERR_OK; } ErrCode AppControlManagerHostImpl::DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, - int32_t userId) + int32_t userId, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "host begin to DeleteDisposedRuleForCloneApp"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (appIndex < Constants::MAIN_APP_INDEX || appIndex > ServiceConstants::CLONE_APP_INDEX_MAX) { LOG_E(BMS_TAG_DEFAULT, "appIndex %{public}d is invalid", appIndex); - return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + funcResult = ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + return ERR_OK; } if (userId == Constants::UNSPECIFIED_USERID) { userId = GetCallingUserId(); } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "appControlManager_ is nullptr"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } ErrCode ret = ERR_OK; if (appIndex == Constants::MAIN_APP_INDEX) { @@ -751,74 +874,86 @@ ErrCode AppControlManagerHostImpl::DeleteDisposedRuleForCloneApp(const std::stri } SendAppControlEvent(ControlActionType::DISPOSE_RULE, ControlOperationType::REMOVE_RULE, callerName, userId, appIndex, { appId }, Constants::EMPTY_STRING); - return ret; + funcResult = ret; + return ERR_OK; } ErrCode AppControlManagerHostImpl::GetUninstallDisposedRule(const std::string &appIdentifier, - int32_t appIndex, int32_t userId, UninstallDisposedRule &rule) + int32_t appIndex, int32_t userId, UninstallDisposedRule &rule, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "begin"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionsForAll({PERMISSION_DISPOSED_STATUS, PERMISSION_GET_DISPOSED_STATUS})) { LOG_W(BMS_TAG_DEFAULT, "verify get uninstall disposed rule permission failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (appIndex < Constants::MAIN_APP_INDEX || appIndex > ServiceConstants::CLONE_APP_INDEX_MAX) { LOG_E(BMS_TAG_DEFAULT, "appIndex %{public}d is invalid", appIndex); - return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + funcResult = ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + return ERR_OK; } if (userId == Constants::UNSPECIFIED_USERID) { userId = GetCallingUserId(); } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "null appControlManager_"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->GetUninstallDisposedRule(appIdentifier, appIndex, userId, rule); if (ret != ERR_OK) { LOG_W(BMS_TAG_DEFAULT, "error:%{public}d, appIndex:%{public}d", ret, appIndex); } - return ret; + funcResult = ret; + return ERR_OK; } ErrCode AppControlManagerHostImpl::SetUninstallDisposedRule(const std::string &appIdentifier, - const UninstallDisposedRule &rule, int32_t appIndex, int32_t userId) + const UninstallDisposedRule &rule, int32_t appIndex, int32_t userId, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "begin"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (appIndex < Constants::MAIN_APP_INDEX || appIndex > ServiceConstants::CLONE_APP_INDEX_MAX) { LOG_E(BMS_TAG_DEFAULT, "appIndex %{public}d is invalid", appIndex); - return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + funcResult = ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); std::string callerName; GetCallerByUid(uid, callerName); if (rule.want == nullptr) { LOG_E(BMS_TAG_DEFAULT, "null want"); - return ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE; + funcResult = ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE; + return ERR_OK; } if (!BundlePermissionMgr::IsNativeTokenType() && callerName != rule.want->GetBundle()) { LOG_E(BMS_TAG_DEFAULT, "callerName is not equal to bundleName in want"); - return ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE; + funcResult = ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE; + return ERR_OK; } if (userId == Constants::UNSPECIFIED_USERID) { userId = GetCallingUserId(); } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "null appControlManager_"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } auto ret = appControlManager_->SetUninstallDisposedRule(callerName, appIdentifier, rule, appIndex, userId); if (ret != ERR_OK) { @@ -827,31 +962,36 @@ ErrCode AppControlManagerHostImpl::SetUninstallDisposedRule(const std::string &a } SendAppControlEvent(ControlActionType::UNINSTALL_DISPOSE_RULE, ControlOperationType::ADD_RULE, callerName, userId, appIndex, { appIdentifier }, rule.ToString()); - return ret; + funcResult = ret; + return ERR_OK; } ErrCode AppControlManagerHostImpl::DeleteUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, - int32_t userId) + int32_t userId, int32_t &funcResult) { LOG_D(BMS_TAG_DEFAULT, "begin"); if (!BundlePermissionMgr::IsSystemApp()) { LOG_E(BMS_TAG_DEFAULT, "non-system app calling system api"); - return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + funcResult = ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + return ERR_OK; } if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) { LOG_W(BMS_TAG_DEFAULT, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed"); - return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + funcResult = ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + return ERR_OK; } if (appIndex < Constants::MAIN_APP_INDEX || appIndex > ServiceConstants::CLONE_APP_INDEX_MAX) { LOG_E(BMS_TAG_DEFAULT, "appIndex %{public}d is invalid", appIndex); - return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + funcResult = ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE; + return ERR_OK; } if (userId == Constants::UNSPECIFIED_USERID) { userId = GetCallingUserId(); } if (!appControlManager_) { LOG_E(BMS_TAG_DEFAULT, "null appControlManager_"); - return ERR_APPEXECFWK_NULL_PTR; + funcResult = ERR_APPEXECFWK_NULL_PTR; + return ERR_OK; } int32_t uid = OHOS::IPCSkeleton::GetCallingUid(); std::string callerName; @@ -865,7 +1005,8 @@ ErrCode AppControlManagerHostImpl::DeleteUninstallDisposedRule(const std::string } SendAppControlEvent(ControlActionType::UNINSTALL_DISPOSE_RULE, ControlOperationType::REMOVE_RULE, callerName, userId, appIndex, { appIdentifier }, Constants::EMPTY_STRING); - return ret; + funcResult = ret; + return ERR_OK; } void AppControlManagerHostImpl::SendAppControlEvent(ControlActionType actionType, ControlOperationType operationType, @@ -882,5 +1023,35 @@ void AppControlManagerHostImpl::SendAppControlEvent(ControlActionType actionType info.rule = rule; EventReport::SendAppControlRuleEvent(info); } + +template +ErrCode AppControlManagerHostImpl::GetVectorParcelInfo(BundleMgrRawData &rawData, + std::vector &parcelInfos) +{ + size_t dataSize = rawData.size; + if (dataSize > MAX_IPC_ALLOWED_CAPACITY) { + APP_LOGE("dataSize is too large"); + return ERR_BUNDLE_MANAGER_PARAM_ERROR; + } + + MessageParcel tempParcel; + if (!tempParcel.ParseFrom(reinterpret_cast(rawData.data), dataSize)) { + APP_LOGE("Fail to ParseFrom"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + int32_t infoSize = tempParcel.ReadInt32(); + CONTAINER_SECURITY_VERIFY(tempParcel, infoSize, &parcelInfos); + for (int32_t i = 0; i < infoSize; i++) { + std::unique_ptr info(tempParcel.ReadParcelable()); + if (info == nullptr) { + APP_LOGE("Read Parcelable infos failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + parcelInfos.emplace_back(*info); + } + + return ERR_OK; +} } // AppExecFwk } // OHOS \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_app_control_proxy_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_app_control_proxy_test/BUILD.gn index f31d7c71782d29ad1b17ea755636d609a0ba21f3..eb09ac6e5138407a4f8770634d4b329ef4eb15ad 100644 --- a/services/bundlemgr/test/unittest/bms_app_control_proxy_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_app_control_proxy_test/BUILD.gn @@ -35,6 +35,7 @@ ohos_unittest("BmsAppControlProxyTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] defines = [ "APP_LOG_TAG = \"BundleMgrTool\"" ] diff --git a/services/bundlemgr/test/unittest/bms_app_control_proxy_test/bms_app_control_proxy_test.cpp b/services/bundlemgr/test/unittest/bms_app_control_proxy_test/bms_app_control_proxy_test.cpp index 9682ed579fede42bb7a6c925a91208bc6aea0dcd..e73ffa5760953b79f28070ca6cbbf970644bf895 100644 --- a/services/bundlemgr/test/unittest/bms_app_control_proxy_test/bms_app_control_proxy_test.cpp +++ b/services/bundlemgr/test/unittest/bms_app_control_proxy_test/bms_app_control_proxy_test.cpp @@ -17,7 +17,10 @@ #include #include #define private public -#include "app_control_proxy.h" +#include "app_control_client.h" +#include "app_control_mgr_proxy.h" +#include "appexecfwk_errors.h" +#include "bundle_constants.h" #undef private #include "want.h" @@ -91,11 +94,10 @@ void BmsAppControlProxyTest::TearDown() */ HWTEST_F(BmsAppControlProxyTest, AddAppInstallControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); std::vector appIds; AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; int32_t userId = 100; - auto res = appControlProxy.AddAppInstallControlRule(appIds, controlRuleType, userId); + auto res = AppControlClient::GetInstance().AddAppInstallControlRule(appIds, controlRuleType, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -107,14 +109,15 @@ HWTEST_F(BmsAppControlProxyTest, AddAppInstallControlRule_0100, Function | Mediu */ HWTEST_F(BmsAppControlProxyTest, AddAppInstallControlRule_0200, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::vector appIds; std::string appId = "appId"; appIds.emplace_back(appId); AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; int32_t userId = 100; - auto res = appControlProxy.AddAppInstallControlRule(appIds, controlRuleType, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.AddAppInstallControlRule(appIds, controlRuleType, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -125,11 +128,10 @@ HWTEST_F(BmsAppControlProxyTest, AddAppInstallControlRule_0200, Function | Mediu */ HWTEST_F(BmsAppControlProxyTest, DeleteAppInstallControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); std::vector appIds; AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; int32_t userId = 100; - auto res = appControlProxy.DeleteAppInstallControlRule(controlRuleType, appIds, userId); + auto res = AppControlClient::GetInstance().DeleteAppInstallControlRule(controlRuleType, appIds, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -141,14 +143,15 @@ HWTEST_F(BmsAppControlProxyTest, DeleteAppInstallControlRule_0100, Function | Me */ HWTEST_F(BmsAppControlProxyTest, DeleteAppInstallControlRule_0200, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::vector appIds; std::string appId = "appId"; appIds.emplace_back(appId); AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; int32_t userId = 100; - auto res = appControlProxy.DeleteAppInstallControlRule(controlRuleType, appIds, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteAppInstallControlRule(controlRuleType, appIds, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -159,11 +162,12 @@ HWTEST_F(BmsAppControlProxyTest, DeleteAppInstallControlRule_0200, Function | Me */ HWTEST_F(BmsAppControlProxyTest, BmsDeleteAppInstallControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; int32_t userId = 100; - auto res = appControlProxy.DeleteAppInstallControlRule(controlRuleType, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteAppInstallControlRule(controlRuleType, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -174,12 +178,13 @@ HWTEST_F(BmsAppControlProxyTest, BmsDeleteAppInstallControlRule_0100, Function | */ HWTEST_F(BmsAppControlProxyTest, GetAppInstallControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; int32_t userId = 100; std::vector appIds; - auto res = appControlProxy.GetAppInstallControlRule(controlRuleType, userId, appIds); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.GetAppInstallControlRule(controlRuleType, userId, appIds, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -190,10 +195,9 @@ HWTEST_F(BmsAppControlProxyTest, GetAppInstallControlRule_0100, Function | Mediu */ HWTEST_F(BmsAppControlProxyTest, AddAppRunningControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); std::vector controlRules; int32_t userId = 100; - auto res = appControlProxy.AddAppRunningControlRule(controlRules, userId); + auto res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -205,13 +209,14 @@ HWTEST_F(BmsAppControlProxyTest, AddAppRunningControlRule_0100, Function | Mediu */ HWTEST_F(BmsAppControlProxyTest, AddAppRunningControlRule_0200, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::vector controlRules; AppRunningControlRule appRunningControlRule; controlRules.emplace_back(appRunningControlRule); int32_t userId = 100; - auto res = appControlProxy.AddAppRunningControlRule(controlRules, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.AddAppRunningControlRule(controlRules, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -222,10 +227,9 @@ HWTEST_F(BmsAppControlProxyTest, AddAppRunningControlRule_0200, Function | Mediu */ HWTEST_F(BmsAppControlProxyTest, DeleteAppRunningControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); std::vector controlRules; int32_t userId = 100; - auto res = appControlProxy.DeleteAppRunningControlRule(controlRules, userId); + auto res = AppControlClient::GetInstance().DeleteAppRunningControlRule(controlRules, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -237,13 +241,14 @@ HWTEST_F(BmsAppControlProxyTest, DeleteAppRunningControlRule_0100, Function | Me */ HWTEST_F(BmsAppControlProxyTest, DeleteAppRunningControlRule_0200, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::vector controlRules; AppRunningControlRule appRunningControlRule; controlRules.emplace_back(appRunningControlRule); int32_t userId = 100; - auto res = appControlProxy.DeleteAppRunningControlRule(controlRules, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteAppRunningControlRule(controlRules, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -254,10 +259,11 @@ HWTEST_F(BmsAppControlProxyTest, DeleteAppRunningControlRule_0200, Function | Me */ HWTEST_F(BmsAppControlProxyTest, BmsDeleteAppRunningControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; - auto res = appControlProxy.DeleteAppRunningControlRule(userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteAppRunningControlRule(userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -268,11 +274,12 @@ HWTEST_F(BmsAppControlProxyTest, BmsDeleteAppRunningControlRule_0100, Function | */ HWTEST_F(BmsAppControlProxyTest, GetAppRunningControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::vector appIds; - auto res = appControlProxy.GetAppRunningControlRule(userId, appIds); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.GetAppRunningControlRule(userId, appIds, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -283,12 +290,13 @@ HWTEST_F(BmsAppControlProxyTest, GetAppRunningControlRule_0100, Function | Mediu */ HWTEST_F(BmsAppControlProxyTest, BmsGetAppRunningControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::string bundleName; AppRunningControlRuleResult controlRuleResult; - auto res = appControlProxy.GetAppRunningControlRule(bundleName, userId, controlRuleResult); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.GetAppRunningControlRule(bundleName, userId, controlRuleResult, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -299,11 +307,10 @@ HWTEST_F(BmsAppControlProxyTest, BmsGetAppRunningControlRule_0100, Function | Me */ HWTEST_F(BmsAppControlProxyTest, ConfirmAppJumpControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); int32_t userId = 100; std::string callerBundleName; const std::string targetBundleName; - auto res = appControlProxy.ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId); + auto res = AppControlClient::GetInstance().ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -315,12 +322,13 @@ HWTEST_F(BmsAppControlProxyTest, ConfirmAppJumpControlRule_0100, Function | Medi */ HWTEST_F(BmsAppControlProxyTest, ConfirmAppJumpControlRule_0200, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::string callerBundleName = "callerBundleName"; const std::string targetBundleName = "targetBundleName"; - auto res = appControlProxy.ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.ConfirmAppJumpControlRule(callerBundleName, targetBundleName, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -331,10 +339,9 @@ HWTEST_F(BmsAppControlProxyTest, ConfirmAppJumpControlRule_0200, Function | Medi */ HWTEST_F(BmsAppControlProxyTest, AddAppJumpControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); int32_t userId = 100; std::vector controlRules; - auto res = appControlProxy.AddAppJumpControlRule(controlRules, userId); + auto res = AppControlClient::GetInstance().AddAppJumpControlRule(controlRules, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -346,13 +353,14 @@ HWTEST_F(BmsAppControlProxyTest, AddAppJumpControlRule_0100, Function | MediumTe */ HWTEST_F(BmsAppControlProxyTest, AddAppJumpControlRule_0200, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::vector controlRules; AppJumpControlRule appJumpControlRule; controlRules.emplace_back(appJumpControlRule); - auto res = appControlProxy.AddAppJumpControlRule(controlRules, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.AddAppJumpControlRule(controlRules, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -363,13 +371,14 @@ HWTEST_F(BmsAppControlProxyTest, AddAppJumpControlRule_0200, Function | MediumTe */ HWTEST_F(BmsAppControlProxyTest, DeleteAppJumpControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::vector controlRules; AppJumpControlRule appJumpControlRule; controlRules.emplace_back(appJumpControlRule); - auto res = appControlProxy.DeleteAppJumpControlRule(controlRules, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteAppJumpControlRule(controlRules, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -380,11 +389,12 @@ HWTEST_F(BmsAppControlProxyTest, DeleteAppJumpControlRule_0100, Function | Mediu */ HWTEST_F(BmsAppControlProxyTest, DeleteRuleByCallerBundleName_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::string callerBundleName = "callerBundleName"; - auto res = appControlProxy.DeleteRuleByCallerBundleName(callerBundleName, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteRuleByCallerBundleName(callerBundleName, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -395,11 +405,12 @@ HWTEST_F(BmsAppControlProxyTest, DeleteRuleByCallerBundleName_0100, Function | M */ HWTEST_F(BmsAppControlProxyTest, DeleteRuleByTargetBundleName_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::string targetBundleName = "targetBundleName"; - auto res = appControlProxy.DeleteRuleByTargetBundleName(targetBundleName, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteRuleByTargetBundleName(targetBundleName, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -410,14 +421,16 @@ HWTEST_F(BmsAppControlProxyTest, DeleteRuleByTargetBundleName_0100, Function | M */ HWTEST_F(BmsAppControlProxyTest, GetAppJumpControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); int32_t userId = 100; std::string callerBundleName = "callerBundleName"; std::string targetBundleName = "targetBundleName"; std::vector controlRules; AppJumpControlRule appJumpControlRule; - auto res = appControlProxy.GetAppJumpControlRule(callerBundleName, targetBundleName, userId, appJumpControlRule); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.GetAppJumpControlRule(callerBundleName, targetBundleName, userId, appJumpControlRule, + funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -428,12 +441,13 @@ HWTEST_F(BmsAppControlProxyTest, GetAppJumpControlRule_0100, Function | MediumTe */ HWTEST_F(BmsAppControlProxyTest, SetDisposedStatus_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::string appId = "appId"; Want want; int32_t userId = 100; - auto res = appControlProxy.SetDisposedStatus(appId, want, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.SetDisposedStatus(appId, want, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -444,11 +458,12 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedStatus_0100, Function | MediumTest | */ HWTEST_F(BmsAppControlProxyTest, DeleteDisposedStatus_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::string appId = "appId"; int32_t userId = 100; - auto res = appControlProxy.DeleteDisposedStatus(appId, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteDisposedStatus(appId, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -459,12 +474,13 @@ HWTEST_F(BmsAppControlProxyTest, DeleteDisposedStatus_0100, Function | MediumTes */ HWTEST_F(BmsAppControlProxyTest, GetDisposedStatus_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::string appId = "appId"; Want want; int32_t userId = 100; - auto res = appControlProxy.GetDisposedStatus(appId, want, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.GetDisposedStatus(appId, userId, want, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -475,12 +491,13 @@ HWTEST_F(BmsAppControlProxyTest, GetDisposedStatus_0100, Function | MediumTest | */ HWTEST_F(BmsAppControlProxyTest, SetDisposedRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::string appId = "appId"; DisposedRule disposedRule; int32_t userId = 100; - auto res = appControlProxy.SetDisposedRule(appId, disposedRule, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.SetDisposedRule(appId, userId, disposedRule, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -491,12 +508,13 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRule_0100, Function | MediumTest | L */ HWTEST_F(BmsAppControlProxyTest, GetDisposedRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::string appId = "appId"; DisposedRule disposedRule; int32_t userId = 100; - auto res = appControlProxy.GetDisposedRule(appId, disposedRule, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.GetDisposedRule(appId, userId, disposedRule, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -507,14 +525,16 @@ HWTEST_F(BmsAppControlProxyTest, GetDisposedRule_0100, Function | MediumTest | L */ HWTEST_F(BmsAppControlProxyTest, GetAbilityRunningControlRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); DisposedRule disposedRule; int32_t userId = 100; std::string bundleName = "bundleName"; std::vector rules; rules.emplace_back(disposedRule); - auto res = appControlProxy.GetAbilityRunningControlRule(bundleName, userId, rules); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); + int32_t appIndex = Constants::MAIN_APP_INDEX; + int32_t funcResult = 0; + auto res = appControlProxy.GetAbilityRunningControlRule(bundleName, userId, appIndex, rules, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -525,13 +545,14 @@ HWTEST_F(BmsAppControlProxyTest, GetAbilityRunningControlRule_0100, Function | M */ HWTEST_F(BmsAppControlProxyTest, SetDisposedRuleForCloneApp_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); DisposedRule disposedRule; std::string appId = "appId"; int32_t userId = 100; int32_t appIndex = 0; - auto res = appControlProxy.SetDisposedRuleForCloneApp(appId, disposedRule, appIndex, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.SetDisposedRuleForCloneApp(appId, appIndex, userId, disposedRule, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -542,13 +563,14 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRuleForCloneApp_0100, Function | Med */ HWTEST_F(BmsAppControlProxyTest, GetDisposedRuleForCloneApp_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); DisposedRule disposedRule; std::string appId = "appId"; int32_t userId = 100; int32_t appIndex = 0; - auto res = appControlProxy.GetDisposedRuleForCloneApp(appId, disposedRule, appIndex, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.GetDisposedRuleForCloneApp(appId, appIndex, userId, disposedRule, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -559,59 +581,13 @@ HWTEST_F(BmsAppControlProxyTest, GetDisposedRuleForCloneApp_0100, Function | Med */ HWTEST_F(BmsAppControlProxyTest, DeleteDisposedRuleForCloneApp_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::string appId = "appId"; int32_t userId = 100; int32_t appIndex = 0; - auto res = appControlProxy.DeleteDisposedRuleForCloneApp(appId, appIndex, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); -} - -/** - * @tc.number: WriteStringVector_0100 - * @tc.name: test the WriteStringVector - * @tc.desc: 1. stringVector is empty - * 2. test WriteStringVector - */ -HWTEST_F(BmsAppControlProxyTest, WriteStringVector_0100, Function | MediumTest | Level1) -{ - AppControlProxy appControlProxy(nullptr); - std::vector stringVector; - MessageParcel data; - auto res = appControlProxy.WriteStringVector(stringVector, data); - EXPECT_TRUE(res); -} - -/** - * @tc.number: GetParcelableInfos_0100 - * @tc.name: test the GetParcelableInfos - * @tc.desc: 1. system running normally - * 2. test GetParcelableInfos - */ -HWTEST_F(BmsAppControlProxyTest, GetParcelableInfos_0100, Function | MediumTest | Level1) -{ - AppControlProxy appControlProxy(nullptr); - AppControlManagerInterfaceCode code = AppControlManagerInterfaceCode::DELETE_APP_INSTALL_CONTROL_RULE; - MessageParcel data; - std::vector stringVector; - auto res = appControlProxy.GetParcelableInfos(code, data, stringVector); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); -} - -/** - * @tc.number: SendRequest_0100 - * @tc.name: test the SendRequest - * @tc.desc: 1. system running normally - * 2. test SendRequest - */ -HWTEST_F(BmsAppControlProxyTest, SendRequest_0100, Function | MediumTest | Level1) -{ - AppControlProxy appControlProxy(nullptr); - AppControlManagerInterfaceCode code = AppControlManagerInterfaceCode::DELETE_APP_INSTALL_CONTROL_RULE; - MessageParcel data; - MessageParcel reply; - auto res = appControlProxy.SendRequest(code, data, reply); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteDisposedRuleForCloneApp(appId, appIndex, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -622,12 +598,13 @@ HWTEST_F(BmsAppControlProxyTest, SendRequest_0100, Function | MediumTest | Level */ HWTEST_F(BmsAppControlProxyTest, DeleteUninstallDisposedRule_0100, Function | MediumTest | Level1) { - AppControlProxy appControlProxy(nullptr); + AppControlMgrProxy appControlProxy(nullptr); std::string appId = "DeleteUninstallDisposedRule"; int32_t appIndex = 1234; int32_t userId = 1234; - auto res = appControlProxy.DeleteUninstallDisposedRule(appId, appIndex, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteUninstallDisposedRule(appId, appIndex, userId, funcResult); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -639,12 +616,14 @@ HWTEST_F(BmsAppControlProxyTest, DeleteUninstallDisposedRule_0100, Function | Me HWTEST_F(BmsAppControlProxyTest, SetDisposedStatus_0200, Function | MediumTest | Level1) { sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); + AppControlMgrProxy appControlProxy(mockRemoteObject); std::string appId = "appId"; Want want; int32_t userId = 100; - auto res = appControlProxy.SetDisposedStatus(appId, want, userId); + int32_t funcResult = 0; + auto res = appControlProxy.SetDisposedStatus(appId, want, userId, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -656,13 +635,16 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedStatus_0200, Function | MediumTest | HWTEST_F(BmsAppControlProxyTest, DeleteDisposedStatus_0200, Function | MediumTest | Level1) { sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); + AppControlMgrProxy appControlProxy(mockRemoteObject); std::string appId = "appId"; Want want; int32_t userId = 100; - auto res = appControlProxy.DeleteDisposedStatus(appId, userId); + int32_t funcResult = 0; + auto res = appControlProxy.DeleteDisposedStatus(appId, userId, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } + /** * @tc.number: SetDisposedRule_0200 * @tc.name: test the SetDisposedRule @@ -672,12 +654,14 @@ HWTEST_F(BmsAppControlProxyTest, DeleteDisposedStatus_0200, Function | MediumTes HWTEST_F(BmsAppControlProxyTest, SetDisposedRule_0200, Function | MediumTest | Level1) { sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); + AppControlMgrProxy appControlProxy(mockRemoteObject); std::string appId = "appId"; DisposedRule disposedRule; int32_t userId = 100; - auto res = appControlProxy.SetDisposedRule(appId, disposedRule, userId); + int32_t funcResult = 0; + auto res = appControlProxy.SetDisposedRule(appId, userId, disposedRule, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -689,13 +673,15 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRule_0200, Function | MediumTest | L HWTEST_F(BmsAppControlProxyTest, SetDisposedRuleForCloneApp_0200, Function | MediumTest | Level1) { sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); + AppControlMgrProxy appControlProxy(mockRemoteObject); std::string appId = "appId"; DisposedRule disposedRule; int32_t appIndex = 0; int32_t userId = 100; - auto result = appControlProxy.SetDisposedRuleForCloneApp(appId, disposedRule, appIndex, userId); + int32_t funcResult = 0; + auto result = appControlProxy.SetDisposedRuleForCloneApp(appId, appIndex, userId, disposedRule, funcResult); EXPECT_EQ(result, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -707,12 +693,14 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRuleForCloneApp_0200, Function | Med HWTEST_F(BmsAppControlProxyTest, DeleteDisposedRuleForCloneApp_0200, Function | MediumTest | Level1) { sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); + AppControlMgrProxy appControlProxy(mockRemoteObject); std::string appId = "appId"; int32_t appIndex = 0; int32_t userId = 100; - auto result = appControlProxy.DeleteDisposedRuleForCloneApp(appId, appIndex, userId); + int32_t funcResult = 0; + auto result = appControlProxy.DeleteDisposedRuleForCloneApp(appId, appIndex, userId, funcResult); EXPECT_EQ(result, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -724,13 +712,15 @@ HWTEST_F(BmsAppControlProxyTest, DeleteDisposedRuleForCloneApp_0200, Function | HWTEST_F(BmsAppControlProxyTest, SetUninstallDisposedRule_0200, Function | MediumTest | Level1) { sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); + AppControlMgrProxy appControlProxy(mockRemoteObject); std::string appId = "appId"; UninstallDisposedRule rule; int32_t appIndex = 0; int32_t userId = 100; - auto result = appControlProxy.SetUninstallDisposedRule(appId, rule, appIndex, userId); + int32_t funcResult = 0; + auto result = appControlProxy.SetUninstallDisposedRule(appId, rule, appIndex, userId, funcResult); EXPECT_EQ(result, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -742,30 +732,14 @@ HWTEST_F(BmsAppControlProxyTest, SetUninstallDisposedRule_0200, Function | Mediu HWTEST_F(BmsAppControlProxyTest, DeleteUninstallDisposedRule_0200, Function | MediumTest | Level1) { sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); + AppControlMgrProxy appControlProxy(mockRemoteObject); std::string appId = "appId"; int32_t appIndex = 0; int32_t userId = 100; - auto result = appControlProxy.DeleteUninstallDisposedRule(appId, appIndex, userId); + int32_t funcResult = 0; + auto result = appControlProxy.DeleteUninstallDisposedRule(appId, appIndex, userId, funcResult); EXPECT_EQ(result, ERR_OK); -} - -/** - * @tc.number: SetDisposedRules_0100 - * @tc.name: test the SetDisposedRules - * @tc.desc: 1. system running normally - * 2. test SetDisposedRules - */ -HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0100, Function | MediumTest | Level1) -{ - AppControlProxy appControlProxy(nullptr); - DisposedRuleConfiguration disposedRuleConfiguration; - disposedRuleConfiguration.appId = APPID; - disposedRuleConfiguration.appIndex = APP_INDEX; - std::vector disposedRuleConfigurations; - disposedRuleConfigurations.push_back(disposedRuleConfiguration); - auto res = appControlProxy.SetDisposedRules(disposedRuleConfigurations, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -776,14 +750,12 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0100, Function | MediumTest | */ HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0200, Function | MediumTest | Level1) { - sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); DisposedRuleConfiguration disposedRuleConfiguration; disposedRuleConfiguration.appId = APPID; disposedRuleConfiguration.appIndex = APP_INDEX; std::vector disposedRuleConfigurations; disposedRuleConfigurations.push_back(disposedRuleConfiguration); - auto res = appControlProxy.SetDisposedRules(disposedRuleConfigurations, USERID); + auto res = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, USERID); EXPECT_EQ(res, ERR_OK); } @@ -795,12 +767,11 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0200, Function | MediumTest | */ HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0300, Function | MediumTest | Level1) { - sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); std::vector disposedRuleConfigurations; disposedRuleConfigurations.clear(); - auto res = appControlProxy.SetDisposedRules(disposedRuleConfigurations, USERID); + auto res = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PARAM_ERROR); + EXPECT_EQ(disposedRuleConfigurations.size(), 0); } /** @@ -811,8 +782,6 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0300, Function | MediumTest | */ HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0400, Function | MediumTest | Level1) { - sptr mockRemoteObject = new MockRemoteObject(); - AppControlProxy appControlProxy(mockRemoteObject); DisposedRuleConfiguration disposedRuleConfiguration; disposedRuleConfiguration.appId = APPID; disposedRuleConfiguration.appIndex = APP_INDEX; @@ -822,7 +791,7 @@ HWTEST_F(BmsAppControlProxyTest, SetDisposedRules_0400, Function | MediumTest | for (int i = 0; i < MAX_VECTOR_NUM; ++i) { disposedRuleConfigurations.push_back(disposedRuleConfiguration); } - auto res = appControlProxy.SetDisposedRules(disposedRuleConfigurations, USERID); + auto res = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PARAM_ERROR); } } // AppExecFwk diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn index d3606bfcf358fe4552fb2da213be87e717bd6933..8bde75867b431de23c76a3a7443f9c41c16c2fa0 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn @@ -66,6 +66,8 @@ ohos_unittest("BmsBundleAppControlTest") { "${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/bmsThirdBundle1:bmsThirdBundle1", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", + "${core_path}:app_control_mgr_stub", ] deps += bundle_install_deps diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_app_control_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_app_control_test.cpp index 81e3200924923779780546ba2f0ec9269748a022..91268cce809868acc915149c8a4ad3239c459633 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_app_control_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_app_control_test.cpp @@ -20,11 +20,13 @@ #include #include "ability_info.h" +#include "app_control_client.h" #include "app_control_constants.h" #include "app_control_manager_rdb.h" #include "app_control_manager_host_impl.h" #include "app_jump_interceptor_manager_rdb.h" #include "bundle_info.h" +#include "bundle_constants.h" #include "bundle_installer_host.h" #include "bundle_mgr_service.h" #include "bundle_permission_mgr.h" @@ -241,38 +243,39 @@ const std::shared_ptr BmsBundleAppControlTest::GetBundleDataMgr() */ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0100, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); std::vector appIds; - auto res = appControlProxy-> + auto res = AppControlClient::GetInstance(). AddAppInstallControlRule(appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); appIds.emplace_back(APPID); - res = appControlProxy-> + res = AppControlClient::GetInstance(). AddAppInstallControlRule(appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_OK); - res = appControlProxy-> + res = AppControlClient::GetInstance(). AddAppInstallControlRule(appIds, AppInstallControlRuleType::UNSPECIFIED, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); - res = appControlProxy-> + res = AppControlClient::GetInstance(). AddAppInstallControlRule(appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_OK); std::vector resultAppIds; - res = appControlProxy-> + res = AppControlClient::GetInstance(). GetAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID, resultAppIds); EXPECT_EQ(res, ERR_OK); EXPECT_EQ(appIds.size(), resultAppIds.size()); for (size_t i = 0; i < AppControlConstants::LIST_MAX_SIZE; i++) { appIds.emplace_back(APPID); } - res = appControlProxy-> + std::cout << appIds.size() << endl; + res = AppControlClient::GetInstance(). AddAppInstallControlRule(appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_OK); } @@ -285,26 +288,26 @@ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0100, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0200, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); std::vector appIds; - auto res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, - appIds, USERID); + auto res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, appIds, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); appIds.emplace_back(APPID); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, - appIds, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, appIds, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::UNSPECIFIED, appIds, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::UNSPECIFIED, appIds, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, appIds, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, appIds, USERID); EXPECT_EQ(res, ERR_OK); for (size_t i = 0; i < AppControlConstants::LIST_MAX_SIZE; i++) { appIds.emplace_back(APPID); } - res = appControlProxy-> + res = AppControlClient::GetInstance(). DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, appIds, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -318,15 +321,16 @@ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0200, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0300, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); - auto res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); + auto res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::UNSPECIFIED, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::UNSPECIFIED, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_OK); } @@ -339,22 +343,21 @@ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0300, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0400, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); std::vector appIds; - auto res = appControlProxy-> + auto res = AppControlClient::GetInstance(). GetAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID, appIds); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); appIds.emplace_back(APPID); - res = appControlProxy-> + res = AppControlClient::GetInstance(). AddAppInstallControlRule(appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_OK); - res = appControlProxy-> + res = AppControlClient::GetInstance(). GetAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID, appIds); EXPECT_EQ(res, ERR_OK); - res = appControlProxy->DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); + res = AppControlClient::GetInstance(). + DeleteAppInstallControlRule(AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_OK); } @@ -393,27 +396,25 @@ HWTEST_F(BmsBundleAppControlTest, AppInstallControlRule_0500, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0100, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); std::vector controlRules; - auto res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + auto res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); AppRunningControlRule controlRule; controlRule.appId = APPID; controlRule.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(controlRule); - res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); - res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_OK); for (size_t i = 0; i < AppControlConstants::LIST_MAX_SIZE; i++) { controlRules.emplace_back(controlRule); } - res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); - res = appControlProxy->DeleteAppRunningControlRule(USERID); + res = AppControlClient::GetInstance().DeleteAppRunningControlRule(USERID); EXPECT_EQ(res, ERR_OK); } @@ -425,27 +426,25 @@ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0100, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0200, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); std::vector controlRules; - auto res = appControlProxy->DeleteAppRunningControlRule(controlRules, USERID); + auto res = AppControlClient::GetInstance().DeleteAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); AppRunningControlRule controlRule; controlRule.appId = APPID; controlRule.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(controlRule); - auto res1 = appControlProxy->DeleteAppRunningControlRule(controlRules, USERID); + auto res1 = AppControlClient::GetInstance().DeleteAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res1, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); - auto res2 = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + auto res2 = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res2, ERR_OK); - auto res3 = appControlProxy->DeleteAppRunningControlRule(controlRules, USERID); + auto res3 = AppControlClient::GetInstance().DeleteAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res3, ERR_OK); for (size_t i = 0; i < AppControlConstants::LIST_MAX_SIZE; i++) { controlRules.emplace_back(controlRule); } - res = appControlProxy->DeleteAppRunningControlRule(controlRules, USERID); + res = AppControlClient::GetInstance().DeleteAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -457,10 +456,8 @@ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0200, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0300, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); - auto res = appControlProxy->DeleteAppRunningControlRule(USERID); + auto res = AppControlClient::GetInstance().DeleteAppRunningControlRule(USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); std::vector controlRules; @@ -468,9 +465,9 @@ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0300, Function | SmallTe ruleParam.appId = APPID; ruleParam.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(ruleParam); - res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_OK); - res = appControlProxy->DeleteAppRunningControlRule(USERID); + res = AppControlClient::GetInstance().DeleteAppRunningControlRule(USERID); EXPECT_EQ(res, ERR_OK); } @@ -482,11 +479,9 @@ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0300, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0400, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(1000); std::vector appIds; - auto res = appControlProxy->GetAppRunningControlRule(USERID, appIds); + auto res = AppControlClient::GetInstance().GetAppRunningControlRule(USERID, appIds); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(3057); std::vector controlRules; @@ -494,11 +489,11 @@ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0400, Function | SmallTe controlRule.appId = APPID; controlRule.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(controlRule); - res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_OK); - res = appControlProxy->GetAppRunningControlRule(USERID, appIds); + res = AppControlClient::GetInstance().GetAppRunningControlRule(USERID, appIds); EXPECT_EQ(res, ERR_OK); - res = appControlProxy->DeleteAppRunningControlRule(USERID); + res = AppControlClient::GetInstance().DeleteAppRunningControlRule(USERID); EXPECT_EQ(res, ERR_OK); } @@ -510,25 +505,23 @@ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0400, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0500, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(3057); std::vector controlRules; AppRunningControlRule controlRule; controlRule.appId = APPID; controlRule.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(controlRule); - auto res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + auto res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_OK); AppRunningControlRuleResult controlRuleResult; - res = appControlProxy->GetAppRunningControlRule(BUNDLE_NAME, USERID, controlRuleResult); + res = AppControlClient::GetInstance().GetAppRunningControlRule(BUNDLE_NAME, USERID, controlRuleResult); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); seteuid(5523); - res = appControlProxy->GetAppRunningControlRule(BUNDLE_NAME, USERID, controlRuleResult); + res = AppControlClient::GetInstance().GetAppRunningControlRule(BUNDLE_NAME, USERID, controlRuleResult); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST); seteuid(3057); - res = appControlProxy->DeleteAppRunningControlRule(USERID); + res = AppControlClient::GetInstance().DeleteAppRunningControlRule(USERID); EXPECT_EQ(res, ERR_OK); } @@ -571,10 +564,8 @@ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0600, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, AppRunningControlRule_0700, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); seteuid(3057); - auto ret = appControlProxy->DeleteAppRunningControlRule(100); + auto ret = AppControlClient::GetInstance().DeleteAppRunningControlRule(100); EXPECT_EQ(ret, ERR_OK); std::vector controlRules; AppRunningControlRule controlRule; @@ -677,12 +668,10 @@ HWTEST_F(BmsBundleAppControlTest, DisposedStatus_0300, Function | SmallTest | Le */ HWTEST_F(BmsBundleAppControlTest, DisposedStatus_0400, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); Want want; want.SetAction("action.system.home"); APP_LOGE("disposedstatus 4"); - auto res = appControlProxy->SetDisposedStatus(APPID, want); + auto res = AppControlClient::GetInstance().SetDisposedStatus(APPID, want); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -694,9 +683,7 @@ HWTEST_F(BmsBundleAppControlTest, DisposedStatus_0400, Function | SmallTest | Le */ HWTEST_F(BmsBundleAppControlTest, DisposedStatus_0500, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - auto res = appControlProxy->DeleteDisposedStatus(APPID); + auto res = AppControlClient::GetInstance().DeleteDisposedStatus(APPID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -708,13 +695,11 @@ HWTEST_F(BmsBundleAppControlTest, DisposedStatus_0500, Function | SmallTest | Le */ HWTEST_F(BmsBundleAppControlTest, DisposedStatus_0600, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); Want want; want.SetAction("action.system.home"); - auto res = appControlProxy->SetDisposedStatus(APPID, want); + auto res = AppControlClient::GetInstance().SetDisposedStatus(APPID, want); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); - res = appControlProxy->GetDisposedStatus(APPID, want); + res = AppControlClient::GetInstance().GetDisposedStatus(APPID, want); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -730,9 +715,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0100, Function | Sma std::vector appIds; appIds.emplace_back(APPID); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->AddAppInstallControlRule( - appIds, AppInstallControlRuleType::ALLOWED_INSTALL, USERID); + appIds, AppInstallControlRuleType::ALLOWED_INSTALL, USERID, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -746,9 +733,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0200, Function | Sma auto impl = std::make_shared(); std::vector appIds; appIds.emplace_back(APPID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->AddAppInstallControlRule( - appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -763,9 +752,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0300, Function | Sma std::vector appIds; appIds.emplace_back(APPID); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->AddAppInstallControlRule( - appIds, AppInstallControlRuleType::UNSPECIFIED, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); + appIds, AppInstallControlRuleType::UNSPECIFIED, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); } /** @@ -780,9 +771,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0400, Function | Sma std::vector appIds; appIds.emplace_back(APPID); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->DeleteAppInstallControlRule( - AppInstallControlRuleType::ALLOWED_INSTALL, appIds, USERID); + AppInstallControlRuleType::ALLOWED_INSTALL, appIds, USERID, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -796,9 +789,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0500, Function | Sma auto impl = std::make_shared(); std::vector appIds; appIds.emplace_back(APPID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->DeleteAppInstallControlRule( - AppInstallControlRuleType::ALLOWED_INSTALL, appIds, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + AppInstallControlRuleType::ALLOWED_INSTALL, appIds, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -812,9 +807,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0600, Function | Sma auto impl = std::make_shared(); std::vector appIds; appIds.emplace_back(APPID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->DeleteAppInstallControlRule( - AppInstallControlRuleType::UNSPECIFIED, appIds, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); + AppInstallControlRuleType::UNSPECIFIED, appIds, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); } /** @@ -827,9 +824,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0700, Function | Sma { auto impl = std::make_shared(); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->DeleteAppInstallControlRule( - AppInstallControlRuleType::ALLOWED_INSTALL, USERID); + AppInstallControlRuleType::ALLOWED_INSTALL, USERID, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -841,9 +840,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0700, Function | Sma HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0800, Function | SmallTest | Level1) { auto impl = std::make_shared(); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->DeleteAppInstallControlRule( - AppInstallControlRuleType::ALLOWED_INSTALL, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + AppInstallControlRuleType::ALLOWED_INSTALL, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -856,9 +857,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_0900, Function | Sma { auto impl = std::make_shared(); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->DeleteAppInstallControlRule( - AppInstallControlRuleType::UNSPECIFIED, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); + AppInstallControlRuleType::UNSPECIFIED, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); } /** @@ -873,9 +876,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1000, Function | Sma std::vector appIds; appIds.emplace_back(APPID); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->GetAppInstallControlRule( - AppInstallControlRuleType::ALLOWED_INSTALL, USERID, appIds); + AppInstallControlRuleType::ALLOWED_INSTALL, USERID, appIds, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -889,9 +894,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1100, Function | Sma auto impl = std::make_shared(); std::vector appIds; appIds.emplace_back(APPID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->GetAppInstallControlRule( - AppInstallControlRuleType::ALLOWED_INSTALL, USERID, appIds); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + AppInstallControlRuleType::ALLOWED_INSTALL, USERID, appIds, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -906,9 +913,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1200, Function | Sma std::vector appIds; appIds.emplace_back(APPID); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; ErrCode res = impl->GetAppInstallControlRule( - AppInstallControlRuleType::UNSPECIFIED, USERID, appIds); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); + AppInstallControlRuleType::UNSPECIFIED, USERID, appIds, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_APP_CONTROL_RULE_TYPE_INVALID); } /** @@ -922,8 +931,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1300, Function | Sma auto impl = std::make_shared(); std::vector controlRules; impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); - ErrCode res = impl->AddAppRunningControlRule(controlRules, USERID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->AddAppRunningControlRule(controlRules, USERID, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -936,8 +947,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1400, Function | Sma { auto impl = std::make_shared(); std::vector controlRules; - ErrCode res = impl->AddAppRunningControlRule(controlRules, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->AddAppRunningControlRule(controlRules, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -950,9 +963,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1500, Function | Sma { auto impl = std::make_shared(); std::vector controlRules; + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); - ErrCode res = impl->DeleteAppRunningControlRule(controlRules, USERID); + ErrCode res = impl->DeleteAppRunningControlRule(controlRules, USERID, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -965,8 +980,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1600, Function | Sma { auto impl = std::make_shared(); std::vector controlRules; - ErrCode res = impl->DeleteAppRunningControlRule(controlRules, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->DeleteAppRunningControlRule(controlRules, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -979,8 +996,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1700, Function | Sma { auto impl = std::make_shared(); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); - ErrCode res = impl->DeleteAppRunningControlRule(USERID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->DeleteAppRunningControlRule(USERID, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -992,8 +1011,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1700, Function | Sma HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1800, Function | SmallTest | Level1) { auto impl = std::make_shared(); - ErrCode res = impl->DeleteAppRunningControlRule(USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->DeleteAppRunningControlRule(USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1008,8 +1029,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_1900, Function | Sma std::vector appIds; appIds.emplace_back(APPID); impl->callingNameMap_.insert(pair(0, AppControlConstants::EDM_CALLING)); - ErrCode res = impl->GetAppRunningControlRule(USERID, appIds); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->GetAppRunningControlRule(USERID, appIds, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -1023,8 +1046,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2000, Function | Sma auto impl = std::make_shared(); std::vector appIds; appIds.emplace_back(APPID); - ErrCode res = impl->GetAppRunningControlRule(USERID, appIds); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->GetAppRunningControlRule(USERID, appIds, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1037,8 +1062,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2100, Function | Sma { auto impl = std::make_shared(); AppRunningControlRuleResult controlRuleResult; - ErrCode res = impl->GetAppRunningControlRule(BUNDLE_NAME, USERID, controlRuleResult); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->GetAppRunningControlRule(BUNDLE_NAME, USERID, controlRuleResult, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1054,14 +1081,18 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2200, Function | Sma auto impl = std::make_shared(); Want want; int32_t userId = Constants::UNSPECIFIED_USERID; - ErrCode res = impl->SetDisposedStatus(APPID, want, userId); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->SetDisposedStatus(APPID, want, userId, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); - res = impl->GetDisposedStatus(APPID, want, userId); + res = impl->GetDisposedStatus(APPID, userId, want, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); - res = impl->DeleteDisposedStatus(APPID, userId); + res = impl->DeleteDisposedStatus(APPID, userId, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -1083,6 +1114,7 @@ HWTEST_F(BmsBundleAppControlTest, GetBundleNameByAppId_0100, Function | SmallTes EXPECT_EQ(bundleName, ""); UnInstallBundle(BUNDLE_NAME); } + /** * @tc.number: AppControlManagerHostImpl_2300 * @tc.name: test ConfirmAppJumpControlRule by AppControlManagerHostImpl @@ -1091,8 +1123,10 @@ HWTEST_F(BmsBundleAppControlTest, GetBundleNameByAppId_0100, Function | SmallTes HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2300, Function | SmallTest | Level1) { auto impl = std::make_shared(); - ErrCode res = impl->ConfirmAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->ConfirmAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1104,8 +1138,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2400, Function | Sma { auto impl = std::make_shared(); std::vector controlRules; - ErrCode res = impl->AddAppJumpControlRule(controlRules, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->AddAppJumpControlRule(controlRules, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1117,8 +1153,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2500, Function | Sma { auto impl = std::make_shared(); std::vector controlRules; - ErrCode res = impl->DeleteAppJumpControlRule(controlRules, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->DeleteAppJumpControlRule(controlRules, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1129,8 +1167,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2500, Function | Sma HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2600, Function | SmallTest | Level1) { auto impl = std::make_shared(); - ErrCode res = impl->DeleteRuleByCallerBundleName(CALLER_BUNDLE_NAME, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->DeleteRuleByCallerBundleName(CALLER_BUNDLE_NAME, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1142,8 +1182,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_2700, Function | Sma { auto impl = std::make_shared(); AppJumpControlRule controlRule; - ErrCode res = impl->GetAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID, controlRule); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->GetAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID, controlRule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1296,10 +1338,9 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_3600, Function | Sma HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_3700, Function | SmallTest | Level1) { auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - auto res = appControlProxy->ConfirmAppJumpControlRule("", TARGET_BUNDLE_NAME, USERID); + auto res = AppControlClient::GetInstance().ConfirmAppJumpControlRule("", TARGET_BUNDLE_NAME, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); - res = appControlProxy->ConfirmAppJumpControlRule(CALLER_BUNDLE_NAME, "", USERID); + res = AppControlClient::GetInstance().ConfirmAppJumpControlRule(CALLER_BUNDLE_NAME, "", USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -1310,11 +1351,8 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_3700, Function | Sma */ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_3800, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - std::vector controlRules; - auto res = appControlProxy->AddAppJumpControlRule(controlRules, USERID); + auto res = AppControlClient::GetInstance().AddAppJumpControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -1331,10 +1369,7 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_3900, Function | Sma controlRule.targetPkg = TARGET_BUNDLE_NAME; controlRule.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(controlRule); - - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - auto res = appControlProxy->AddAppJumpControlRule(controlRules, USERID); + auto res = AppControlClient::GetInstance().AddAppJumpControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1351,10 +1386,7 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4000, Function | Sma controlRule.targetPkg = TARGET_BUNDLE_NAME; controlRule.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(controlRule); - - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - auto res = appControlProxy->DeleteAppJumpControlRule(controlRules, USERID); + auto res = AppControlClient::GetInstance().DeleteAppJumpControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1365,9 +1397,7 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4000, Function | Sma */ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4100, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - auto res = appControlProxy->DeleteRuleByCallerBundleName(CALLER_BUNDLE_NAME, USERID); + auto res = AppControlClient::GetInstance().DeleteRuleByCallerBundleName(CALLER_BUNDLE_NAME, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1378,9 +1408,7 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4100, Function | Sma */ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4200, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - auto res = appControlProxy->DeleteRuleByTargetBundleName(CALLER_BUNDLE_NAME, USERID); + auto res = AppControlClient::GetInstance().DeleteRuleByTargetBundleName(CALLER_BUNDLE_NAME, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1392,9 +1420,8 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4200, Function | Sma HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4300, Function | SmallTest | Level1) { AppJumpControlRule controlRule; - auto bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - auto res = appControlProxy->GetAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID, controlRule); + auto res = AppControlClient::GetInstance().GetAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID, + controlRule); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1408,8 +1435,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4400, Function | Sma auto impl = std::make_shared(); std::vector disposedRules; int32_t userId = Constants::UNSPECIFIED_USERID; - ErrCode res = impl->GetAbilityRunningControlRule(CALLER_BUNDLE_NAME, userId, disposedRules); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->GetAbilityRunningControlRule(CALLER_BUNDLE_NAME, userId, Constants::MAIN_APP_INDEX, + disposedRules, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); EXPECT_EQ(disposedRules.empty(), true); } @@ -1531,7 +1561,9 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5100, Function | Sma auto impl = std::make_shared(); ASSERT_NE(impl, nullptr); DisposedRule rule; - auto ret = impl->GetDisposedRule(APPID, rule, USERID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + auto ret = impl->GetDisposedRule(APPID, USERID, rule, funcResult); + EXPECT_EQ(funcResult, ERR_OK); EXPECT_EQ(ret, ERR_OK); } @@ -1545,12 +1577,17 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5200, Function | Sma auto impl = std::make_shared(); ASSERT_NE(impl, nullptr); DisposedRule rule; - auto ret = impl->GetDisposedRuleForCloneApp(APPID, rule, MAIN_APP_INDEX, USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); - ret = impl->GetDisposedRuleForCloneApp(APPID, rule, CLONE_APP_INDEX_MAX, USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); - ret = impl->GetDisposedRuleForCloneApp(APPID, rule, APP_INDEX, USERID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + auto ret = impl->GetDisposedRuleForCloneApp(APPID, MAIN_APP_INDEX, USERID, rule, funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ret = impl->GetDisposedRuleForCloneApp(APPID, CLONE_APP_INDEX_MAX, USERID, rule, funcResult); EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + ret = impl->GetDisposedRuleForCloneApp(APPID, APP_INDEX, USERID, rule, funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -1563,10 +1600,14 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5300, Function | Sma auto impl = std::make_shared(); ASSERT_NE(impl, nullptr); DisposedRule rule; - auto ret = impl->SetDisposedRuleForCloneApp(APPID, rule, MAIN_APP_INDEX, USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); - ret = impl->SetDisposedRuleForCloneApp(APPID, rule, CLONE_APP_INDEX_MAX, USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + auto ret = impl->SetDisposedRuleForCloneApp(APPID, MAIN_APP_INDEX, USERID, rule, funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ret = impl->SetDisposedRuleForCloneApp(APPID, CLONE_APP_INDEX_MAX, USERID, rule, funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); } /** @@ -1579,12 +1620,18 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5400, Function | Sma auto impl = std::make_shared(); ASSERT_NE(impl, nullptr); DisposedRule rule; - auto ret = impl->DeleteDisposedRuleForCloneApp(APPID, MAIN_APP_INDEX, USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); - ret = impl->DeleteDisposedRuleForCloneApp(APPID, CLONE_APP_INDEX_MAX, USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); - ret = impl->DeleteDisposedRuleForCloneApp(APPID, APP_INDEX, USERID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + auto ret = impl->DeleteDisposedRuleForCloneApp(APPID, MAIN_APP_INDEX, USERID, funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ret = impl->DeleteDisposedRuleForCloneApp(APPID, CLONE_APP_INDEX_MAX, USERID, funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ret = impl->DeleteDisposedRuleForCloneApp(APPID, APP_INDEX, USERID, funcResult); EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -1670,14 +1717,10 @@ HWTEST_F(BmsBundleAppControlTest, GetAbilityRunningControlRule_0200, Function | */ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5700, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); std::string appId; DisposedRule disposedRule; int32_t userId = 0; - ErrCode res = appControlProxy->SetDisposedRule(appId, disposedRule, userId); + ErrCode res = AppControlClient::GetInstance().SetDisposedRule(appId, disposedRule, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1688,15 +1731,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5700, Function | Sma */ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5800, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); std::string appId; DisposedRule disposedRule; int32_t appIndex = 0; int32_t userId = 0; - ErrCode res = appControlProxy->SetDisposedRuleForCloneApp(appId, disposedRule, appIndex, userId); + ErrCode res = AppControlClient::GetInstance().SetDisposedRuleForCloneApp(appId, disposedRule, appIndex, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1707,15 +1746,11 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5800, Function | Sma */ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5900, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); std::string appId; DisposedRule rule; int32_t appIndex = 0; int32_t userId = 0; - ErrCode res = appControlProxy->GetDisposedRuleForCloneApp(appId, rule, appIndex, userId); + ErrCode res = AppControlClient::GetInstance().GetDisposedRuleForCloneApp(appId, rule, appIndex, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1726,14 +1761,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_5900, Function | Sma */ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_6000, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); std::string appId; int32_t appIndex = 0; int32_t userId = 0; - ErrCode res = appControlProxy->DeleteDisposedRuleForCloneApp(appId, appIndex, userId); + ErrCode res = AppControlClient::GetInstance().DeleteDisposedRuleForCloneApp(appId, appIndex, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1750,10 +1781,12 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_6100, Function | Sma disposedRuleConfiguration.appIndex = APP_INDEX; std::vector disposedRuleConfigurations; disposedRuleConfigurations.push_back(disposedRuleConfiguration); - impl->appControlManager_ = nullptr; - ErrCode res = impl->SetDisposedRules(disposedRuleConfigurations, USERID); - EXPECT_EQ(res, ERR_APPEXECFWK_NULL_PTR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + BundleMgrRawData disposedRuleConfigurationsRawData; + ErrCode res = impl->SetDisposedRules(USERID, disposedRuleConfigurationsRawData, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_NULL_PTR); } /** @@ -1771,7 +1804,7 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_6200, Function | Sma disposedRuleConfigurations.push_back(disposedRuleConfiguration); impl->appControlManager_ = DelayedSingleton::GetInstance(); - ErrCode res = impl->SetDisposedRules(disposedRuleConfigurations, USERID); + ErrCode res = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, USERID); EXPECT_EQ(res, ERR_OK); } @@ -1790,7 +1823,7 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_8000, Function | Sma disposedRuleConfigurations.push_back(disposedRuleConfiguration); impl->appControlManager_ = DelayedSingleton::GetInstance(); - ErrCode res = impl->SetDisposedRules(disposedRuleConfigurations, UNSPECIFIED_USERID); + ErrCode res = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, UNSPECIFIED_USERID); EXPECT_EQ(res, ERR_OK); } @@ -1833,14 +1866,10 @@ HWTEST_F(BmsBundleAppControlTest, AppJumpInterceptorManagerRdb_6200, Function | */ HWTEST_F(BmsBundleAppControlTest, AppControlProxyGetDisposedRule_0100, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); std::string appId = "0"; DisposedRule disposedRule; int32_t userId = 0; - ErrCode res = appControlProxy->GetDisposedRule(appId, disposedRule, userId); + ErrCode res = AppControlClient::GetInstance().GetDisposedRule(appId, disposedRule, userId); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1851,15 +1880,12 @@ HWTEST_F(BmsBundleAppControlTest, AppControlProxyGetDisposedRule_0100, Function */ HWTEST_F(BmsBundleAppControlTest, AppControlProxyGetAbilityRunningControlRule_0100, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); std::string bundleName = "bundleName"; int32_t userId = 100; std::vector disposedRules; int32_t appIndex = 0; - ErrCode result = appControlProxy->GetAbilityRunningControlRule(bundleName, userId, disposedRules, appIndex); + ErrCode result = AppControlClient::GetInstance().GetAbilityRunningControlRule(bundleName, userId, disposedRules, + appIndex); EXPECT_EQ(result, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } @@ -1870,13 +1896,9 @@ HWTEST_F(BmsBundleAppControlTest, AppControlProxyGetAbilityRunningControlRule_01 */ HWTEST_F(BmsBundleAppControlTest, AppControlProxyAppInstallControlRule_0100, Function | SmallTest | Level1) { - sptr bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); const int32_t size = AppControlConstants::LIST_MAX_SIZE + 1; std::vector appIds(size); - auto res = appControlProxy->AddAppInstallControlRule( + auto res = AppControlClient::GetInstance().AddAppInstallControlRule( appIds, AppInstallControlRuleType::DISALLOWED_UNINSTALL, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); } @@ -1888,61 +1910,12 @@ HWTEST_F(BmsBundleAppControlTest, AppControlProxyAppInstallControlRule_0100, Fun */ HWTEST_F(BmsBundleAppControlTest, AppControlProxyConfirmAppJumpControlRule_0100, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); - auto res = appControlProxy->ConfirmAppJumpControlRule("", "", USERID); + auto res = AppControlClient::GetInstance().ConfirmAppJumpControlRule("", "", USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_PARAMETER); - res = appControlProxy->ConfirmAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID); + res = AppControlClient::GetInstance().ConfirmAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } -/** - * @tc.number: AppControlHostHandleSetDisposedRuleForCloneApp_0100 - * @tc.name: test HandleSetDisposedRuleForCloneApp by AppControlHost - * @tc.desc: 1.HandleSetDisposedRuleForCloneApp test - */ -HWTEST_F(BmsBundleAppControlTest, AppControlHostHandleSetDisposedRuleForCloneApp_0100, Function | SmallTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleSetDisposedRuleForCloneApp(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); -} - -/** - * @tc.number: AppControlHostHandleSetDisposedRule_0100 - * @tc.name: test HandleSetDisposedRule by AppControlHost - * @tc.desc: 1.HandleSetDisposedRule test - */ -HWTEST_F(BmsBundleAppControlTest, AppControlHostHandleSetDisposedRule_0100, Function | SmallTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleSetDisposedRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); -} - -/** - * @tc.number: AppControlHostHandleSetDisposedStatus_0100 - * @tc.name: test HandleSetDisposedStatus by AppControlHost - * @tc.desc: 1.HandleSetDisposedStatus test - */ -HWTEST_F(BmsBundleAppControlTest, AppControlHostHandleSetDisposedStatus_0100, Function | SmallTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleSetDisposedStatus(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); -} - /** * @tc.number: AppControlManagerHostImpl_6300 * @tc.name: Test DeleteRuleByTargetBundleName by AppControlManagerHostImpl @@ -1952,8 +1925,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_6300, Function | Sma { auto impl = std::make_shared(); ASSERT_NE(impl, nullptr); - ErrCode res = impl->DeleteRuleByTargetBundleName(CALLER_BUNDLE_NAME, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->DeleteRuleByTargetBundleName(CALLER_BUNDLE_NAME, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** @@ -1967,8 +1942,10 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_6400, Function | Sma ASSERT_NE(impl, nullptr); DisposedRule rule; int32_t userId = Constants::UNSPECIFIED_USERID; - auto ret = impl->GetDisposedRuleForCloneApp(APPID, rule, APP_INDEX, USERID); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + auto ret = impl->GetDisposedRuleForCloneApp(APPID, APP_INDEX, USERID, rule, funcResult); EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -2273,30 +2250,12 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_7900, Function | Sma */ HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_0100, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); UninstallDisposedRule uninstallDisposedRule; - ErrCode res = appControlProxy->SetUninstallDisposedRule(APPID, uninstallDisposedRule, APP_INDEX, USERID); + ErrCode res = AppControlClient::GetInstance().SetUninstallDisposedRule(APPID, uninstallDisposedRule, APP_INDEX, + USERID); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } -/** - * @tc.number: UninstallDisposedRule_0200 - * @tc.name: Test HandleSetUninstallDisposedRule by AppControlHost - * @tc.desc: 1.HandleSetUninstallDisposedRule test - */ -HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_0200, Function | SmallTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleSetUninstallDisposedRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); -} - /** * @tc.number: UninstallDisposedRule_0300 * @tc.name: Test SetUninstallDisposedRule by AppControlManager @@ -2337,30 +2296,12 @@ HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_0400, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_0500, Function | SmallTest | Level1) { - auto bundleMgrProxy = GetBundleMgrProxy(); - ASSERT_NE(bundleMgrProxy, nullptr); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); - ASSERT_NE(appControlProxy, nullptr); UninstallDisposedRule uninstallDisposedRule; - ErrCode res = appControlProxy->GetUninstallDisposedRule(APPID, APP_INDEX, USERID, uninstallDisposedRule); + ErrCode res = AppControlClient::GetInstance().GetUninstallDisposedRule(APPID, APP_INDEX, USERID, + uninstallDisposedRule); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } -/** - * @tc.number: UninstallDisposedRule_0600 - * @tc.name: Test HandleGetUninstallDisposedRule by AppControlHost - * @tc.desc: 1.HandleGetUninstallDisposedRule test - */ -HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_0600, Function | SmallTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleGetUninstallDisposedRule(data, reply); - EXPECT_EQ(res, ERR_OK); -} - /** * @tc.number: UninstallDisposedRule_0700 * @tc.name: Test GetUninstallDisposedRule by AppControlManager @@ -2430,21 +2371,6 @@ HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_1000, Function | SmallTe EXPECT_EQ(res, ERR_OK); } -/** - * @tc.number: UninstallDisposedRule_1100 - * @tc.name: Test HandleDeleteUninstallDisposedRule by AppControlHost - * @tc.desc: 1.HandleDeleteUninstallDisposedRule test - */ -HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_1100, Function | SmallTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleDeleteUninstallDisposedRule(data, reply); - EXPECT_EQ(res, ERR_OK); -} - /** * @tc.number: UninstallDisposedRule_1200 * @tc.name: Test DeleteUninstallDisposedRule by AppControlManager @@ -2486,31 +2412,13 @@ HWTEST_F(BmsBundleAppControlTest, UninstallDisposedRule_1300, Function | SmallTe */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0100, Function | MediumTest | Level0) { - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::ADD_APP_INSTALL_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, OBJECT_NULL); -} - -/** - * @tc.number: OnRemoteRequest_0200 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0200, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::ADD_APP_INSTALL_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_ADD_APP_INSTALL_CONTROL_RULE), data, reply, option); + EXPECT_EQ(res, ERR_TRANSACTION_FAILED); } /** @@ -2521,142 +2429,16 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0200, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0300, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_APP_JUMP_CONTROL_RULE), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_GET_APP_JUMP_CONTROL_RULE), data, reply, option); EXPECT_EQ(res, ERR_OK); } -/** - * @tc.number: OnRemoteRequest_0400 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0400, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_APP_INSTALL_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_0500 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0500, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::CLEAN_APP_INSTALL_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_0600 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0600, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_APP_INSTALL_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_0700 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0700, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::ADD_APP_RUNNING_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_0800 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0800, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_APP_RUNNING_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_0900 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_0900, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::CLEAN_APP_RUNNING_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_1000 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1000, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_APP_RUNNING_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - /** * @tc.number: OnRemoteRequest_1100 * @tc.name: test the OnRemoteRequest @@ -2665,109 +2447,17 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1000, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1100, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_APP_RUNNING_CONTROL_RULE_RESULT), + ErrCode res = impl->OnRemoteRequest(static_cast(IAppControlMgrIpcCode:: + COMMAND_GET_APP_RUNNING_CONTROL_RULE_IN_STRING_IN_INT_OUT_APPRUNNINGCONTROLRULERESULT_OUT_INT), data, reply, option); EXPECT_EQ(res, ERR_OK); } -/** - * @tc.number: OnRemoteRequest_1200 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1200, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::CONFIRM_APP_JUMP_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_1300 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1300, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::ADD_APP_JUMP_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_1400 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1400, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_1500 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1500, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE_BY_CALLER), - data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: OnRemoteRequest_1600 - * @tc.name: test the OnRemoteRequest - * @tc.desc: 1. system running normally - * 2. test OnRemoteRequest - */ -HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1600, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_APP_JUMP_CONTROL_RULE_BY_TARGET), - data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - /** * @tc.number: OnRemoteRequest_1700 * @tc.name: test the OnRemoteRequest @@ -2776,14 +2466,14 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1600, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1700, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_STATUS), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_SET_DISPOSED_STATUS), data, reply, option); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -2794,13 +2484,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1700, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1800, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_DISPOSED_STATUS), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_GET_DISPOSED_STATUS), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -2812,13 +2502,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1800, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2800, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_DISPOSED_STATUS), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_DELETE_DISPOSED_STATUS), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -2830,14 +2520,14 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2800, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1900, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_SET_DISPOSED_RULE), data, reply, option); + EXPECT_EQ(res, ERR_OK); } /** @@ -2848,13 +2538,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_1900, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2000, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_DISPOSED_RULE), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_GET_DISPOSED_RULE), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -2866,13 +2556,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2000, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2100, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_ABILITY_RUNNING_CONTROL_RULE), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_GET_ABILITY_RUNNING_CONTROL_RULE), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -2884,13 +2574,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2100, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2200, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_GET_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -2902,14 +2592,14 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2200, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2300, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_SET_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); + EXPECT_EQ(res, ERR_OK); } /** @@ -2920,13 +2610,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2300, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2400, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_DELETE_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -2938,14 +2628,14 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2400, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2500, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::SET_UNINSTALL_DISPOSED_RULE), data, reply, option); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_SET_UNINSTALL_DISPOSED_RULE), data, reply, option); + EXPECT_EQ(res, ERR_INVALID_DATA); } /** @@ -2956,13 +2646,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2500, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2600, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_UNINSTALL_DISPOSED_RULE), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_GET_UNINSTALL_DISPOSED_RULE), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -2974,13 +2664,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2600, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2700, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::DELETE_UNINSTALL_DISPOSED_RULE), data, reply, option); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_DELETE_UNINSTALL_DISPOSED_RULE), data, reply, option); EXPECT_EQ(res, ERR_OK); } @@ -3086,14 +2776,20 @@ HWTEST_F(BmsBundleAppControlTest, GetUninstallDisposedRuleImpl_0100, Function | int32_t userId = 100; UninstallDisposedRule uninstallDisposedRule; - ErrCode res = impl->GetUninstallDisposedRule(appIdentifier, appIndex, userId, uninstallDisposedRule); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->GetUninstallDisposedRule(appIdentifier, appIndex, userId, uninstallDisposedRule, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); - res = impl->GetUninstallDisposedRule(appIdentifier, -1, userId, uninstallDisposedRule); - EXPECT_EQ(res, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + res = impl->GetUninstallDisposedRule(appIdentifier, -1, userId, uninstallDisposedRule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); - res = impl->GetUninstallDisposedRule(appIdentifier, appIndex, -2, uninstallDisposedRule); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + res = impl->GetUninstallDisposedRule(appIdentifier, appIndex, -2, uninstallDisposedRule, funcResult); EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_OK); } /** @@ -3109,14 +2805,20 @@ HWTEST_F(BmsBundleAppControlTest, SetUninstallDisposedRuleImpl_0100, Function | int32_t userId = 100; UninstallDisposedRule uninstallDisposedRule; - ErrCode res = impl->SetUninstallDisposedRule(appIdentifier, uninstallDisposedRule, appIndex, userId); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->SetUninstallDisposedRule(appIdentifier, uninstallDisposedRule, appIndex, userId, funcResult); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE); + EXPECT_EQ(res, ERR_OK); - res = impl->SetUninstallDisposedRule(appIdentifier, uninstallDisposedRule, -1, userId); - EXPECT_EQ(res, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + res = impl->SetUninstallDisposedRule(appIdentifier, uninstallDisposedRule, -1, userId, funcResult); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + EXPECT_EQ(res, ERR_OK); - res = impl->SetUninstallDisposedRule(appIdentifier, uninstallDisposedRule, appIndex, -2); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + res = impl->SetUninstallDisposedRule(appIdentifier, uninstallDisposedRule, appIndex, -2, funcResult); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INVALID_UNINSTALL_RULE); + EXPECT_EQ(res, ERR_OK); } /** @@ -3131,13 +2833,19 @@ HWTEST_F(BmsBundleAppControlTest, DeleteUninstallDisposedRuleImpl_0100, Function int32_t appIndex = 0; int32_t userId = 100; - ErrCode res = impl->DeleteUninstallDisposedRule(appIdentifier, appIndex, userId); + int32_t funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + ErrCode res = impl->DeleteUninstallDisposedRule(appIdentifier, appIndex, userId, funcResult); + EXPECT_EQ(funcResult, ERR_OK); EXPECT_EQ(res, ERR_OK); - res = impl->DeleteUninstallDisposedRule(appIdentifier, -1, userId); - EXPECT_EQ(res, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + res = impl->DeleteUninstallDisposedRule(appIdentifier, -1, userId, funcResult); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE); + EXPECT_EQ(res, ERR_OK); - res = impl->DeleteUninstallDisposedRule(appIdentifier, appIndex, -2); + funcResult = ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR; + res = impl->DeleteUninstallDisposedRule(appIdentifier, appIndex, -2, funcResult); + EXPECT_EQ(funcResult, ERR_OK); EXPECT_EQ(res, ERR_OK); } @@ -3237,21 +2945,6 @@ HWTEST_F(BmsBundleAppControlTest, SendAppControlEvent_0100, Function | SmallTest "test", 100, 0, { "test_appId "}, "rule")); } -/** - * @tc.number: AppControlHostHandleSetDisposedRules_0100 - * @tc.name: test HandleSetDisposedRules by AppControlHost - * @tc.desc: 1.HandleSetDisposedRules test - */ -HWTEST_F(BmsBundleAppControlTest, AppControlHostHandleSetDisposedRules_0100, Function | SmallTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleSetDisposedRules(data, reply); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PARAM_ERROR); -} - /** * @tc.number: OnRemoteRequest_2900 * @tc.name: test the OnRemoteRequest @@ -3260,14 +2953,14 @@ HWTEST_F(BmsBundleAppControlTest, AppControlHostHandleSetDisposedRules_0100, Fun */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2900, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; - data.WriteInterfaceToken(AppControlHost::GetDescriptor()); + data.WriteInterfaceToken(AppControlMgrStub::GetDescriptor()); MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_RULES), data, reply, option); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PARAM_ERROR); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_SET_DISPOSED_RULES), data, reply, option); + EXPECT_EQ(res, ERR_OK); } /** @@ -3278,13 +2971,13 @@ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_2900, Function | MediumTest | */ HWTEST_F(BmsBundleAppControlTest, OnRemoteRequest_3000, Function | MediumTest | Level0) { - AppControlHost appControlHost; + auto impl = std::make_shared(); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::SET_DISPOSED_RULES), data, reply, option); - EXPECT_EQ(res, OBJECT_NULL); + ErrCode res = impl->OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_SET_DISPOSED_RULES), data, reply, option); + EXPECT_EQ(res, ERR_TRANSACTION_FAILED); } /** diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_mock_app_control.cpp b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_mock_app_control.cpp index 1d003957083675b85b86f9b1d85859a01284f014..1a1846db927c1f2621539f6fd65ad9992919c037 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_mock_app_control.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/bms_bundle_mock_app_control.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -540,8 +540,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0010, Function | AppRunningControlRuleResult controlRuleResult; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.GetAppRunningControlRule("", USERID, controlRuleResult); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.GetAppRunningControlRule("", USERID, controlRuleResult, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST); } /** @@ -554,8 +556,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0020, Function | AppControlManagerHostImpl impl; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.ConfirmAppJumpControlRule("", "", USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.ConfirmAppJumpControlRule("", "", USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); } /** @@ -569,8 +573,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0030, Function | std::vector controlRules; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.AddAppJumpControlRule(controlRules, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.AddAppJumpControlRule(controlRules, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); } /** @@ -584,8 +590,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0040, Function | std::vector controlRules; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.DeleteAppJumpControlRule(controlRules, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.DeleteAppJumpControlRule(controlRules, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); } /** @@ -598,8 +606,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0050, Function | AppControlManagerHostImpl impl; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.DeleteRuleByCallerBundleName("", USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.DeleteRuleByCallerBundleName("", USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); } /** @@ -612,8 +622,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0060, Function | AppControlManagerHostImpl impl; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.DeleteRuleByTargetBundleName("", USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.DeleteRuleByTargetBundleName("", USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); } /** @@ -625,8 +637,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0070, Function | { AppControlManagerHostImpl impl; Want want; - auto res = impl.SetDisposedStatus("", want, USERID); - EXPECT_EQ(res, ERR_APPEXECFWK_DB_DELETE_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.SetDisposedStatus("", want, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_DB_DELETE_ERROR); } /** @@ -638,8 +652,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0080, Function | { AppControlManagerHostImpl impl; Want want; - auto res = impl.DeleteDisposedStatus("", USERID); - EXPECT_EQ(res, ERR_APPEXECFWK_DB_DELETE_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.DeleteDisposedStatus("", USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_DB_DELETE_ERROR); } /** @@ -651,8 +667,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0090, Function | { AppControlManagerHostImpl impl; Want want; - auto res = impl.GetDisposedStatus("", want, USERID); - EXPECT_EQ(res, ERR_APPEXECFWK_DB_RESULT_SET_EMPTY); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.GetDisposedStatus("", USERID, want, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_DB_RESULT_SET_EMPTY); } /** @@ -665,8 +683,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0100, Function | AppControlManagerHostImpl impl; AppJumpControlRule controlRule; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.GetAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID, controlRule); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.GetAppJumpControlRule(CALLER_BUNDLE_NAME, TARGET_BUNDLE_NAME, USERID, controlRule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_INTERNAL_ERROR); } /** @@ -679,8 +699,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0110, Function | AppControlManagerHostImpl impl; DisposedRule rule; setuid(AppControlConstants::EDM_UID); - auto res = impl.SetDisposedRule(APPID, rule, Constants::UNSPECIFIED_USERID); - EXPECT_EQ(res, ERR_APPEXECFWK_DB_DELETE_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.SetDisposedRule(APPID, Constants::UNSPECIFIED_USERID, rule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_DB_DELETE_ERROR); } /** @@ -694,8 +716,11 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0120, Function | DisposedRule rule; std::vector disposedRules; setuid(AppControlConstants::FOUNDATION_UID); - auto res = impl.GetAbilityRunningControlRule(CALLER_BUNDLE_NAME, Constants::UNSPECIFIED_USERID, disposedRules); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto res = impl.GetAbilityRunningControlRule(CALLER_BUNDLE_NAME, Constants::UNSPECIFIED_USERID, + Constants::MAIN_APP_INDEX, disposedRules, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST); } /** @@ -708,8 +733,11 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0130, Function | AppControlManagerHostImpl impl; DisposedRule rule; setuid(AppControlConstants::EDM_UID); - auto ret = impl.SetDisposedRuleForCloneApp(APPID, rule, Constants::MAIN_APP_INDEX, Constants::UNSPECIFIED_USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_DB_DELETE_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto ret = impl.SetDisposedRuleForCloneApp(APPID, Constants::MAIN_APP_INDEX, Constants::UNSPECIFIED_USERID, + rule, funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_DB_DELETE_ERROR); } /** @@ -721,7 +749,10 @@ HWTEST_F(BmsBundleMockAppControlTest, AppControlManagerHostImpl_0140, Function | { AppControlManagerHostImpl impl; setuid(AppControlConstants::EDM_UID); - auto ret = impl.DeleteDisposedRuleForCloneApp(APPID, Constants::MAIN_APP_INDEX, Constants::UNSPECIFIED_USERID); - EXPECT_EQ(ret, ERR_APPEXECFWK_DB_DELETE_ERROR); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + auto ret = impl.DeleteDisposedRuleForCloneApp(APPID, Constants::MAIN_APP_INDEX, Constants::UNSPECIFIED_USERID, + funcResult); + EXPECT_EQ(ret, ERR_OK); + EXPECT_EQ(funcResult, ERR_APPEXECFWK_DB_DELETE_ERROR); } } // OHOS \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_def_list_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_def_list_test.cpp index c185f8686c095921ed15a4a87c9c4ce9eee7eeab..1147c2303ff40759257985f828ae8d17bfb884f1 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_def_list_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_def_list_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -229,10 +229,14 @@ HWTEST_F(BmsBundlePermissionDefListTest, BmsBundlePermissionDefListTest_0900, Fu { auto impl = std::make_shared(); DisposedRule rule; - ErrCode res = impl->SetDisposedRule(APPID, rule, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); - - res = impl->GetDisposedRule(APPID, rule, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + ErrCode res = impl->SetDisposedRule(APPID, USERID, rule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + + funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + res = impl->GetDisposedRule(APPID, USERID, rule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } } // OHOS \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp index c0ab4c0b449d3392067bb6742e62746bb72607b3..3a1a836126e86907fae4b0e507a0a769b806c9ad 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_false_test.cpp @@ -21,6 +21,7 @@ #include #include +#include "app_control_client.h" #include "bundle_info.h" #include "bundle_installer_host.h" #include "bundle_mgr_service.h" @@ -1327,14 +1328,20 @@ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_8900, Functi { auto impl = std::make_shared(); Want want; - ErrCode res = impl->SetDisposedStatus(APPID, want, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + ErrCode res = impl->SetDisposedStatus(APPID, want, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); - res = impl->GetDisposedStatus(APPID, want, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + res = impl->GetDisposedStatus(APPID, USERID, want, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); - res = impl->DeleteDisposedStatus(APPID, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + res = impl->DeleteDisposedStatus(APPID, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); DisposedRuleConfiguration disposedRuleConfiguration; disposedRuleConfiguration.appId = APPID; @@ -1342,8 +1349,9 @@ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_8900, Functi std::vector disposedRuleConfigurations; disposedRuleConfigurations.push_back(disposedRuleConfiguration); - res = impl->SetDisposedRules(disposedRuleConfigurations, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); + res = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, USERID); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_PERMISSION_DENIED); } /** diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp index 900d0c034dbbdceba9f9778ed466b7262af4ce7d..27e165ec9bd849bce350a76486094cb6f61445a2 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/bms_bundle_permission_system_app_test.cpp @@ -20,6 +20,7 @@ #include #include +#include "app_control_client.h" #include "app_control_manager_host_impl.h" #include "bundle_info.h" #include "bundle_installer_host.h" @@ -923,14 +924,20 @@ HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, BmsBundleSyetemAppFalseTest_5800 { auto impl = std::make_shared(); Want want; - ErrCode res = impl->SetDisposedStatus(APPID, want, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + ErrCode res = impl->SetDisposedStatus(APPID, want, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); - res = impl->GetDisposedStatus(APPID, want, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); + funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + res = impl->GetDisposedStatus(APPID, USERID, want, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); - res = impl->DeleteDisposedStatus(APPID, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); + funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + res = impl->DeleteDisposedStatus(APPID, USERID, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); DisposedRuleConfiguration disposedRuleConfiguration; disposedRuleConfiguration.appId = APPID; @@ -938,8 +945,9 @@ HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, BmsBundleSyetemAppFalseTest_5800 std::vector disposedRuleConfigurations; disposedRuleConfigurations.push_back(disposedRuleConfiguration); - res = impl->SetDisposedRules(disposedRuleConfigurations, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); + res = AppControlClient::GetInstance().SetDisposedRules(disposedRuleConfigurations, USERID); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); } /** @@ -1302,11 +1310,15 @@ HWTEST_F(BmsBundlePermissionSyetemAppFalseTest, BmsBundleSyetemAppFalseTest_8200 { auto impl = std::make_shared(); DisposedRule rule; - ErrCode res = impl->SetDisposedRule(APPID, rule, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); - - res = impl->GetDisposedRule(APPID, rule, USERID); - EXPECT_EQ(res, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + ErrCode res = impl->SetDisposedRule(APPID, USERID, rule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); + + funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + res = impl->GetDisposedRule(APPID, USERID, rule, funcResult); + EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(funcResult, ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED); } /** diff --git a/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/BUILD.gn index 1bc8d62845afd0fbc5d7120f0c2e90ab4f9f9fc6..4f4ea8c93a4aecc8d54c7cb51882ec979f9bc355 100755 --- a/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("AddAppInstallControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/addappInstallcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/addappInstallcontrolrule_fuzzer.cpp index c2ce383e01c250762d32f63cd145f80046bbd8cd..5e4aeb0d29b2b22c89f092aeb64c1b46a5459578 100755 --- a/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/addappInstallcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/addappInstallcontrolrule_fuzzer/addappInstallcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "addappInstallcontrolrule_fuzzer.h" @@ -25,12 +26,14 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; std::vector appIds; std::string appId (reinterpret_cast(data), size); appIds.push_back(appId); - appControl.AddAppInstallControlRule(appIds, controlRuleType, reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.AddAppInstallControlRule(appIds, controlRuleType, reinterpret_cast(data), + funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/BUILD.gn index 4edb4879f1210d7385ba40eb82f0f0d19b311e21..c21572995febe85aa4c39843184309134689ce7a 100644 --- a/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("AddAppJumpControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/addappjumpcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/addappjumpcontrolrule_fuzzer.cpp index 3379437e27edb71ad537325d9ba03ee2fe2aa3eb..f153421cfcfd80cfaca08558355efdafb3bf8eb9 100644 --- a/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/addappjumpcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer/addappjumpcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "addappjumpcontrolrule_fuzzer.h" #include "securec.h" @@ -28,9 +29,10 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::vector controlRule; - appControl.AddAppJumpControlRule(controlRule, reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.AddAppJumpControlRule(controlRule, reinterpret_cast(data), funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_application/addapprunningcontrolrule_fuzzer/addapprunningcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_application/addapprunningcontrolrule_fuzzer/addapprunningcontrolrule_fuzzer.cpp index a89417a0bfbeb6fd0777705cbb6073f2df9af1c7..1a4704b5e5e4ac8dcaea011b51b3499e3056b0e4 100755 --- a/test/fuzztest/fuzztest_application/addapprunningcontrolrule_fuzzer/addapprunningcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/addapprunningcontrolrule_fuzzer/addapprunningcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "addapprunningcontrolrule_fuzzer.h" @@ -25,9 +26,10 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::vector controlRule; - appControl.AddAppRunningControlRule(controlRule, reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.AddAppRunningControlRule(controlRule, reinterpret_cast(data), funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/BUILD.gn index dab459e37abbbcc47ee27dec3f9ee16525053a96..269e1e2d2a9fa5310f59c62a003530a6ab86c31f 100644 --- a/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -16,6 +16,7 @@ import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") import("../../../../appexecfwk.gni") +import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni") module_output_path = fuzz_test_path ##############################fuzztest########################################## @@ -30,17 +31,124 @@ ohos_fuzztest("AppControlHostFuzzTest") { "-Wno-unused-variable", "-fno-omit-frame-pointer", ] + + use_exceptions = true sources = [ "appcontrolhost_fuzzer.cpp" ] - deps = [ + sources += bundle_mgr_source + sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ] + sources += [ + "${services_path}/bundlemgr/src/aot/aot_executor.cpp", + "${services_path}/bundlemgr/src/installd/installd_host_impl.cpp", + "${services_path}/bundlemgr/src/installd/installd_operator.cpp", + "${services_path}/bundlemgr/test/mock/src/installd_service.cpp", + ] + + sources += [ + "${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp", + "${services_path}/bundlemgr/test/mock/src/mock_bundle_status.cpp", + "${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp", + ] + + sources += bundle_install_sources + + configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ] + + deps = bundle_install_deps + deps += [ "${base_path}:appexecfwk_base", - "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", ] + external_deps = [ - "ability_base:want", + "ability_runtime:ability_manager", + "access_token:el5_filekey_manager_sdk", + "access_token:libprivacy_sdk", + "access_token:libtokenid_sdk", + "appspawn:hnpapi", + "appverify:libhapverify", + "bounds_checking_function:libsec_shared", "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", "ipc:ipc_core", + "safwk:system_ability_fwk", "samgr:samgr_proxy", + "selinux_adapter:librestorecon", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + + external_deps += bundle_install_external_deps + + if (bundle_framework_power_mgr_enable) { + external_deps += aot_external_deps + } + + configs += [ "../../../../services/bundlemgr:rdb_config" ] + external_deps += [ "relational_store:native_rdb" ] + sources += [ + "${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp", + "${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp", + ] + + defines = [] + include_dirs = [] + if (device_usage_statistics_enabled) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLED" ] + } + if (code_signature_enable) { + sources += [ + "${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp", + "${services_path}/bundlemgr/src/code_sign_helper.cpp", + ] + include_dirs += [ "${services_path}/bundlemgr/include" ] + external_deps += [ + "bounds_checking_function:libsec_shared", + "code_signature:libcode_sign_utils", + "ets_runtime:libcompiler_service", + ] + defines += [ "CODE_SIGNATURE_ENABLE" ] + } + if (current_cpu == "arm64") { + defines += [ "ON_64BIT_SYSTEM" ] + } + if (bundle_framework_app_control) { + defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ] + sources += [ + "${services_path}/bundlemgr/src/app_control/app_control_manager.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp", + ] + include_dirs += [ "${services_path}/bundlemgr/include/app_control" ] + external_deps += [ "c_utils:utils" ] + } + if (udmf_enabled) { + defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] + external_deps += [ "udmf:utd_client" ] + } + + if (user_auth_framework_impl_enabled) { + external_deps += [ "user_auth_framework:userauth_client" ] + defines += [ "BMS_USER_AUTH_FRAMEWORK_ENABLED" ] + include_dirs += [ "${services_path}/bundlemgr/include/user_auth" ] + sources += user_auth + } } diff --git a/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/appcontrolhost_fuzzer.cpp b/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/appcontrolhost_fuzzer.cpp index d15924c827765b017c22baebb62894c017977698..f41ab25298edaebbde61c363ca3cbdbb203e0d3d 100644 --- a/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/appcontrolhost_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/appcontrolhost_fuzzer/appcontrolhost_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,7 +19,8 @@ #include #include -#include "app_control_host.h" +#include "app_control_mgr_stub.h" +#include "app_control_manager_host_impl.h" #include "securec.h" using namespace OHOS::AppExecFwk; @@ -29,18 +30,16 @@ constexpr uint32_t CODE_MAX = 23; bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { - AppControlHost appControlHost; + AppControlManagerHostImpl impl; MessageParcel datas; MessageParcel reply; - appControlHost.HandleAddAppInstallControlRule(datas, reply); - appControlHost.HandleDeleteAppInstallControlRule(datas, reply); for (uint32_t code = 2; code <= CODE_MAX; code++) { - std::u16string descriptor = AppControlHost::GetDescriptor(); + std::u16string descriptor = AppControlMgrStub::GetDescriptor(); datas.WriteInterfaceToken(descriptor); datas.WriteBuffer(data, size); datas.RewindRead(0); MessageOption option; - appControlHost.OnRemoteRequest(code, datas, reply, option); + impl.OnRemoteRequest(code, datas, reply, option); } return true; } diff --git a/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/BUILD.gn index adfd30b517a0b65071b82ee0890f4e3ad0216d06..36f836ae77ecd18dd0de274b81614b20ce73aadd 100755 --- a/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -35,6 +35,7 @@ ohos_fuzztest("DeleteAppInstallControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/deleteappinstallcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/deleteappinstallcontrolrule_fuzzer.cpp index 8b82f62ffe4e7465325d59c9a663c011eb6a696b..963b7f2f937205536a9f007cfdad8036123b4524 100755 --- a/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/deleteappinstallcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/deleteappinstallcontrolrule_fuzzer/deleteappinstallcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "deleteappinstallcontrolrule_fuzzer.h" @@ -25,13 +26,15 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; std::vector appIds; std::string appId (reinterpret_cast(data), size); appIds.push_back(appId); - appControl.DeleteAppInstallControlRule(controlRuleType, appIds, reinterpret_cast(data)); - appControl.DeleteAppInstallControlRule(controlRuleType, reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteAppInstallControlRule(controlRuleType, appIds, reinterpret_cast(data), + funcResult); + appControlMgrProxy.DeleteAppInstallControlRule(controlRuleType, reinterpret_cast(data), funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_application/deleteapprunningcontrolrule_fuzzer/deleteapprunningcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_application/deleteapprunningcontrolrule_fuzzer/deleteapprunningcontrolrule_fuzzer.cpp index 774400eaa05bf64f98429e1ba9cdf543873c3004..a025e5fff184f50162bf2ff18cbe33a468173a16 100755 --- a/test/fuzztest/fuzztest_application/deleteapprunningcontrolrule_fuzzer/deleteapprunningcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/deleteapprunningcontrolrule_fuzzer/deleteapprunningcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "deleteapprunningcontrolrule_fuzzer.h" @@ -25,10 +26,11 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::vector controlRule; - appControl.DeleteAppRunningControlRule(controlRule, reinterpret_cast(data)); - appControl.DeleteAppRunningControlRule(reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteAppRunningControlRule(controlRule, reinterpret_cast(data), funcResult); + appControlMgrProxy.DeleteAppRunningControlRule(reinterpret_cast(data), funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/BUILD.gn index 3854d5e99f2911feba4ea710f5c3b74ec4d4aa32..08e5746813dd5d35e75a58eac398651fc36ec0f9 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("BMSAddAppInstallControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/bmsaddappInstallcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/bmsaddappInstallcontrolrule_fuzzer.cpp index 184f6ceb0bde2ac8ef4c02e271102e2fb94ce507..a5947a85324874b795c5da96cdd51734a036919e 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/bmsaddappInstallcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsaddappInstallcontrolrule_fuzzer/bmsaddappInstallcontrolrule_fuzzer.cpp @@ -17,7 +17,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "bmsaddappInstallcontrolrule_fuzzer.h" #include "bms_fuzztest_util.h" @@ -28,14 +29,15 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); FuzzedDataProvider fdp(data, size); AppInstallControlRuleType controlRuleType = static_cast(fdp.ConsumeIntegralInRange(0, 3)); std::vector appIds = BMSFuzzTestUtil::GenerateStringArray(fdp); int32_t userId = BMSFuzzTestUtil::GenerateRandomUser(fdp); - appControl.AddAppInstallControlRule(appIds, controlRuleType, userId); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.AddAppInstallControlRule(appIds, controlRuleType, userId, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/BUILD.gn index eeba2ba75f7888664e483e86f67d7bcd81ef8b66..a93850a8076991ed7534225c7097ebfa898dc12f 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("BMSAddAppJumpControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/bmsaddappjumpcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/bmsaddappjumpcontrolrule_fuzzer.cpp index 8a83709a5582a2b1a87a57a7267193a13b313e40..79fde0dd37b90e9c625e2da09c80def56bbca999 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/bmsaddappjumpcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsaddappjumpcontrolrule_fuzzer/bmsaddappjumpcontrolrule_fuzzer.cpp @@ -17,7 +17,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "bmsaddappjumpcontrolrule_fuzzer.h" #include "securec.h" @@ -38,7 +39,7 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); FuzzedDataProvider fdp(data, size); size_t arraySize = fdp.ConsumeIntegralInRange(0, BMSFuzzTestUtil::ARRAY_MAX_LENGTH); @@ -51,7 +52,8 @@ namespace OHOS { } int32_t userId = BMSFuzzTestUtil::GenerateRandomUser(fdp); - appControl.AddAppJumpControlRule(controlRules, userId); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.AddAppJumpControlRule(controlRules, userId, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/BUILD.gn index 11317e0d6233d17b69ff53a00df70acbfc572b8c..96c36302b037121c9ec57f71620eab22bc9fcd31 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("BMSAddAppRunningControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/bmsaddapprunningcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/bmsaddapprunningcontrolrule_fuzzer.cpp index ab163a5900e16bb6fa3403ce71f2ae055dba7e58..d6f40256df01d7d4dafc21c55d72aaa7d9ac3fd7 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/bmsaddapprunningcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsaddapprunningcontrolrule_fuzzer/bmsaddapprunningcontrolrule_fuzzer.cpp @@ -17,7 +17,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "bmsaddapprunningcontrolrule_fuzzer.h" #include "bms_fuzztest_util.h" @@ -34,7 +35,7 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); FuzzedDataProvider fdp(data, size); size_t arraySize = fdp.ConsumeIntegralInRange(0, BMSFuzzTestUtil::ARRAY_MAX_LENGTH); @@ -47,7 +48,8 @@ namespace OHOS { } int32_t userId = BMSFuzzTestUtil::GenerateRandomUser(fdp); - appControl.AddAppRunningControlRule(controlRules, userId); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.AddAppRunningControlRule(controlRules, userId, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/BUILD.gn index 7554d3268b4ba63189c13ae3f922f2747c658aa1..0f1f6d5f5aaef3a174a73b4230e03c7a2390826f 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/BUILD.gn @@ -16,6 +16,7 @@ import("//build/config/features.gni") import("//build/ohos.gni") import("//build/test.gni") import("../../../../appexecfwk.gni") +import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni") module_output_path = fuzz_test_path ##############################fuzztest########################################## @@ -30,18 +31,125 @@ ohos_fuzztest("BMSAppControlHostFuzzTest") { "-Wno-unused-variable", "-fno-omit-frame-pointer", ] + use_exceptions = true include_dirs = [ "${test_path}/fuzztest" ] sources = [ "bmsappcontrolhost_fuzzer.cpp" ] - deps = [ + sources += bundle_mgr_source + sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ] + sources += [ + "${services_path}/bundlemgr/src/aot/aot_executor.cpp", + "${services_path}/bundlemgr/src/installd/installd_host_impl.cpp", + "${services_path}/bundlemgr/src/installd/installd_operator.cpp", + "${services_path}/bundlemgr/test/mock/src/installd_service.cpp", + ] + + sources += [ + "${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp", + "${services_path}/bundlemgr/test/mock/src/mock_bundle_status.cpp", + "${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp", + ] + + sources += bundle_install_sources + + configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ] + + deps = bundle_install_deps + deps += [ "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", ] + external_deps = [ "ability_base:want", + "ability_runtime:ability_manager", + "access_token:el5_filekey_manager_sdk", + "access_token:libprivacy_sdk", + "access_token:libtokenid_sdk", + "appspawn:hnpapi", + "appverify:libhapverify", + "bounds_checking_function:libsec_shared", "c_utils:utils", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", "ipc:ipc_core", + "safwk:system_ability_fwk", "samgr:samgr_proxy", + "selinux_adapter:librestorecon", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + + external_deps += bundle_install_external_deps + + if (bundle_framework_power_mgr_enable) { + external_deps += aot_external_deps + } + + configs += [ "../../../../services/bundlemgr:rdb_config" ] + external_deps += [ "relational_store:native_rdb" ] + sources += [ + "${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp", + "${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp", + ] + + defines = [] + if (device_usage_statistics_enabled) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLED" ] + } + if (code_signature_enable) { + sources += [ + "${services_path}/bundlemgr/src/aot/aot_sign_data_cache_mgr.cpp", + "${services_path}/bundlemgr/src/code_sign_helper.cpp", + ] + include_dirs += [ "${services_path}/bundlemgr/include" ] + external_deps += [ + "bounds_checking_function:libsec_shared", + "code_signature:libcode_sign_utils", + "ets_runtime:libcompiler_service", + ] + defines += [ "CODE_SIGNATURE_ENABLE" ] + } + if (current_cpu == "arm64") { + defines += [ "ON_64BIT_SYSTEM" ] + } + if (bundle_framework_app_control) { + defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ] + sources += [ + "${services_path}/bundlemgr/src/app_control/app_control_manager.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp", + ] + include_dirs += [ "${services_path}/bundlemgr/include/app_control" ] + external_deps += [ "c_utils:utils" ] + } + if (udmf_enabled) { + defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] + external_deps += [ "udmf:utd_client" ] + } + + if (user_auth_framework_impl_enabled) { + external_deps += [ "user_auth_framework:userauth_client" ] + defines += [ "BMS_USER_AUTH_FRAMEWORK_ENABLED" ] + include_dirs += [ "${services_path}/bundlemgr/include/user_auth" ] + sources += user_auth + } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/bmsappcontrolhost_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/bmsappcontrolhost_fuzzer.cpp index 976fa3f26998288079b8fecabfcf15f8d74ee42a..3a68890601244aaf6d58245dda233d0763ef79cf 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/bmsappcontrolhost_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsappcontrolhost_fuzzer/bmsappcontrolhost_fuzzer.cpp @@ -20,7 +20,8 @@ #include #include -#include "app_control_host.h" +#include "app_control_mgr_stub.h" +#include "app_control_manager_host_impl.h" #include "securec.h" #include "bms_fuzztest_util.h" @@ -30,20 +31,18 @@ constexpr uint32_t CODE_MAX = 26; bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { - AppControlHost appControlHost; + AppControlManagerHostImpl impl; MessageParcel datas; MessageParcel reply; - appControlHost.HandleAddAppInstallControlRule(datas, reply); - appControlHost.HandleDeleteAppInstallControlRule(datas, reply); FuzzedDataProvider fdp(data, size); uint8_t code = fdp.ConsumeIntegralInRange(0, CODE_MAX); - std::u16string descriptor = AppControlHost::GetDescriptor(); + std::u16string descriptor = AppControlMgrStub::GetDescriptor(); datas.WriteInterfaceToken(descriptor); datas.WriteBuffer(data, size); datas.RewindRead(0); MessageOption option; - appControlHost.OnRemoteRequest(code, datas, reply, option); + impl.OnRemoteRequest(code, datas, reply, option); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/BUILD.gn index 6304c732569909348aae3a2ac174637acfbbd9c5..fc238728e988f28543c462e1528ddb4b2b82dfd0 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("BMSDeleteAppInstallControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/bmsdeleteappinstallcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/bmsdeleteappinstallcontrolrule_fuzzer.cpp index 81c33260d83584596544503a898521df9c13f62c..d21634b65752150111aa07145417fb86bf660696 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/bmsdeleteappinstallcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsdeleteappinstallcontrolrule_fuzzer/bmsdeleteappinstallcontrolrule_fuzzer.cpp @@ -17,7 +17,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "bmsdeleteappinstallcontrolrule_fuzzer.h" #include "bms_fuzztest_util.h" @@ -28,15 +29,16 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); FuzzedDataProvider fdp(data, size); AppInstallControlRuleType controlRuleType = static_cast(fdp.ConsumeIntegralInRange(0, 3)); std::vector appIds = GenerateStringArray(fdp); int32_t userId = BMSFuzzTestUtil::GenerateRandomUser(fdp); - appControl.DeleteAppInstallControlRule(controlRuleType, appIds, userId); - appControl.DeleteAppInstallControlRule(controlRuleType, userId); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteAppInstallControlRule(controlRuleType, appIds, userId, funcResult); + appControlMgrProxy.DeleteAppInstallControlRule(controlRuleType, userId, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsdeleteapprunningcontrolrule_fuzzer/bmsdeleteapprunningcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsdeleteapprunningcontrolrule_fuzzer/bmsdeleteapprunningcontrolrule_fuzzer.cpp index bc0feded039917bc8b851f1e00ad72bb92cee870..54bc613d23295b3f67974d7cd8781931fe155c66 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsdeleteapprunningcontrolrule_fuzzer/bmsdeleteapprunningcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsdeleteapprunningcontrolrule_fuzzer/bmsdeleteapprunningcontrolrule_fuzzer.cpp @@ -17,7 +17,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "bmsdeleteapprunningcontrolrule_fuzzer.h" #include "bms_fuzztest_util.h" @@ -35,7 +36,7 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::vector controlRule; FuzzedDataProvider fdp(data, size); size_t arraySize = fdp.ConsumeIntegralInRange(0, ARRAY_MAX_LENGTH); @@ -48,8 +49,9 @@ namespace OHOS { } int32_t userId = BMSFuzzTestUtil::GenerateRandomUser(fdp); - appControl.DeleteAppRunningControlRule(controlRule, userId); - appControl.DeleteAppRunningControlRule(userId); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteAppRunningControlRule(controlRule, userId, funcResult); + appControlMgrProxy.DeleteAppRunningControlRule(userId, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/BUILD.gn index 974a67970cfdde8bcabcd9d7ff94d5e653d655f4..6d0fff6a7de60ef334ad5f504338c7a26d742ae3 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("BMSGetAppInstallControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/bmsgetappinstallcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/bmsgetappinstallcontrolrule_fuzzer.cpp index 5752006721121234385a229293097163c4c86580..d450d975aa14f78aeadba8abf41cda8144e4aedb 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/bmsgetappinstallcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsgetappinstallcontrolrule_fuzzer/bmsgetappinstallcontrolrule_fuzzer.cpp @@ -17,7 +17,7 @@ #include #include -#include "app_control_proxy.h" +#include "app_control_mgr_proxy.h" #include "bmsgetappinstallcontrolrule_fuzzer.h" #include "bms_fuzztest_util.h" @@ -28,15 +28,15 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControl(object); FuzzedDataProvider fdp(data, size); AppInstallControlRuleType controlRuleType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_MAX_THREE)); int32_t userId = BMSFuzzTestUtil::GenerateRandomUser(fdp); std::vector appIds = GenerateStringArray(fdp); - - appControl.GetAppInstallControlRule(controlRuleType, userId, appIds); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControl.GetAppInstallControlRule(controlRuleType, userId, appIds, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/BUILD.gn index aaaf673d8c26311b8d1a2ee66920f530c21f2d9e..39377d6900662b579f57477e02bda08460fc6004 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("BMSGetAppRunningControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/bmsgetapprunningcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/bmsgetapprunningcontrolrule_fuzzer.cpp index 3b0d40812053a6263157d097b38a054f16e399dd..7ddddf9aa638d9dcf2ba4f275038b5febc69218e 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/bmsgetapprunningcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsgetapprunningcontrolrule_fuzzer/bmsgetapprunningcontrolrule_fuzzer.cpp @@ -17,7 +17,7 @@ #include #include -#include "app_control_proxy.h" +#include "app_control_mgr_proxy.h" #include "bmsgetapprunningcontrolrule_fuzzer.h" #include "bms_fuzztest_util.h" @@ -28,14 +28,15 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControl(object); AppRunningControlRuleResult controlRuleResult; FuzzedDataProvider fdp(data, size); std::string bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); std::vector appIds; int32_t userId = BMSFuzzTestUtil::GenerateRandomUser(fdp); - appControl.GetAppRunningControlRule(userId, appIds); - appControl.GetAppRunningControlRule(bundleName, userId, controlRuleResult); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControl.GetAppRunningControlRule(userId, appIds, funcResult); + appControl.GetAppRunningControlRule(bundleName, userId, controlRuleResult, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/BUILD.gn index 73c363af4b82a49398f5b1610987fff9474d744c..65f5020a1fe697979b3306a8431d6b72fde23e6a 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("BMSGetDisposedStatusFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/bmsgetdisposedstatus_fuzzer.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/bmsgetdisposedstatus_fuzzer.cpp index e46f9042f9c09809aee4a36ded12dcc690797e3b..9f80950f751d241679017e555187d63d055fd178 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/bmsgetdisposedstatus_fuzzer.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsgetdisposedstatus_fuzzer/bmsgetdisposedstatus_fuzzer.cpp @@ -1,50 +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 -#include -#include - -#include "app_control_proxy.h" - -#include "bmsgetdisposedstatus_fuzzer.h" -#include "bms_fuzztest_util.h" - -using Want = OHOS::AAFwk::Want; - -using namespace OHOS::AppExecFwk; -using namespace OHOS::AppExecFwk::BMSFuzzTestUtil; -namespace OHOS { -bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) -{ - sptr object; - AppControlProxy appControl(object); - Want want; - FuzzedDataProvider fdp(data, size); - std::string appId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); - std::string bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); - want.SetAction(bundleName); - appControl.GetDisposedStatus(appId, want); - return true; -} -} - -// Fuzzer entry point. -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - // Run your code on data. - OHOS::DoSomethingInterestingWithMyAPI(data, size); - return 0; -} \ No newline at end of file +/* + * 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 +#include +#include + +#include "app_control_mgr_proxy.h" + +#include "bmsgetdisposedstatus_fuzzer.h" +#include "bms_fuzztest_util.h" + +using Want = OHOS::AAFwk::Want; + +using namespace OHOS::AppExecFwk; +using namespace OHOS::AppExecFwk::BMSFuzzTestUtil; +namespace OHOS { +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + sptr object; + AppControlMgrProxy appControl(object); + Want want; + FuzzedDataProvider fdp(data, size); + std::string appId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + std::string bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + want.SetAction(bundleName); + int32_t userId = Constants::UNSPECIFIED_USERID; + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControl.GetDisposedStatus(appId, userId, want, funcResult); + return true; +} +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} diff --git a/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/BUILD.gn index 8b8326a911eed0605b566e6fe986b6b2f8635073..9d9cdc30b1da746359b6672357cae67c38e6f6d2 100755 --- a/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("GetAppInstallControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/getappinstallcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/getappinstallcontrolrule_fuzzer.cpp index 63e5ca19cf11415d58d307cc673209c728425cce..c0901b41d049697dd87ac2ab5353e6563bbe2089 100755 --- a/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/getappinstallcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_information/getappinstallcontrolrule_fuzzer/getappinstallcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "getappinstallcontrolrule_fuzzer.h" @@ -25,12 +26,14 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); AppInstallControlRuleType controlRuleType = AppInstallControlRuleType::UNSPECIFIED; std::vector appIds; std::string appId (reinterpret_cast(data), size); appIds.push_back(appId); - appControl.GetAppInstallControlRule(controlRuleType, reinterpret_cast(data), appIds); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.GetAppInstallControlRule(controlRuleType, reinterpret_cast(data), appIds, + funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_information/getapprunningcontrolrule_fuzzer/getapprunningcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_information/getapprunningcontrolrule_fuzzer/getapprunningcontrolrule_fuzzer.cpp index 18f8458c4d88dd4b99176c5532e33f19814c79d7..f28366e334ff83ea07e46b85e1b63a6eb93fab38 100755 --- a/test/fuzztest/fuzztest_information/getapprunningcontrolrule_fuzzer/getapprunningcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_information/getapprunningcontrolrule_fuzzer/getapprunningcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "getapprunningcontrolrule_fuzzer.h" @@ -25,14 +26,16 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); AppRunningControlRuleResult controlRuleResult; std::string bundleName (reinterpret_cast(data), size); std::vector appIds; std::string appId (reinterpret_cast(data), size); appIds.push_back(appId); - appControl.GetAppRunningControlRule(reinterpret_cast(data), appIds); - appControl.GetAppRunningControlRule(bundleName, reinterpret_cast(data), controlRuleResult); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.GetAppRunningControlRule(reinterpret_cast(data), appIds, funcResult); + appControlMgrProxy.GetAppRunningControlRule(bundleName, reinterpret_cast(data), controlRuleResult, + funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/BUILD.gn index 14c8258c7b2b87a1fe1df7e97230fb1c336f535c..c1ce78254f435bc57b28f267041c73e390331601 100755 --- a/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("GetDisposedStatusFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/getdisposedstatus_fuzzer.cpp b/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/getdisposedstatus_fuzzer.cpp index 3f447eed7a7d6328ea1ee4346f38e6e6c5f6194d..5a9b9bd57fd7822ee4e30b6f2bd9e2a2580f633b 100755 --- a/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/getdisposedstatus_fuzzer.cpp +++ b/test/fuzztest/fuzztest_information/getdisposedstatus_fuzzer/getdisposedstatus_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,9 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" +#include "bundle_constants.h" #include "getdisposedstatus_fuzzer.h" @@ -27,12 +29,14 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); Want want; std::string appId (reinterpret_cast(data), size); std::string bundleName (reinterpret_cast(data), size); want.SetAction(bundleName); - appControl.GetDisposedStatus(appId, want); + int32_t userId = Constants::UNSPECIFIED_USERID; + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.GetDisposedStatus(appId, userId, want, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/BUILD.gn index e3a253bd2a1f3b41585243567a73658c4581b148..fb432a654d533bff1277c9805ea11f2c6294a19f 100644 --- a/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/BUILD.gn @@ -53,6 +53,7 @@ ohos_fuzztest("DefaultAppHostImplFuzzTest") { "${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/defaultAppTest:defaultAppTest", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] deps += bundle_install_deps diff --git a/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/defaultapphostimpl_fuzzer.cpp b/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/defaultapphostimpl_fuzzer.cpp index 8381fa2b7a066cdbd2f20bcd3ae51147dccb2e9d..77c2e38778b3a84dc5154cbf88268acb7250bbe2 100644 --- a/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/defaultapphostimpl_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/defaultapphostimpl_fuzzer/defaultapphostimpl_fuzzer.cpp @@ -18,7 +18,7 @@ #include #include -#include "app_control_proxy.h" +#include "app_control_mgr_proxy.h" #include "defaultapphostimpl_fuzzer.h" #include "default_app_host_impl.h" diff --git a/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/BUILD.gn index ad88f32e3e855c9b6222243eb2ae31123044e8dc..54875061eb6703cc3854149b5f1731878debd76f 100644 --- a/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("DefaultAppMgrFuzzTest") { "${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/defaultAppTest:defaultAppTest", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] deps += bundle_install_deps diff --git a/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/defaultappmgr_fuzzer.cpp b/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/defaultappmgr_fuzzer.cpp index 850e397ab3f618c45d697bf6fd4412b61a3ae908..d26ed7eb854ea559a8cbcd525453a87edf5a0584 100644 --- a/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/defaultappmgr_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/defaultappmgr_fuzzer/defaultappmgr_fuzzer.cpp @@ -18,7 +18,7 @@ #include #include -#include "app_control_proxy.h" +#include "app_control_mgr_proxy.h" #include "defaultappmgr_fuzzer.h" #include "default_app_mgr.h" diff --git a/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/BUILD.gn index 7172353da5533dc95953032c9d91709e78e6e74a..9780436fd9b43cc6cf2dd80e2bf58a6bb2bb95e3 100644 --- a/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("DefaultAppRdbFuzzTest") { "${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/defaultAppTest:defaultAppTest", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] deps += bundle_install_deps diff --git a/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/defaultapprdb_fuzzer.cpp b/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/defaultapprdb_fuzzer.cpp index ebcbbd54fbafda4ad147e61a990e759e902ba8a2..be13d0314d9fc59330143f0bd5f47c3829f1678e 100644 --- a/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/defaultapprdb_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/defaultapprdb_fuzzer/defaultapprdb_fuzzer.cpp @@ -18,7 +18,7 @@ #include #include -#include "app_control_proxy.h" +#include "app_control_mgr_proxy.h" #include "defaultapprdb_fuzzer.h" #include "default_app_rdb.h" diff --git a/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/BUILD.gn index c5fe9cd61bdd19f8354039fc04efe84300cca0ed..677cd12cc4d0863c8914068abc0c8713e9318832 100644 --- a/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("DeleteAppJumpControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/deleteappjumpcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/deleteappjumpcontrolrule_fuzzer.cpp index 06a5f5510c57768cd7b6b1236610ec01124d3941..829fc5bcd7955d9e0af0971f24ad90619de2d881 100644 --- a/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/deleteappjumpcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/deleteappjumpcontrolrule_fuzzer/deleteappjumpcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "deleteappjumpcontrolrule_fuzzer.h" @@ -25,9 +26,10 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::vector controlRules; - appControl.DeleteAppJumpControlRule(controlRules, reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteAppJumpControlRule(controlRules, reinterpret_cast(data), funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/BUILD.gn index 8b5f85a88272141870bb0acc790bf49eece2f6e9..b40d4d2dacaf61acfdf42a5b16a10f5c0bb378ca 100755 --- a/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("DeleteDisposedStatusFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/deletedisposedstatus_fuzzer.cpp b/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/deletedisposedstatus_fuzzer.cpp index 703acebc761005a0735c19039b57c0fad225918a..77f1a3a44745d54765ebd4ded90f51420526d0b6 100755 --- a/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/deletedisposedstatus_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/deletedisposedstatus_fuzzer/deletedisposedstatus_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,9 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" +#include "bundle_constants.h" #include "deletedisposedstatus_fuzzer.h" @@ -25,9 +27,11 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::string appId (reinterpret_cast(data), size); - appControl.DeleteDisposedStatus(appId); + int32_t userId = Constants::UNSPECIFIED_USERID; + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteDisposedStatus(appId, userId, funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_others/deleterulebycallerbundlename_fuzzer/deleterulebycallerbundlename_fuzzer.cpp b/test/fuzztest/fuzztest_others/deleterulebycallerbundlename_fuzzer/deleterulebycallerbundlename_fuzzer.cpp index a23cd672bad55ade51f885989cd3f02a55bd2d80..1da4600ab6b1c01de4567b290b84bcc39dc8050c 100644 --- a/test/fuzztest/fuzztest_others/deleterulebycallerbundlename_fuzzer/deleterulebycallerbundlename_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/deleterulebycallerbundlename_fuzzer/deleterulebycallerbundlename_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "deleterulebycallerbundlename_fuzzer.h" @@ -25,9 +26,11 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::string callerBundleName; - appControl.DeleteRuleByCallerBundleName(callerBundleName, reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteRuleByCallerBundleName(callerBundleName, reinterpret_cast(data), + funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/BUILD.gn index a41d91fa338f174dc14efc44f086ae649f3f44d7..36e7a22a7b14ab0e3a030a2ffaa870cc13a2affd 100644 --- a/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("DeleteRuleByTargetBundleNameFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/deleterulebytargetbundlename_fuzzer.cpp b/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/deleterulebytargetbundlename_fuzzer.cpp index 003123e961ccd5d66d82a440bc407b55747b1f01..261c5cabfbf3eae2f0286751a863a4246006faff 100644 --- a/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/deleterulebytargetbundlename_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/deleterulebytargetbundlename_fuzzer/deleterulebytargetbundlename_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,8 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" #include "deleterulebytargetbundlename_fuzzer.h" @@ -25,9 +26,11 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::string targetBundleName; - appControl.DeleteRuleByTargetBundleName(targetBundleName, reinterpret_cast(data)); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.DeleteRuleByTargetBundleName(targetBundleName, reinterpret_cast(data), + funcResult); return true; } } diff --git a/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/BUILD.gn index a262aa51a7f9ed490f3ee128f3726ea99c012e6c..19eefed2e001ba13ce7cc171d15394cb083291bd 100644 --- a/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("GetAppJumpControlRuleFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "c_utils:utils", diff --git a/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/getappjumpcontrolrule_fuzzer.cpp b/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/getappjumpcontrolrule_fuzzer.cpp index c48d756680c7a0167be2863619271d6ad4ffda9a..f24bf72a67b646b70dd767a59827d472bde040ac 100644 --- a/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/getappjumpcontrolrule_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/getappjumpcontrolrule_fuzzer/getappjumpcontrolrule_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,19 +18,21 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" using namespace OHOS::AppExecFwk; namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); std::string callerBundleName; std::string targetBundleName; AppJumpControlRule controlRules; - appControl.GetAppJumpControlRule( - callerBundleName, targetBundleName, reinterpret_cast(data), controlRules); + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.GetAppJumpControlRule( + callerBundleName, targetBundleName, reinterpret_cast(data), controlRules, funcResult); return true; } } // namespace OHOS diff --git a/test/fuzztest/fuzztest_others/quickfix_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/quickfix_fuzzer/BUILD.gn index 51f4ff95cebdfae849095485efdff346c7d5149c..d06e4586b3599c2dcacd52c3cb87ba34bc32b26a 100644 --- a/test/fuzztest/fuzztest_others/quickfix_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/quickfix_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("QuickFixFuzzTest") { "${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/first_right:first_right", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ diff --git a/test/fuzztest/fuzztest_others/quickfix_fuzzer/quickfix_fuzzer.cpp b/test/fuzztest/fuzztest_others/quickfix_fuzzer/quickfix_fuzzer.cpp index abad400d89e326daaf67d7b10cb09a18ca015a8a..0d55841be380779ac1a4eb1a94d6abcfdb2ff2db 100644 --- a/test/fuzztest/fuzztest_others/quickfix_fuzzer/quickfix_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/quickfix_fuzzer/quickfix_fuzzer.cpp @@ -20,7 +20,7 @@ #include #include -#include "app_control_proxy.h" +#include "app_control_mgr_proxy.h" #include "quick_fixer.h" using namespace OHOS::AppExecFwk; diff --git a/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/BUILD.gn index af5b9e59b5dc452ae97a13c433a4af57a1939ca4..2a28b13e939ca79c7fca3119fca096516362b15b 100644 --- a/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/BUILD.gn @@ -51,6 +51,7 @@ ohos_fuzztest("QuickFixMgrFuzzTest") { "${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test", "${bundle_framework_path}/test/sceneProject/unittest/test_bundle/first_right:first_right", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ diff --git a/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/quickfixmgr_fuzzer.cpp b/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/quickfixmgr_fuzzer.cpp index 81ccb77c1fd9e9772ebfc67bc764a4027bc47b88..b880b9aec6540929d7809b84c777dab7a1217dd9 100644 --- a/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/quickfixmgr_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/quickfixmgr_fuzzer/quickfixmgr_fuzzer.cpp @@ -20,7 +20,7 @@ #include #include -#include "app_control_proxy.h" +#include "app_control_mgr_proxy.h" #include "quick_fix_mgr.h" using namespace OHOS::AppExecFwk; diff --git a/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/BUILD.gn index 86bb502f0ad8a0c7d4d655354862c329bab3b840..eacf2047014340d4ed6ade1a845f6fe30e7665bc 100755 --- a/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -36,6 +36,7 @@ ohos_fuzztest("SetDisposedStatusFuzzTest") { "${base_path}:appexecfwk_base", "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_proxy", ] external_deps = [ "ability_base:want", diff --git a/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/setdisposedstatus_fuzzer.cpp b/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/setdisposedstatus_fuzzer.cpp index 7b29f393bd766ff8b71111bde5509f15de5c5b5c..a2d861b90b053e4f7d38421411063308cbbc30c6 100755 --- a/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/setdisposedstatus_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/setdisposedstatus_fuzzer/setdisposedstatus_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,9 @@ #include #include -#include "app_control_proxy.h" +#include "appexecfwk_errors.h" +#include "app_control_mgr_proxy.h" +#include "bundle_constants.h" #include "setdisposedstatus_fuzzer.h" @@ -27,12 +29,14 @@ namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { sptr object; - AppControlProxy appControl(object); + AppControlMgrProxy appControlMgrProxy(object); Want want; std::string appId (reinterpret_cast(data), size); std::string bundleName (reinterpret_cast(data), size); want.SetAction(bundleName); - appControl.SetDisposedStatus(appId, want); + int32_t userId = Constants::UNSPECIFIED_USERID; + int32_t funcResult = ERR_APPEXECFWK_IDL_GET_RESULT_ERROR; + appControlMgrProxy.SetDisposedStatus(appId, want, userId, funcResult); return true; } } diff --git a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp index 8d29ead0cddefdd605610ee64be35b66af501582..7a1e60b363b5af3ac25538b9c64c411bfbf526dd 100644 --- a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp +++ b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp @@ -21,6 +21,7 @@ #include #include "accesstoken_kit.h" +#include "app_control_client.h" #include "app_log_wrapper.h" #include "bundle_additional_info.h" #include "bundle_constants.h" @@ -9742,27 +9743,25 @@ HWTEST_F(ActsBmsKitSystemTest, AppControlCache_0001, Function | MediumTest | Lev std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap"; std::string appName = BASE_BUNDLE_NAME + "1"; Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec); - sptr bundleMgrProxy = GetBundleMgrProxy(); - sptr appControlProxy = bundleMgrProxy->GetAppControlProxy(); setuid(3057); std::vector controlRules; AppRunningControlRule controlRule; controlRule.appId = APPID; controlRule.controlMessage = CONTROL_MESSAGE; controlRules.emplace_back(controlRule); - ErrCode res = appControlProxy->AddAppRunningControlRule(controlRules, USERID); + ErrCode res = AppControlClient::GetInstance().AddAppRunningControlRule(controlRules, USERID); EXPECT_EQ(res, ERR_OK); setuid(5523); AppRunningControlRuleResult controlRuleResult; - res = appControlProxy->GetAppRunningControlRule(appName, USERID, controlRuleResult); + res = AppControlClient::GetInstance().GetAppRunningControlRule(appName, USERID, controlRuleResult); EXPECT_EQ(res, ERR_OK); EXPECT_EQ(controlRuleResult.controlMessage, CONTROL_MESSAGE); setuid(3057); - res = appControlProxy->DeleteAppRunningControlRule(USERID); + res = AppControlClient::GetInstance().DeleteAppRunningControlRule(USERID); EXPECT_EQ(res, ERR_OK); setuid(5523); AppRunningControlRuleResult controlRuleResult2; - res = appControlProxy->GetAppRunningControlRule(appName, USERID, controlRuleResult2); + res = AppControlClient::GetInstance().GetAppRunningControlRule(appName, USERID, controlRuleResult2); EXPECT_EQ(res, ERR_BUNDLE_MANAGER_BUNDLE_NOT_SET_CONTROL); EXPECT_EQ(controlRuleResult2.controlMessage, ""); Uninstall(appName, resvec); diff --git a/test/systemtest/common/bms/bms_app_control_host_test/BUILD.gn b/test/systemtest/common/bms/bms_app_control_host_test/BUILD.gn index e47c8077c3a232a24ee84429b23264a56c999ecd..3ab8f08be89d1244d94c00ffd22e643f94ac017e 100644 --- a/test/systemtest/common/bms/bms_app_control_host_test/BUILD.gn +++ b/test/systemtest/common/bms/bms_app_control_host_test/BUILD.gn @@ -31,6 +31,7 @@ ohos_systemtest("BmsAppControlHostTest") { deps = [ "${common_path}:libappexecfwk_common", "${core_path}:appexecfwk_core", + "${core_path}:app_control_mgr_stub", ] defines = [ "APP_LOG_TAG = \"BundleMgrTool\"" ] diff --git a/test/systemtest/common/bms/bms_app_control_host_test/bms_app_control_host_test.cpp b/test/systemtest/common/bms/bms_app_control_host_test/bms_app_control_host_test.cpp index 0fa3cf83993a18c585beadae730718680c1edb10..64b1eacc93afb37e0b9b106803763998f31231f9 100644 --- a/test/systemtest/common/bms/bms_app_control_host_test/bms_app_control_host_test.cpp +++ b/test/systemtest/common/bms/bms_app_control_host_test/bms_app_control_host_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,8 +17,9 @@ #include #include #include -#include "app_control_host.h" +#include "app_control_mgr_stub.h" #include "bundle_framework_core_ipc_interface_code.h" +#include "iapp_control_mgr.h" using namespace testing::ext; @@ -33,6 +34,175 @@ public: void TearDown(); }; +class MockAppControlMgrStub : public AppControlMgrStub { +public: + int32_t CallbackEnter(uint32_t code) override + { + return ERR_NONE; + } + + int32_t CallbackExit(uint32_t code, int32_t result) override + { + return ERR_NONE; + } + + ErrCode AddAppInstallControlRule(const std::vector &appIds, + const AppInstallControlRuleType controlRuleType, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode DeleteAppInstallControlRule(const AppInstallControlRuleType controlRuleType, + const std::vector &appIds, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode DeleteAppInstallControlRule( + const AppInstallControlRuleType controlRuleType, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode GetAppInstallControlRule(const AppInstallControlRuleType controlRuleType, int32_t userId, + std::vector &appIds, int32_t &funcResult) override + { + return ERR_OK; + } + // for app running control rule + ErrCode AddAppRunningControlRule( + const std::vector &controlRules, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode DeleteAppRunningControlRule( + const std::vector &controlRules, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode DeleteAppRunningControlRule(int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode GetAppRunningControlRule(int32_t userId, std::vector &appIds, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode GetAppRunningControlRule(const std::string &bundleName, int32_t userId, + AppRunningControlRuleResult &controlRule, int32_t &funcResult) override + { + return ERR_OK; + } + + // for app jump control rule + ErrCode ConfirmAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, + int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode AddAppJumpControlRule(const std::vector &controlRules, int32_t userId, + int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode DeleteAppJumpControlRule(const std::vector &controlRules, + int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode DeleteRuleByCallerBundleName(const std::string &callerBundleName, int32_t userId, + int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode DeleteRuleByTargetBundleName(const std::string &targetBundleName, int32_t userId, + int32_t &funcResult) override + { + return ERR_OK; + } + ErrCode GetAppJumpControlRule(const std::string &callerBundleName, const std::string &targetBundleName, + int32_t userId, AppJumpControlRule &controlRule, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode SetDisposedStatus( + const std::string &appId, const Want &want, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode DeleteDisposedStatus( + const std::string &appId, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode GetDisposedStatus( + const std::string &appId, int32_t userId, Want &want, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode SetDisposedRule( + const std::string &appId, int32_t userId, DisposedRule &DisposedRule, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode SetDisposedRules(int32_t userId, BundleMgrRawData &disposedRuleConfigurationsRawData, + int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode GetDisposedRule( + const std::string &appId, int32_t userId, DisposedRule &DisposedRule, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t userId, + int32_t appIndex, std::vector& disposedRules, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode SetDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, int32_t userId, + DisposedRule &DisposedRule, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode GetDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, int32_t userId, + DisposedRule &DisposedRule, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode DeleteDisposedRuleForCloneApp( + const std::string &appId, int32_t appIndex, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode GetUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, + int32_t userId, UninstallDisposedRule &rule, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode SetUninstallDisposedRule(const std::string &appIdentifier, const UninstallDisposedRule &rule, + int32_t appIndex, int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } + + ErrCode DeleteUninstallDisposedRule(const std::string &appIdentifier, int32_t appIndex, + int32_t userId, int32_t &funcResult) override + { + return ERR_OK; + } +}; + void BmsAppControlHostTest::SetUpTestCase() {} @@ -45,366 +215,6 @@ void BmsAppControlHostTest::SetUp() void BmsAppControlHostTest::TearDown() {} -/** - * @tc.number: HandleAddAppInstallControlRule_0100 - * @tc.name: test the HandleAddAppInstallControlRule - * @tc.desc: 1. system running normally - * 2. test HandleAddAppInstallControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleAddAppInstallControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleAddAppInstallControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleDeleteAppInstallControlRule_0100 - * @tc.name: test the HandleDeleteAppInstallControlRule - * @tc.desc: 1. system running normally - * 2. test HandleDeleteAppInstallControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteAppInstallControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleDeleteAppInstallControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleCleanAppInstallControlRule_0100 - * @tc.name: test the HandleCleanAppInstallControlRule - * @tc.desc: 1. system running normally - * 2. test HandleCleanAppInstallControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleCleanAppInstallControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleCleanAppInstallControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleGetAppInstallControlRule_0100 - * @tc.name: test the HandleGetAppInstallControlRule - * @tc.desc: 1. system running normally - * 2. test HandleGetAppInstallControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleGetAppInstallControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetAppInstallControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleAddAppRunningControlRule_0100 - * @tc.name: test the HandleAddAppRunningControlRule - * @tc.desc: 1. system running normally - * 2. test HandleAddAppRunningControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleAddAppRunningControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleAddAppRunningControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleDeleteAppRunningControlRule_0100 - * @tc.name: test the HandleDeleteAppRunningControlRule - * @tc.desc: 1. system running normally - * 2. test HandleDeleteAppRunningControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteAppRunningControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleDeleteAppRunningControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleCleanAppRunningControlRule_0100 - * @tc.name: test the HandleCleanAppRunningControlRule - * @tc.desc: 1. system running normally - * 2. test HandleCleanAppRunningControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleCleanAppRunningControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleCleanAppRunningControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleGetAppRunningControlRule_0100 - * @tc.name: test the HandleGetAppRunningControlRule - * @tc.desc: 1. system running normally - * 2. test HandleGetAppRunningControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleGetAppRunningControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetAppRunningControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleGetAppRunningControlRuleResult_0100 - * @tc.name: test the HandleGetAppRunningControlRuleResult - * @tc.desc: 1. system running normally - * 2. test HandleGetAppRunningControlRuleResult - */ -HWTEST_F(BmsAppControlHostTest, HandleGetAppRunningControlRuleResult_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetAppRunningControlRuleResult(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: HandleConfirmAppJumpControlRule_0100 - * @tc.name: test the HandleConfirmAppJumpControlRule - * @tc.desc: 1. system running normally - * 2. test HandleConfirmAppJumpControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleConfirmAppJumpControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleConfirmAppJumpControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleAddAppJumpControlRule_0100 - * @tc.name: test the HandleAddAppJumpControlRule - * @tc.desc: 1. system running normally - * 2. test HandleAddAppJumpControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleAddAppJumpControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleAddAppJumpControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleDeleteAppJumpControlRule_0100 - * @tc.name: test the HandleDeleteAppJumpControlRule - * @tc.desc: 1. system running normally - * 2. test HandleDeleteAppJumpControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteAppJumpControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleDeleteAppJumpControlRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleDeleteRuleByCallerBundleName_0100 - * @tc.name: test the HandleDeleteRuleByCallerBundleName - * @tc.desc: 1. system running normally - * 2. test HandleDeleteRuleByCallerBundleName - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteRuleByCallerBundleName_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleDeleteRuleByCallerBundleName(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleDeleteRuleByTargetBundleName_0100 - * @tc.name: test the HandleDeleteRuleByTargetBundleName - * @tc.desc: 1. system running normally - * 2. test HandleDeleteRuleByTargetBundleName - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteRuleByTargetBundleName_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleDeleteRuleByTargetBundleName(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR); -} - -/** - * @tc.number: HandleGetAppJumpControlRule_0100 - * @tc.name: test the HandleGetAppJumpControlRule - * @tc.desc: 1. system running normally - * 2. test HandleGetAppJumpControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleGetAppJumpControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetAppJumpControlRule(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: HandleSetDisposedStatus_0100 - * @tc.name: test the HandleSetDisposedStatus - * @tc.desc: 1. system running normally - * 2. test HandleSetDisposedStatus - */ -HWTEST_F(BmsAppControlHostTest, HandleSetDisposedStatus_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleSetDisposedStatus(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); -} - -/** - * @tc.number: HandleDeleteDisposedStatus_0100 - * @tc.name: test the HandleDeleteDisposedStatus - * @tc.desc: 1. system running normally - * 2. test HandleDeleteDisposedStatus - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteDisposedStatus_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleDeleteDisposedStatus(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: HandleGetDisposedStatus_0100 - * @tc.name: test the HandleGetDisposedStatus - * @tc.desc: 1. system running normally - * 2. test HandleGetDisposedStatus - */ -HWTEST_F(BmsAppControlHostTest, HandleGetDisposedStatus_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetDisposedStatus(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: HandleGetDisposedRule_0100 - * @tc.name: test the HandleGetDisposedRule - * @tc.desc: 1. system running normally - * 2. test HandleGetDisposedRule - */ -HWTEST_F(BmsAppControlHostTest, HandleGetDisposedRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetDisposedRule(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: HandleSetDisposedRule_0100 - * @tc.name: test the HandleSetDisposedRule - * @tc.desc: 1. system running normally - * 2. test HandleSetDisposedRule - */ -HWTEST_F(BmsAppControlHostTest, HandleSetDisposedRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleSetDisposedRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); -} - -/** - * @tc.number: HandleGetAbilityRunningControlRule_0100 - * @tc.name: test the HandleGetAbilityRunningControlRule - * @tc.desc: 1. system running normally - * 2. test HandleGetAbilityRunningControlRule - */ -HWTEST_F(BmsAppControlHostTest, HandleGetAbilityRunningControlRule_0100, Function | MediumTest | Level1) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetAbilityRunningControlRule(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: HandleSetUninstallDisposedRule_0100 - * @tc.name: Test HandleSetUninstallDisposedRule by AppControlHost - * @tc.desc: 1.HandleSetUninstallDisposedRule test - */ -HWTEST_F(BmsAppControlHostTest, HandleSetUninstallDisposedRule_0100, Function | MediumTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleSetUninstallDisposedRule(data, reply); - EXPECT_EQ(res, ERR_APPEXECFWK_PARCEL_ERROR); -} - -/** - * @tc.number: HandleGetUninstallDisposedRule_0100 - * @tc.name: Test HandleGetUninstallDisposedRule by AppControlHost - * @tc.desc: 1.HandleGetUninstallDisposedRule test - */ -HWTEST_F(BmsAppControlHostTest, HandleGetUninstallDisposedRule_0100, Function | MediumTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleGetUninstallDisposedRule(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: HandleDeleteUninstallDisposedRule_0100 - * @tc.name: Test HandleDeleteUninstallDisposedRule by AppControlHost - * @tc.desc: 1.HandleDeleteUninstallDisposedRule test - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteUninstallDisposedRule_0100, Function | MediumTest | Level1) -{ - std::shared_ptr appControlHost = std::make_shared(); - ASSERT_NE(appControlHost, nullptr); - MessageParcel data; - MessageParcel reply; - auto res = appControlHost->HandleDeleteUninstallDisposedRule(data, reply); - EXPECT_EQ(res, ERR_OK); -} - /** * @tc.number: OnRemoteRequest_0100 * @tc.name: test the OnRemoteRequest @@ -413,58 +223,13 @@ HWTEST_F(BmsAppControlHostTest, HandleDeleteUninstallDisposedRule_0100, Function */ HWTEST_F(BmsAppControlHostTest, OnRemoteRequest_0100, Function | MediumTest | Level0) { - AppControlHost appControlHost; + MockAppControlMgrStub appControlMgrStub; MessageParcel data; MessageParcel reply; MessageOption option; - ErrCode res = appControlHost.OnRemoteRequest( - static_cast(AppControlManagerInterfaceCode::GET_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); - EXPECT_EQ(res, OBJECT_NULL); -} - -/** - * @tc.number: HandleDeleteDisposedRuleForCloneApp_0100 - * @tc.name: test the HandleDeleteDisposedRuleForCloneApp - * @tc.desc: 1. system running normally - * 2. test HandleDeleteDisposedRuleForCloneApp - */ -HWTEST_F(BmsAppControlHostTest, HandleDeleteDisposedRuleForCloneApp_0100, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleDeleteDisposedRuleForCloneApp(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.number: WriteStringVector_0100 - * @tc.name: test the WriteStringVector - * @tc.desc: 1. system running normally - * 2. test WriteStringVector - */ -HWTEST_F(BmsAppControlHostTest, WriteStringVector_0100, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - std::vector stringVector; - MessageParcel reply; - ErrCode res = appControlHost.WriteStringVector(stringVector, reply); - EXPECT_TRUE(res); -} - -/** - * @tc.number: HandleGetDisposedRuleForCloneApp_0100 - * @tc.name: test the HandleGetDisposedRuleForCloneApp - * @tc.desc: 1. system running normally - * 2. test HandleGetDisposedRuleForCloneApp - */ -HWTEST_F(BmsAppControlHostTest, HandleGetDisposedRuleForCloneApp_0100, Function | MediumTest | Level0) -{ - AppControlHost appControlHost; - MessageParcel data; - MessageParcel reply; - ErrCode res = appControlHost.HandleGetDisposedRuleForCloneApp(data, reply); - EXPECT_EQ(res, ERR_OK); + ErrCode res = appControlMgrStub.OnRemoteRequest( + static_cast(IAppControlMgrIpcCode::COMMAND_GET_DISPOSED_RULE_FOR_CLONE_APP), data, reply, option); + EXPECT_EQ(res, ERR_TRANSACTION_FAILED); } } // AppExecFwk } // OHOS \ No newline at end of file