diff --git a/bundle.json b/bundle.json index 4f2d73c0fa941cb3208eb096f53cbc4d4c7d5338..a591441e92f68e9f83c67435877c4245ca98f7ab 100644 --- a/bundle.json +++ b/bundle.json @@ -50,7 +50,7 @@ "init", "hdc", "drivers_interface_input", - "drivers_peripheral_partitionslot", + "drivers_interface_partitionslot", "c_utils", "hilog", "selinux_adapter", diff --git a/interfaces/kits/slot_info/BUILD.gn b/interfaces/kits/slot_info/BUILD.gn index 3aff7f72cd498f275a04b8e0b00a800329d9bbb4..98db2059161ca9414e15416c8ad7c98e60b2def6 100644 --- a/interfaces/kits/slot_info/BUILD.gn +++ b/interfaces/kits/slot_info/BUILD.gn @@ -29,7 +29,7 @@ ohos_static_library("libslotinfo") { defines = [ "UPDATER_AB_SUPPORT" ] external_deps = [ "c_utils:utils", - "drivers_peripheral_partitionslot:libpartition_slot_manager", + "drivers_interface_partitionslot:libpartitionslot_proxy_1.0", "hilog:libhilog_base", "init:libbegetutil_static", ] diff --git a/interfaces/kits/slot_info/slot_info.cpp b/interfaces/kits/slot_info/slot_info.cpp index e6f2787dcd01ac11f55d9d30b7cadbf5ab21eb1f..0948b5f59e0d5b65534fa8ddb67921120979ab19 100644 --- a/interfaces/kits/slot_info/slot_info.cpp +++ b/interfaces/kits/slot_info/slot_info.cpp @@ -17,7 +17,8 @@ #include "log/log.h" #ifdef UPDATER_AB_SUPPORT -#include "partitionslot_manager.h" +#include "v1_0/ipartition_slot.h" +using namespace OHOS::HDI::Partitionslot::V1_0; #endif namespace Updater { @@ -36,10 +37,15 @@ void SetActiveSlot() #else void GetPartitionSuffix(std::string &suffix) { - OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; + sptr partitionslot = + OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); + if (partitionslot == nullptr) { + LOG(ERROR) << "partitionslot ptr is nullptr"; + return; + } int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = partitionslot->GetCurrentSlot(curSlot, numOfSlots); LOG(INFO) << "Get slot info, curSlot: " << curSlot << "numOfSlots :" << numOfSlots; if (ret != 0 || curSlot <= 0 || curSlot > 2 || numOfSlots != 2) { // 2: max slot num suffix = ""; @@ -47,7 +53,7 @@ void GetPartitionSuffix(std::string &suffix) } int32_t updateSlot = curSlot == 1 ? 2 : 1; - ret = psMgr.GetSlotSuffix(updateSlot, suffix); + ret = partitionslot->GetSlotSuffix(updateSlot, suffix); if (ret != 0) { LOG(ERROR) << "Get slot suffix error, partitionPath: " << suffix; suffix = ""; @@ -56,17 +62,22 @@ void GetPartitionSuffix(std::string &suffix) void GetActivePartitionSuffix(std::string &suffix) { - OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; + sptr partitionslot = + OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); + if (partitionslot == nullptr) { + LOG(ERROR) << "partitionslot ptr is nullptr"; + return; + } int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = partitionslot->GetCurrentSlot(curSlot, numOfSlots); LOG(INFO) << "Get slot info, curSlot: " << curSlot << "numOfSlots :" << numOfSlots; if (ret != 0 || curSlot <= 0 || curSlot > 2 || numOfSlots != 2) { // 2: max slot num suffix = ""; return; } - ret = psMgr.GetSlotSuffix(curSlot, suffix); + ret = partitionslot->GetSlotSuffix(curSlot, suffix); if (ret != 0) { LOG(ERROR) << "Get slot suffix error, partitionPath: " << suffix; suffix = ""; @@ -75,17 +86,22 @@ void GetActivePartitionSuffix(std::string &suffix) void SetActiveSlot() { - OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; + sptr partitionslot = + OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); + if (partitionslot == nullptr) { + LOG(ERROR) << "partitionslot ptr is nullptr"; + return; + } int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = partitionslot->GetCurrentSlot(curSlot, numOfSlots); LOG(INFO) << "Get slot info, curSlot: " << curSlot << "numOfSlots :" << numOfSlots; if (ret != 0 || curSlot <= 0 || curSlot > 2 || numOfSlots != 2) { // 2: max slot num return; } int32_t activeSlot = curSlot == 1 ? 2 : 1; - ret = psMgr.SetActiveSlot(activeSlot); + ret = partitionslot->SetActiveSlot(activeSlot); if (ret != 0) { LOG(ERROR) << "Set active slot error, slot: " << activeSlot; }