diff --git a/services/security_component_service/sa/test/BUILD.gn b/services/security_component_service/sa/test/BUILD.gn index 3d71a9236923715016ac157060c2d7ed438805e7..58f619a47d29f8758bceb97daeba9d59c3d1d78f 100644 --- a/services/security_component_service/sa/test/BUILD.gn +++ b/services/security_component_service/sa/test/BUILD.gn @@ -75,11 +75,8 @@ ohos_unittest("sec_comp_service_test") { "ability_base:base", "ability_base:want", "ability_base:zuri", - "ability_runtime:ability_manager", "ability_runtime:runtime", "access_token:libtoken_setproc", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "c_utils:utils", "eventhandler:libeventhandler", "googletest:gmock_main", @@ -89,7 +86,6 @@ ohos_unittest("sec_comp_service_test") { "hitrace:hitrace_meter", "ipc:ipc_core", "json:nlohmann_json_static", - "window_manager:libdm", ] } @@ -148,11 +144,8 @@ ohos_unittest("sec_comp_service_mock_test") { "ability_base:base", "ability_base:want", "ability_base:zuri", - "ability_runtime:ability_manager", "ability_runtime:runtime", "access_token:libtoken_setproc", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "c_utils:utils", "eventhandler:libeventhandler", "googletest:gmock_main", @@ -162,7 +155,6 @@ ohos_unittest("sec_comp_service_mock_test") { "hitrace:hitrace_meter", "ipc:ipc_core", "json:nlohmann_json_static", - "window_manager:libdm", ] } diff --git a/services/security_component_service/sa/test/mock/include/ability_manager_client.h b/services/security_component_service/sa/test/mock/include/ability_manager_client.h new file mode 100644 index 0000000000000000000000000000000000000000..f8f9d9d456d57715c303aab043f4edced6428cba --- /dev/null +++ b/services/security_component_service/sa/test/mock/include/ability_manager_client.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_CLIENT_H +#define OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_CLIENT_H + +#include +#include "iremote_object.h" +#include "want.h" + +namespace OHOS { +namespace AAFwk { +/** + * @class AbilityManagerClient + * AbilityManagerClient is used to access ability manager services. + */ +class AbilityManagerClient { +public: + AbilityManagerClient() = default; + virtual ~AbilityManagerClient() = default; + static std::shared_ptr GetInstance() + { + static std::shared_ptr instance_ = std::make_shared(); + return instance_; + } + + ErrCode StartExtensionAbility(const Want &want, sptr callerToken) + { + return 0; + } +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_ABILITY_MANAGER_CLIENT_H diff --git a/services/security_component_service/sa/test/mock/include/bundle_info.h b/services/security_component_service/sa/test/mock/include/bundle_info.h new file mode 100644 index 0000000000000000000000000000000000000000..1313452b1a87cd20cdb9f3367170c271d8396bcf --- /dev/null +++ b/services/security_component_service/sa/test/mock/include/bundle_info.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H +#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H + +#include +#include + +namespace OHOS { +namespace AppExecFwk { +enum BundleFlag { + // get bundle info except abilityInfos + GET_BUNDLE_DEFAULT = 0x00000000, + // get bundle info include abilityInfos + GET_BUNDLE_WITH_ABILITIES = 0x00000001, + // get bundle info include request permissions + GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010, + // get bundle info include extension info + GET_BUNDLE_WITH_EXTENSION_INFO = 0x00000020, + // get bundle info include hash value + GET_BUNDLE_WITH_HASH_VALUE = 0x00000030, + // get bundle info inlcude menu, only for dump usage + GET_BUNDLE_WITH_MENU = 0x00000040, + // get bundle info inlcude router map, only for dump usage + GET_BUNDLE_WITH_ROUTER_MAP = 0x00000080, + // get bundle info include skill info + GET_BUNDLE_WITH_SKILL = 0x00000800, +}; + +// configuration information about a bundle +struct BundleInfo { + bool isNewVersion = false; + bool isKeepAlive = false; + bool singleton = false; + bool isPreInstallApp = false; + + bool isNativeApp = false; + + bool entryInstallationFree = false; // application : false; atomic service : true + bool isDifferentName = false; + std::string versionName; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H diff --git a/services/security_component_service/sa/test/mock/include/bundle_mgr_client.h b/services/security_component_service/sa/test/mock/include/bundle_mgr_client.h new file mode 100644 index 0000000000000000000000000000000000000000..1e20d42d9f9e8edfdbf94913b3fa3336b883901c --- /dev/null +++ b/services/security_component_service/sa/test/mock/include/bundle_mgr_client.h @@ -0,0 +1,42 @@ +/* + * 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_BUNDLEMGR_BUNDLE_MGR_CLIENT_H +#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_CLIENT_H + +#include "want.h" +#include "bundle_info.h" + +namespace OHOS { +namespace AppExecFwk { + +class BundleMgrClient { +public: + BundleMgrClient() = default; + virtual ~BundleMgrClient() = default; + + ErrCode GetNameForUid(const int uid, std::string &name) + { + return 0; + } + bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId = 0) + { + return true; + } +}; +} // namespace AppExecFwk +} // namespace OHOS + +#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_CLIENT_H diff --git a/services/security_component_service/sa/test/mock/include/display.h b/services/security_component_service/sa/test/mock/include/display.h new file mode 100644 index 0000000000000000000000000000000000000000..8dd4053571c1c3543cca23e2d974f0f9cc0e6d37 --- /dev/null +++ b/services/security_component_service/sa/test/mock/include/display.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SECURITY_COMPONENT_MANAGER_DISPLAY_MOCK_H +#define SECURITY_COMPONENT_MANAGER_DISPLAY_MOCK_H +#include "display_info.h" +#include "refbase.h" + +namespace OHOS::Rosen { +class Display : public RefBase { +public: + sptr GetDisplayInfo() const + { + return sptr::MakeSptr(); + } +}; +} +#endif // SECURITY_COMPONENT_MANAGER_DISPLAY_MOCK_H \ No newline at end of file diff --git a/services/security_component_service/sa/test/mock/include/display_info.h b/services/security_component_service/sa/test/mock/include/display_info.h new file mode 100644 index 0000000000000000000000000000000000000000..04b582a312d82e5bd317165a69190d724b038233 --- /dev/null +++ b/services/security_component_service/sa/test/mock/include/display_info.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SECURITY_COMPONENT_MANAGER_DISPLAY_INFO_MOCK_H +#define SECURITY_COMPONENT_MANAGER_DISPLAY_INFO_MOCK_H +#include +#include + +namespace OHOS::Rosen { +namespace { +static const int32_t DEFAULT_SCREEN_SIZE = 1500; +}; + +class DisplayInfo : public Parcelable { +public: + bool Marshalling(Parcel &parcel) const override + { + return true; + } + + int32_t GetWidth() const + { + return DEFAULT_SCREEN_SIZE; + } + + int32_t GetHeight() const + { + return DEFAULT_SCREEN_SIZE; + } + + int32_t GetPhysicalHeight() const + { + return DEFAULT_SCREEN_SIZE; + } + + int32_t GetAvailableHeight() const + { + return DEFAULT_SCREEN_SIZE; + } + + std::vector GetCreaseRects() const + { + return std::vector(); + } +}; +} +#endif // SECURITY_COMPONENT_MANAGER_DISPLAY_INFO_MOCK_H diff --git a/services/security_component_service/sa/test/mock/include/display_manager.h b/services/security_component_service/sa/test/mock/include/display_manager.h new file mode 100644 index 0000000000000000000000000000000000000000..7861d6b536222f4b7d70580f73bac5cf6f504e93 --- /dev/null +++ b/services/security_component_service/sa/test/mock/include/display_manager.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H +#define SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H +#include "display.h" +#include "display_info.h" + +namespace OHOS::Rosen { +class DisplayManager { +public: + static DisplayManager& GetInstance() + { + static DisplayManager instance; + return instance; + } + + sptr GetDefaultDisplaySync() + { + return sptr::MakeSptr(); + } + + sptr GetDisplayById(uint64_t displayId) + { + return sptr::MakeSptr(); + } + + sptr GetCurrentFoldCreaseRegion() + { + return sptr::MakeSptr(); + } +}; +} +#endif // SECURITY_COMPONENT_MANAGER_DISPLAY_MANAGER_MOCK_H