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 9ee471b86..02062bff8 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 @@ -188,7 +188,9 @@ enum class BundleMgrInterfaceCode : uint32_t { GET_CONTINUE_BUNDLE_NAMES, GET_LAUNCH_WANT, UPDATE_APP_ENCRYPTED_KEY_STATUS, - IS_BUNDLE_INSTALLED + IS_BUNDLE_INSTALLED, + GET_COMPATIBLED_DEVICE_TYPE_NATIVE, + GET_COMPATIBLED_DEVICE_TYPE }; /* SAID: 401-85 Interface No.85 subservice also provides the following interfaces */ diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h index 3115ec2a8..72d165268 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h @@ -839,6 +839,10 @@ private: ErrCode HandleIsBundleInstalled(MessageParcel &data, MessageParcel &reply); + ErrCode HandleGetCompatibleDeviceTypeNative(MessageParcel &data, MessageParcel &reply); + + ErrCode HandleGetCompatibleDeviceType(MessageParcel &data, MessageParcel &reply); + private: /** * @brief Write a parcelabe vector objects to the proxy node. 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 d1fea73fb..5f2ce9f2b 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 @@ -1599,6 +1599,16 @@ public: { return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; } + + virtual ErrCode GetCompatibleDeviceTypeNative(std::string &deviceType) + { + return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; + } + + virtual ErrCode GetCompatibleDeviceType(const std::string &bundleName, std::string &deviceType) + { + return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; + } }; #define WRITE_PARCEL(func) \ diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h index 061da4007..d66bdb7a8 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h @@ -1115,6 +1115,8 @@ public: virtual ErrCode IsBundleInstalled(const std::string &bundleName, int32_t userId, int32_t appIndex, bool &isInstalled) override; + virtual ErrCode GetCompatibleDeviceType(const std::string &bundleName, std::string &deviceType) override; + private: /** * @brief Send a command message from the proxy object. diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp index 3e5d781ba..bb31bbdf5 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp @@ -606,6 +606,12 @@ int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa case static_cast(BundleMgrInterfaceCode::IS_BUNDLE_INSTALLED): errCode = HandleIsBundleInstalled(data, reply); break; + case static_cast(BundleMgrInterfaceCode::GET_COMPATIBLED_DEVICE_TYPE_NATIVE): + errCode = HandleGetCompatibleDeviceTypeNative(data, reply); + break; + case static_cast(BundleMgrInterfaceCode::GET_COMPATIBLED_DEVICE_TYPE): + errCode = HandleGetCompatibleDeviceType(data, reply); + break; default : APP_LOGW("bundleMgr host receives unknown code %{public}u", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -4120,5 +4126,38 @@ ErrCode BundleMgrHost::HandleIsBundleInstalled(MessageParcel &data, MessageParce } return ERR_OK; } + +ErrCode BundleMgrHost::HandleGetCompatibleDeviceTypeNative(MessageParcel &data, MessageParcel &reply) +{ + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); + std::string deviceType; + auto ret = GetCompatibleDeviceTypeNative(deviceType); + if (!reply.WriteInt32(ret)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!reply.WriteString(deviceType)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + return ERR_OK; +} + +ErrCode BundleMgrHost::HandleGetCompatibleDeviceType(MessageParcel &data, MessageParcel &reply) +{ + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); + std::string bundleName = data.ReadString(); + std::string deviceType; + auto ret = GetCompatibleDeviceType(bundleName, deviceType); + if (!reply.WriteInt32(ret)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!reply.WriteString(deviceType)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + return ERR_OK; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp index 4e56fe6fa..c2a1c0c89 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -5337,5 +5337,31 @@ ErrCode BundleMgrProxy::IsBundleInstalled(const std::string &bundleName, int32_t isInstalled = reply.ReadBool(); return ERR_OK; } + +ErrCode BundleMgrProxy::GetCompatibleDeviceType(const std::string &bundleName, std::string &deviceType) +{ + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + APP_LOGE("Write interface token fail"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!data.WriteString(bundleName)) { + APP_LOGE("Write bundle name fail"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + MessageParcel reply; + if (!SendTransactCmd(BundleMgrInterfaceCode::GET_COMPATIBLED_DEVICE_TYPE, data, reply)) { + APP_LOGE("Fail to IsBundleInstalled from server"); + return ERR_BUNDLE_MANAGER_IPC_TRANSACTION; + } + auto ret = reply.ReadInt32(); + if (ret == ERR_OK) { + deviceType = reply.ReadString(); + } + APP_LOGD("GetCompatibleDeviceType: ret: %{public}d, device type: %{public}s", ret, deviceType.c_str()); + return ret; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/bundlemgr_extension/BUILD.gn b/interfaces/inner_api/bundlemgr_extension/BUILD.gn index 12771efcb..4f4b18345 100644 --- a/interfaces/inner_api/bundlemgr_extension/BUILD.gn +++ b/interfaces/inner_api/bundlemgr_extension/BUILD.gn @@ -46,6 +46,7 @@ ohos_shared_library("bundlemgr_extension") { "appverify:libhapverify", "c_utils:utils", "hilog:libhilog", + "init:libbegetutil", "ipc:ipc_single", "relational_store:native_rdb", ] diff --git a/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h b/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h index dd18608bb..ba7aaf9d9 100644 --- a/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h +++ b/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h @@ -75,6 +75,7 @@ public: void CheckBundleNameAndStratAbility(const std::string &bundleName, const std::string &appIdentifier); bool DetermineCloneNum(const std::string &bundleName, const std::string &appIdentifier, int32_t &cloneNum); + std::string GetCompatibleDeviceType(const std::string &bundleName); private: bool OpenHandler(); static BmsExtension bmsExtension_; diff --git a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h index a595b67ac..b73e20704 100644 --- a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h +++ b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h @@ -153,6 +153,10 @@ public: { return false; } + virtual std::string GetCompatibleDeviceType(const std::string &bundleName) + { + return ""; + } }; } // AppExecFwk diff --git a/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp b/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp index 6a8d607d4..a1f8ff508 100644 --- a/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp +++ b/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp @@ -20,6 +20,7 @@ #include "bms_extension_data_mgr.h" #include "bms_extension_profile.h" #include "bundle_mgr_ext_register.h" +#include "parameter.h" namespace OHOS { namespace AppExecFwk { @@ -553,5 +554,20 @@ bool BmsExtensionDataMgr::DetermineCloneNum( } return bundleMgrExtPtr->DetermineCloneNum(bundleName, appIdentifier, cloneNum); } + +std::string BmsExtensionDataMgr::GetCompatibleDeviceType(const std::string &bundleName) +{ + if ((Init() == ERR_OK) && handler_) { + auto bundleMgrExtPtr = + BundleMgrExtRegister::GetInstance().GetBundleMgrExt(bmsExtension_.bmsExtensionBundleMgr.extensionName); + if (bundleMgrExtPtr) { + return bundleMgrExtPtr->GetCompatibleDeviceType(bundleName); + } + APP_LOGE("create class: %{public}s failed", bmsExtension_.bmsExtensionBundleMgr.extensionName.c_str()); + return ""; + } + APP_LOGW("access bms-extension failed"); + return GetDeviceType(); +} } // AppExecFwk } // OHOS diff --git a/interfaces/kits/native/bundle/include/bundle_mgr_proxy_native.h b/interfaces/kits/native/bundle/include/bundle_mgr_proxy_native.h index 6cf1c4470..bd970468e 100644 --- a/interfaces/kits/native/bundle/include/bundle_mgr_proxy_native.h +++ b/interfaces/kits/native/bundle/include/bundle_mgr_proxy_native.h @@ -40,8 +40,11 @@ public: */ bool GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo); + bool GetCompatibleDeviceTypeNative(std::string &deviceType); + enum { - GET_BUNDLE_INFO_FOR_SELF_NATIVE = 98 + GET_BUNDLE_INFO_FOR_SELF_NATIVE = 98, + GET_COMPATIBLED_DEVICE_TYPE_NATIVE = 166 }; private: sptr GetBmsProxy(); diff --git a/interfaces/kits/native/bundle/include/native_interface_bundle.h b/interfaces/kits/native/bundle/include/native_interface_bundle.h index 808bc8c38..cdabbaa09 100644 --- a/interfaces/kits/native/bundle/include/native_interface_bundle.h +++ b/interfaces/kits/native/bundle/include/native_interface_bundle.h @@ -146,6 +146,20 @@ char* OH_NativeBundle_GetAppIdentifier(); * @version 1.0 */ OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName(); + +/** + * @brief Obtains the compatible device type of the current application. + * After utilizing this interface, to prevent memory leaks, + * it is necessary to manually release the pointer returned by the interface. + * + * @return Returns the newly created string that indicates the compatible device type, + * if the returned object is NULL, it indicates creation failure. + * The possible cause of failure could be that the application address space is full, + * leading to space allocation failure. + * @since 14 + * @version 1.0 + */ +char* OH_NativeBundle_GetCompatibleDeviceType(); #ifdef __cplusplus }; #endif diff --git a/interfaces/kits/native/bundle/libbundle.ndk.json b/interfaces/kits/native/bundle/libbundle.ndk.json index a9db17ede..f61863508 100644 --- a/interfaces/kits/native/bundle/libbundle.ndk.json +++ b/interfaces/kits/native/bundle/libbundle.ndk.json @@ -14,5 +14,9 @@ { "first_introduced": "13", "name": "OH_NativeBundle_GetMainElementName" + }, + { + "first_introduced": "14", + "name": "OH_NativeBundle_GetCompatibleDeviceType" } ] diff --git a/interfaces/kits/native/bundle/src/bundle_mgr_proxy_native.cpp b/interfaces/kits/native/bundle/src/bundle_mgr_proxy_native.cpp index 8c150bb95..058e7827b 100644 --- a/interfaces/kits/native/bundle/src/bundle_mgr_proxy_native.cpp +++ b/interfaces/kits/native/bundle/src/bundle_mgr_proxy_native.cpp @@ -58,6 +58,29 @@ bool BundleMgrProxyNative::GetBundleInfoForSelf(int32_t flags, BundleInfo &bundl return true; } +bool BundleMgrProxyNative::GetCompatibleDeviceTypeNative(std::string &deviceType) +{ + LOG_I(BMS_TAG_QUERY, "begin to get compatible device type"); + MessageParcel data; + if (!data.WriteInterfaceToken(BMS_PROXY_INTERFACE_TOKEN)) { + LOG_E(BMS_TAG_QUERY, "Write interfaceToken failed"); + return false; + } + + MessageParcel reply; + if (!SendTransactCmd(GET_COMPATIBLED_DEVICE_TYPE_NATIVE, data, reply)) { + return false; + } + int32_t res = reply.ReadInt32(); + if (res != NO_ERROR) { + APP_LOGE("reply result failed"); + return false; + } + deviceType = reply.ReadString(); + APP_LOGD("get compatible device type success"); + return true; +} + bool BundleMgrProxyNative::SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply) { MessageOption option(MessageOption::TF_SYNC); diff --git a/interfaces/kits/native/bundle/src/native_interface_bundle.cpp b/interfaces/kits/native/bundle/src/native_interface_bundle.cpp index 2b4bbf72d..66ef681e5 100644 --- a/interfaces/kits/native/bundle/src/native_interface_bundle.cpp +++ b/interfaces/kits/native/bundle/src/native_interface_bundle.cpp @@ -248,3 +248,29 @@ OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName() } return elementName; } + +char* OH_NativeBundle_GetCompatibleDeviceType() +{ + OHOS::AppExecFwk::BundleMgrProxyNative bundleMgrProxyNative; + std::string deviceType; + if (!bundleMgrProxyNative.GetCompatibleDeviceTypeNative(deviceType)) { + APP_LOGE("can not get compatible device type"); + return nullptr; + } + if (deviceType.size() + 1 > CHAR_MAX_LENGTH) { + APP_LOGE("failed due to the length of device type is too long"); + return nullptr; + } + char* deviceTypeC = static_cast(malloc(deviceType.size() + 1)); + if (deviceTypeC == nullptr) { + APP_LOGE("failed due to malloc error"); + return nullptr; + } + if (strcpy_s(deviceTypeC, deviceType.size() + 1, deviceType.c_str()) != EOK) { + APP_LOGE("failed due to strcpy_s error"); + free(deviceTypeC); + return nullptr; + } + APP_LOGI("OH_NativeBundle_GetCompatibleDeviceType success"); + return deviceTypeC; +} diff --git a/services/bundlemgr/include/bundle_mgr_host_impl.h b/services/bundlemgr/include/bundle_mgr_host_impl.h index 7321b893a..8a239c120 100644 --- a/services/bundlemgr/include/bundle_mgr_host_impl.h +++ b/services/bundlemgr/include/bundle_mgr_host_impl.h @@ -1036,6 +1036,9 @@ public: virtual ErrCode IsBundleInstalled(const std::string &bundleName, int32_t userId, int32_t appIndex, bool &isInstalled) override; + virtual ErrCode GetCompatibleDeviceTypeNative(std::string &deviceType) override; + virtual ErrCode GetCompatibleDeviceType(const std::string &bundleName, std::string &deviceType) override; + private: const std::shared_ptr GetDataMgrFromService(); #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 37362587e..17c81b759 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -20,6 +20,7 @@ #include "app_mgr_interface.h" #include "aot/aot_handler.h" #include "bms_extension_client.h" +#include "bms_extension_data_mgr.h" #include "bundle_parser.h" #include "bundle_permission_mgr.h" #ifdef DISTRIBUTED_BUNDLE_FRAMEWORK @@ -4485,5 +4486,44 @@ ErrCode BundleMgrHostImpl::IsBundleInstalled(const std::string &bundleName, int3 } return dataMgr->IsBundleInstalled(bundleName, userId, appIndex, isInstalled); } + +ErrCode BundleMgrHostImpl::GetCompatibleDeviceTypeNative(std::string &deviceType) +{ + APP_LOGD("start GetCompatibleDeviceTypeNative"); + auto dataMgr = GetDataMgrFromService(); + if (dataMgr == nullptr) { + APP_LOGE("DataMgr is nullptr"); + return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; + } + std::string bundleName; + dataMgr->GetBundleNameForUid(IPCSkeleton::GetCallingUid(), bundleName); + BmsExtensionDataMgr bmsExtensionDataMgr; + deviceType = bmsExtensionDataMgr.GetCompatibleDeviceType(bundleName); + APP_LOGI("deviceType : %{public}s", deviceType.c_str()); + return ERR_OK; +} + +ErrCode BundleMgrHostImpl::GetCompatibleDeviceType(const std::string &bundleName, std::string &deviceType) +{ + APP_LOGD("start GetCompatibleDeviceType"); + if (!BundlePermissionMgr::IsSystemApp()) { + APP_LOGE("non-system app calling system api"); + return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + } + if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED)) { + APP_LOGE("Verify permission failed"); + return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + } + + auto dataMgr = GetDataMgrFromService(); + if (dataMgr == nullptr) { + APP_LOGE("DataMgr is nullptr"); + return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; + } + BmsExtensionDataMgr bmsExtensionDataMgr; + deviceType = bmsExtensionDataMgr.GetCompatibleDeviceType(bundleName); + APP_LOGI("deviceType : %{public}s", deviceType.c_str()); + return ERR_OK; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/fuzztest/fuzztest_application/bundlemgrproxy_fuzzer/bundlemgrproxy_fuzzer.cpp b/test/fuzztest/fuzztest_application/bundlemgrproxy_fuzzer/bundlemgrproxy_fuzzer.cpp index 796003088..7c665d90a 100755 --- a/test/fuzztest/fuzztest_application/bundlemgrproxy_fuzzer/bundlemgrproxy_fuzzer.cpp +++ b/test/fuzztest/fuzztest_application/bundlemgrproxy_fuzzer/bundlemgrproxy_fuzzer.cpp @@ -330,6 +330,8 @@ namespace OHOS { bundleMgrProxy.GetAllDesktopShortcutInfo(reinterpret_cast(data), shortcutInfos); bundleMgrProxy.GetOdidByBundleName(bundleName, odid); bundleMgrProxy.GetBundleInfosForContinuation(0, bundleInfos, reinterpret_cast(data)); + std::string deviceType; + bundleMgrProxy.GetCompatibleDeviceType(bundleName, deviceType); 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 3f8a5ae41..8e0d59553 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 @@ -9689,5 +9689,56 @@ HWTEST_F(ActsBmsKitSystemTest, IsBundleInstalled_0002, Function | MediumTest | L EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; std::cout << "END IsBundleInstalled_0002" << std::endl; } + +/** + * @tc.number: GetCompatibleDeviceType_0001 + * @tc.name: test GetCompatibleDeviceType interface + * @tc.desc: 1.under '/data/test/bms_bundle',there is a hap + * 2.install the app + * 3.call GetCompatibleDeviceType + */ +HWTEST_F(ActsBmsKitSystemTest, GetCompatibleDeviceType_0001, Function | MediumTest | Level1) +{ + std::cout << "START GetCompatibleDeviceType_0001" << std::endl; + std::vector resvec; + std::string bundleFilePath = THIRD_BUNDLE_PATH + "bundleClient1.hap"; + std::string appName = "com.example.ohosproject.hmservice"; + Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec); + CommonTool commonTool; + std::string installResult = commonTool.VectorToStr(resvec); + EXPECT_EQ(installResult, "Success") << "install fail!"; + + sptr bundleMgrProxy = GetBundleMgrProxy(); + ASSERT_NE(bundleMgrProxy, nullptr); + + std::string deviceType; + auto queryResult = bundleMgrProxy->GetCompatibleDeviceType(appName, deviceType); + + EXPECT_EQ(queryResult, ERR_OK); + + resvec.clear(); + Uninstall(appName, resvec); + std::string uninstallResult = commonTool.VectorToStr(resvec); + EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; + std::cout << "END GetCompatibleDeviceType_0001" << std::endl; +} + +/** + * @tc.number: GetCompatibleDeviceType_0002 + * @tc.name: test GetCompatibleDeviceType interface + * @tc.desc: GetCompatibleDeviceType failed for calling bundle name is invalid + */ +HWTEST_F(ActsBmsKitSystemTest, GetCompatibleDeviceType_0002, Function | MediumTest | Level1) +{ + std::cout << "START GetCompatibleDeviceType_0002" << std::endl; + sptr bundleMgrProxy = GetBundleMgrProxy(); + ASSERT_NE(bundleMgrProxy, nullptr); + + std::string deviceType; + auto queryResult = bundleMgrProxy->GetCompatibleDeviceType("", deviceType); + + EXPECT_EQ(queryResult, ERR_OK); + std::cout << "END GetCompatibleDeviceType_0002" << std::endl; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/common/bms/bms_bundle_mgr_host_test/bms_bundle_mgr_host_test.cpp b/test/systemtest/common/bms/bms_bundle_mgr_host_test/bms_bundle_mgr_host_test.cpp index cf99d1449..4afab4ced 100644 --- a/test/systemtest/common/bms/bms_bundle_mgr_host_test/bms_bundle_mgr_host_test.cpp +++ b/test/systemtest/common/bms/bms_bundle_mgr_host_test/bms_bundle_mgr_host_test.cpp @@ -1933,5 +1933,35 @@ HWTEST_F(BmsBundleMgrHostTest, HandleIsBundleInstalled_0001, Function | MediumTe ErrCode res = bundleMgrHost.HandleIsBundleInstalled(data, reply); EXPECT_EQ(res, ERR_OK); } + +/** + * @tc.number: HandleGetCompatibleDeviceTypeNative_0001 + * @tc.name: test the HandleGetCompatibleDeviceTypeNative + * @tc.desc: 1. system running normally + * 2. test HandleGetCompatibleDeviceTypeNative + */ +HWTEST_F(BmsBundleMgrHostTest, HandleGetCompatibleDeviceTypeNative_0001, Function | MediumTest | Level1) +{ + BundleMgrHost bundleMgrHost; + MessageParcel data; + MessageParcel reply; + ErrCode res = bundleMgrHost.HandleGetCompatibleDeviceTypeNative(data, reply); + EXPECT_EQ(res, ERR_OK); +} + +/** + * @tc.number: HandleGetCompatibleDeviceType_0001 + * @tc.name: test the HandleGetCompatibleDeviceType + * @tc.desc: 1. system running normally + * 2. test HandleGetCompatibleDeviceType + */ +HWTEST_F(BmsBundleMgrHostTest, HandleGetCompatibleDeviceType_0001, Function | MediumTest | Level1) +{ + BundleMgrHost bundleMgrHost; + MessageParcel data; + MessageParcel reply; + ErrCode res = bundleMgrHost.HandleGetCompatibleDeviceType(data, reply); + EXPECT_EQ(res, ERR_OK); +} } // AppExecFwk } // OHOS \ No newline at end of file