From 7a6d36dfc6fb35c025074871f3ecb3341449d791 Mon Sep 17 00:00:00 2001 From: Rayllll Date: Tue, 6 May 2025 15:57:26 +0800 Subject: [PATCH 1/2] Signed-off-by: Rayllll modify partitionslot deps --- bundle.json | 2 +- interfaces/kits/slot_info/BUILD.gn | 2 +- interfaces/kits/slot_info/slot_info.cpp | 24 ++++++++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bundle.json b/bundle.json index 4f2d73c0..a591441e 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 e513ffb5..d584fa8b 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:utilsbase", - "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 e6f2787d..17b5ca16 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,11 @@ 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); int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = partitionslot->GetSlotSuffix(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 +49,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 +58,18 @@ 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); 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 +78,18 @@ void GetActivePartitionSuffix(std::string &suffix) void SetActiveSlot() { - OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; + sptr partitionslot = + OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); 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; } -- Gitee From ec98781226b316de0da402eebf47886d142bdb3e Mon Sep 17 00:00:00 2001 From: Rayllll Date: Tue, 6 May 2025 15:57:26 +0800 Subject: [PATCH 2/2] Signed-off-by: Rayllll modify partitionslot deps Signed-off-by: Rayllll --- bundle.json | 2 +- interfaces/kits/slot_info/BUILD.gn | 2 +- interfaces/kits/slot_info/slot_info.cpp | 24 ++++++++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bundle.json b/bundle.json index 4f2d73c0..a591441e 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 e513ffb5..d584fa8b 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:utilsbase", - "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 e6f2787d..844ea766 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,11 @@ 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); int32_t curSlot = -1; int32_t numOfSlots = 0; - int32_t ret = psMgr.GetCurrentSlot(curSlot, numOfSlots); + int32_t ret = partitionslot->GetSlotSuffix(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 +49,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 +58,18 @@ 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); 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 +78,18 @@ void GetActivePartitionSuffix(std::string &suffix) void SetActiveSlot() { - OHOS::HDI::Partitionslot::V1_0::PartitionSlotManager psMgr; + sptr partitionslot = + OHOS::HDI::Partitionslot::V1_0::IPartitionSlot::Get(true); 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; } -- Gitee